def self.process(filename = "wordpress.xml")
FileUtils.mkdir_p "_posts"
posts = 0
doc = Hpricot::XML(File.read(filename))
(doc/:channel/:item).each do |item|
title = item.at(:title).inner_text
name = "#{Date.parse((doc/:channel/:item).first.at(:pubDate).inner_text).to_s("%Y-%m-%d")}-#{title.downcase.gsub('[^a-z0-9]', '-')}.html"
File.open("_posts/#{name}", "w") do |f|
f.puts "---\nlayout: post\ntitle: \#{title}\n---\n\n"
f.puts item.at('content:encoded').inner_text
end
posts += 1
end
"Imported #{posts} posts"
end