lib/hoe.rb in hoe-1.1.7 vs lib/hoe.rb in hoe-1.2.0

- old
+ new

@@ -35,18 +35,20 @@ # # * announce - Generate email announcement file and post to rubyforge. # * audit - Run ZenTest against the package # * check_manifest - Verify the manifest # * clean - Clean up all the extras +# * config_hoe - Create a fresh ~/.hoerc file # * debug_gem - Show information about the gem. # * default - Run the default tasks # * docs - Build the docs HTML Files # * email - Generate email announcement file. # * install - Install the package. Uses PREFIX and RUBYLIB # * install_gem - Install the package as a gem # * multi - Run the test suite using multiruby # * package - Build all the packages +# * post_blog - Post announcement to blog. # * post_news - Post announcement to rubyforge. # * publish_docs - Publish RDoc to RubyForge # * release - Package and upload the release to rubyforge. # * ridocs - Generate ri locally for testing # * test - Run the test suite. Use FILTER to add to the command line. @@ -88,11 +90,11 @@ # * PREFIX - Used to specify a custom install location (for rake install). # * RUBY_DEBUG - Used to add extra flags to RUBY_FLAGS. # * RUBY_FLAGS - Used to specify flags to ruby [has smart default]. class Hoe - VERSION = '1.1.7' + VERSION = '1.2.0' rubyprefix = Config::CONFIG['prefix'] sitelibdir = Config::CONFIG['sitelibdir'] PREFIX = ENV['PREFIX'] || rubyprefix @@ -226,11 +228,11 @@ desc 'Show information about the gem.' task :debug_gem do puts spec.to_ruby end - self.lib_files = spec.files.grep(/^lib/) + self.lib_files = spec.files.grep(/^(lib|ext)/) self.bin_files = spec.files.grep(/^bin/) self.test_files = spec.files.grep(/^test/) Rake::GemPackageTask.new spec do |pkg| pkg.need_tar = @need_tar @@ -322,16 +324,41 @@ remote_dir = "/var/www/gforge-projects/#{rubyforge_name}/#{name}" local_dir = 'doc' sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}} end + # no doco for this one + task :publish_on_announce do + with_config do |rc, path| + if rc["publish_on_announce"] then + Rake::Task['publish_docs'].invoke + end + end + end + ############################################################ # Misc/Maintenance: + def with_config(create=false) + require 'yaml' + rc = File.expand_path("~/.hoerc") + + unless create then + if test ?f, rc then + config = YAML.load_file(rc) + yield(config, rc) + end + else + unless test ?f, rc then + yield(rc) + end + end + end + desc 'Run ZenTest against the package' task :audit do - libs = %w(lib test).join(File::PATH_SEPARATOR) + libs = %w(lib test ext).join(File::PATH_SEPARATOR) sh "zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}" end desc 'Clean up all the extras' task :clean => [ :clobber_docs, :clobber_package ] do @@ -339,10 +366,36 @@ files = Dir[pattern] rm_rf files unless files.empty? end end + desc 'Create a fresh ~/.hoerc file' + task :config_hoe do + with_config(:create) do |rc, path| + blog = { + "publish_on_announce" => false, + "blogs" => [ { + "user" => "user", + "url" => "url", + "extra_headers" => { + "mt_convert_breaks" => "markdown" + }, + "blog_id" => "blog_id", + "password"=>"password", + } ], + } + File.open(rc, "w") do |f| + YAML.dump(blog, f) + end + end + + with_config do |rc, path| + editor = ENV['EDITOR'] || 'vi' + system "#{editor} #{path}" + end + end + desc 'Generate email announcement file.' task :email do require 'rubyforge' subject, title, body, urls = announcement @@ -358,10 +411,30 @@ mail.puts urls end puts "Created email.txt" end + desc 'Post announcement to blog.' + task :post_blog do + require 'xmlrpc/client' + + with_config do |config, path| + subject, title, body, urls = announcement + config['blogs'].each do |site| + server = XMLRPC::Client.new2(site['url']) + content = site['extra_headers'].merge(:title => title, + :description => body) + result = server.call('metaWeblog.newPost', + site['blog_id'], + site['user'], + site['password'], + content, + true) + end + end + end + desc 'Post announcement to rubyforge.' task :post_news do require 'rubyforge' subject, title, body, urls = announcement @@ -370,10 +443,10 @@ rf.post_news(rubyforge_name, subject, "#{title}\n\n#{body}") puts "Posted to rubyforge" end desc 'Generate email announcement file and post to rubyforge.' - task :announce => [:email, :post_news] + task :announce => [:email, :post_news, :post_blog, :publish_on_announce ] desc "Verify the manifest" task :check_manifest => :clean do f = "Manifest.tmp" require 'find'