class Hoe
def define_spec
def define_spec self.spec = Gem::Specification.new do |s| dirs = Dir['lib'] manifest = read_manifest abort [ "Manifest is missing or couldn't be read.", "The Manifest is kind of a big deal.", "Maybe you're using a gem packaged by a linux project.", "It seems like they enjoy breaking other people's code." ].join "\n" unless manifest s.name = name s.version = version if version s.summary = summary s.email = email s.homepage = case urls when Hash then urls["home"] || urls.values.first when Array then urls.first else raise "unknown urls format: #{urls.inspect}" end s.rubyforge_project = rubyforge_name s.description = description s.files = manifest s.executables = s.files.grep(/^bin/) { |f| File.basename(f) } s.bindir = "bin" s.require_paths = dirs unless dirs.empty? s.rdoc_options = ['--main', readme_file] s.post_install_message = post_install_message s.test_files = Dir[*self.test_globs] missing "Manifest.txt" if s.files.empty? case author when Array s.authors = author else s.author = author end s.extra_rdoc_files += s.files.grep(/(txt|rdoc)$/) s.extra_rdoc_files.reject! { |f| f =~ %r%^(test|spec|vendor|template|data|tmp)/% } s.extra_rdoc_files += @extra_rdoc_files end unless self.version then version = nil version_re = /VERSION += +([\"\'])([\d][\w\.]+)\1/ spec.files.each do |file| next unless File.exist? file version = File.read_utf(file)[version_re, 2] rescue nil break if version end spec.version = self.version = version if version unless self.version then spec.version = self.version = "0.borked" warn "** Add 'VERSION = \"x.y.z\"' to your code," warn " add a version to your hoe spec," warn " or fix your Manifest.txt" end end # Do any extra stuff the user wants spec_extras.each do |msg, val| case val when Proc val.call spec.send(msg) else spec.send "#{msg}=", val end end end