lib/hoe.rb in hoe-1.0.4 vs lib/hoe.rb in hoe-1.0.5

- old
+ new

@@ -48,35 +48,40 @@ # # === Attributes # # The attributes that you can provide inside the new block above are: # -# ==== Mandatory (or damn good to set) +# ==== Mandatory # +# * name - The name of the release. +# * version - The version. Don't hardcode! use a constant in the project. +# +# ==== Damn Good to Set +# # * author - The author of the package. (can be array of authors) +# * changes - A description of the release's latest changes. # * description - A description of the project. -# * email - The author's email address. -# * name - The name of the release. +# * email - The author's email address. (can be array of urls) # * summary - A short summary of the project. # * url - The url of the project. -# * version - The version. Don't hardcode! use a constant in the project. # # ==== Optional # # * clean_globs - An array of file patterns to delete on clean. # * extra_deps - An array of rubygem dependencies. # * rubyforge_name - The name of the rubyforge project. [default: name.downcase] +# * spec_extras - A hash of extra values to set in the gemspec. # # === Environment Variables # # * PREFIX - Used to specify a custom install location (for rake install). # * RUBY_FLAGS - Used to specify flags to ruby [has smart default]. # * RUBY_DEBUG - Used to add extra flags to RUBY_FLAGS. # * FILTER - Used to add flags to test_unit (e.g., -n test_borked) class Hoe - VERSION = '1.0.4' + VERSION = '1.0.5' rubyprefix = Config::CONFIG['prefix'] sitelibdir = Config::CONFIG['sitelibdir'] PREFIX = ENV['PREFIX'] || rubyprefix @@ -89,31 +94,33 @@ RUBY_FLAGS = ENV['RUBY_FLAGS'] || "-w -I#{%w(lib bin test).join(File::PATH_SEPARATOR)}" + (RUBY_DEBUG ? " #{RUBY_DEBUG}" : '') FILTER = ENV['FILTER'] # for tests (eg FILTER="-n test_blah") - attr_accessor :author, :bin_files, :clean_globs, :description, :email, :extra_deps, :lib_files, :name, :rubyforge_name, :spec, :summary, :test_files, :url, :version + attr_accessor :author, :bin_files, :changes, :clean_globs, :description, :email, :extra_deps, :lib_files, :name, :rubyforge_name, :spec, :spec_extras, :summary, :test_files, :url, :version def initialize(name, version) self.name = name self.version = version # Defaults self.rubyforge_name = name.downcase self.url = "http://www.zenspider.com/ZSS/Products/#{name}/" self.author = "Ryan Davis" self.email = "ryand-ruby@zenspider.com" - self.clean_globs = %w(diff diff.txt demo.rb ri *.gem **/*~) + self.clean_globs = %w(diff diff.txt demo.rb email.txt ri *.gem **/*~) + self.changes = "#{author} is too lazy to write a changeset" self.description = "#{author} is too lazy to write a description" self.summary = "#{author} is too lazy to write a summary" self.extra_deps = [] + self.spec_extras = {} if name == 'hoe' then extra_deps << ['rake'] - extra_deps << ['rubyforge'] + extra_deps << ['rubyforge', '>= 0.3.0'] else - extra_deps << ['hoe'] + extra_deps << ['hoe', ">= #{VERSION}"] end yield self if block_given? define_tasks @@ -145,19 +152,23 @@ s.authors = author else s.author = author end s.email = email - s.homepage = url + s.homepage = Array(url).first s.rubyforge_project = rubyforge_name s.description = description extra_deps.each do |dep| s.add_dependency(*dep) end + spec_extras.each do |msg, val| + s.send "#{msg}=", val + end + s.files = File.read("Manifest.txt").split s.executables = s.files.grep(/bin/) { |f| File.basename(f) } s.bindir = "bin" s.require_paths = Dir['{lib,test}'] @@ -214,10 +225,16 @@ end rf = RubyForge.new puts "Logging in" rf.login + + c = rf.config + c["release_notes"] = description if description + c["release_changes"] = changes if changes + c["preformatted"] = true + puts "Releasing #{name} v. #{version} tarball" release_id = rf.add_release rubyforge_name, name, version, "#{pkg}.tgz" if release_id then puts " release_id = #{release_id.inspect}" puts "Releasing #{name} v. #{version} gem" @@ -230,13 +247,20 @@ ############################################################ # Doco Rake::RDocTask.new(:docs) do |rd| rd.main = "README.txt" - rd.options << '-d' if `which dot` =~ /\/dot/ and RUBY_PLATFORM !~ /win32/ + rd.options << '-d' if RUBY_PLATFORM !~ /win32/ and `which dot` =~ /\/dot/ rd.rdoc_dir = 'doc' - rd.rdoc_files.push(*spec.files.grep(/^(lib|bin)|txt$/)) + files = spec.files.grep(/^(lib|bin)|txt$/) + files -= ['Manifest.txt'] + rd.rdoc_files.push(*files) + + title = "#{name}-#{version} Documentation" + title = "#{rubyforge_name}'s " + title if rubyforge_name != title + + rd.options << "-t #{title}" end desc "Generate ri locally for testing" task :ridocs => :clean do sh %q{ rdoc --ri -o ri . } @@ -277,23 +301,71 @@ clean_globs.each do |pattern| files = Dir[pattern] rm_rf files unless files.empty? end end + + desc 'Generate email announcement file.' + task :email do + require 'rubyforge' + subject, body = announcement + + File.open("email.txt", "w") do |mail| + mail.puts subject + mail.puts + mail.puts body + end + puts "Created email.txt" + end + + desc 'Post announcement to rubyforge.' + task :post_news do + require 'rubyforge' + subject, body = announcement + + rf = RubyForge.new + rf.login + rf.post_news(rubyforge_name, subject, body) + puts "Posted to rubyforge" + end + + desc 'Generate email announcement file and post to rubyforge.' + task :announce => [:email, :post_news] + end # end define - def run_tests(multi=false) + def announcement + urls = " " + Array(url).map {|s| s.strip}.join("\n ") + + subject = "Subject: #{name} #{version} Released" + body = "#{name} version #{version} has been released!\n\n#{urls}\n\n#{description}\n\nChanges:\n\n#{changes}\n\n#{urls}\n" + + return subject, body + end + + def run_tests(multi=false) # :nodoc: msg = multi ? :sh : :ruby cmd = if test ?f, 'test/test_all.rb' then "#{RUBY_FLAGS} test/test_all.rb #{FILTER}" else - tests = (Dir.glob("test/**/test_*.rb") + ['test/unit']).map { |f| - "require \"#{f}\"" - } + tests = ((Dir.glob("test/**/test_*.rb") + ['test/unit']).map { |f| + "require \"#{f}\"" + }) "#{RUBY_FLAGS} -e '#{tests.join("; ")}' #{FILTER}" end cmd = "multiruby #{cmd}" if multi send msg, cmd + end + + ## + # Reads a file at +path+ and spits out an array of the +paragraphs+ specified + # + # changes = p.paragraphs_of('History.txt', 0..1).join("\n\n") + # summary, *description = p.paragraphs_of('Readme.txt', 3, 3..8) + + def paragraphs_of(path, *paragraphs) + file = File.read(path) + file.split(/\n\n+/).values_at(*paragraphs) end end class ::Rake::SshDirPublisher # :nodoc: attr_reader :host, :remote_dir, :local_dir