[Ruby] Announcements from HOE

Aaron Patterson aaron_patterson at speakeasy.net
Mon Jan 22 21:22:29 PST 2007


I thought it would be fun to post announcments to my blog from hoe, so I
added that functionality to my local copy of hoe.  Here's the result:

http://tenderlovemaking.com/2007/01/22/ograph-version-001-has-been-released/

It uses the MetaWeblog API:

  http://www.xmlrpc.com/metaWeblogApi

My diff is below.  Does anyone else like it?

==== //src/hoe/dev/lib/hoe.rb#4 -
/Users/aaron/Programming/ruby/p4/zss/src/hoe/dev/lib/hoe.rb ====
***************
*** 360,365 ****
--- 360,393 ----
        puts "Created email.txt"
      end
  
+     desc 'Post announcement to blog.'
+     task :post_blog do
+       require 'xmlrpc/client'
+       require 'yaml'
+       require 'rdoc/markup/simple_markup'
+       require 'rdoc/markup/simple_markup/to_html'
+ 
+       config = YAML.load_file([ ENV['HOME'],
+                   '.blogs',
+                   'config.yml'].join(File::SEPARATOR))
+       subject, title, body, urls = announcement
+       to_html = SM::ToHtml.new
+       markup  = SM::SimpleMarkup.new
+       config['blogs'].each do |site|
+         server    = XMLRPC::Client.new(site['host'], site['path'])
+         content   = { :title => title,
+                       :description => markup.convert(body, to_html)
+         }
+         result = server.call('metaWeblog.newPost',
+                              site['blog_id'],
+                              site['user'],
+                              site['password'],
+                              content,
+                              true
+                             )
+       end
+     end
+ 
      desc 'Post announcement to rubyforge.'
      task :post_news do
        require 'rubyforge'

-- 
Aaron Patterson
http://tenderlovemaking.com/


More information about the Ruby mailing list