This post originated from an RSS feed registered with Ruby Buzz
by Gregory Brown.
Original Post: Okay, finally done with infrastructure (for now)
Feed Title: Ruby Reports Blog
Feed URL: http://www.cwinters.com/blog/index.rss
Feed Description: News and Updates regarding the Ruby Reports library and toolset.
Now that I have my nice little vim integration script for Infogami, I'm happy.
If anyone is curious, here's what it looks like:
require "rubygems"
require "mechanize"
require "redcloth"
class WWW::Form
def field(field_name)
self.fields.find { |f| f.name.eql? field_name }
end
end
entry = ARGF.read.to_a
title = entry[0].chomp
body = entry[2..-1].join
url = title.gsub(" ","_").downcase
agent = WWW::Mechanize.new
agent.get "http://ruport.infogami.com/_edit/blog/_add"
form = agent.page.forms[0]
form.field("url").value = url
form.field("title").value = title
form.field("body").value = RedCloth.new(body).to_html
begin
agent.submit(form, form.buttons.first)
rescue WWW::ResponseCodeError
nil
end
Now that I've got a happy home, I can start working on Ruport's Fetchable module,
which will abstract data acquisition, and hopefully politely open the doors to ActiveRecord.