Sha256: f002694ed50cdd94f51d08e5d965edb58191cc6e9439aea9d1be68c432061764

Contents?: true

Size: 879 Bytes

Versions: 13

Compression:

Stored size: 879 Bytes

Contents

require 'rubygems'
require 'rake'
require 'open-uri'
require 'multi_json'
require 'awesome_print'
require 'hashie'

class Post < Hashie::Mash
  def date
    Time.parse(self['published'])
  end
  
  def filename
    "_posts/#{date.strftime('%Y-%m-%d')}-#{slug}.html"
  end
  
  def slug
    self["link"].split('/').last
  end
  
  def body
    self.content.content
  end
end

task :pull do
  posts = MultiJson.decode(open("http://pipes.yahoo.com/pipes/pipe.run?_id=50f63f64c70a2a032bdaa5dbb3458224&_render=json").read)['value']['items'].map{|p| Post.new(p) }
  
  posts.each do |p|
    if File.exists?(p.filename)
      puts "- Blog post at #{p.filename} exists, ignoring"
    else
      puts "- Creating blog post at #{p.filename}"
      File.open(p.filename,'w') do |f|
        f.write <<-YAML
---
layout: post
title: "#{p.title}"
---

#{p.body}
YAML
      end
    end
  end
end

Version data entries

13 entries across 7 versions & 1 rubygems

Version Path
mkblog-0.0.7 templates/Rakefile
mkblog-0.0.6 templates/_site/Rakefile
mkblog-0.0.6 templates/Rakefile
mkblog-0.0.5 templates/Rakefile
mkblog-0.0.5 templates/_site/Rakefile
mkblog-0.0.4 templates/Rakefile
mkblog-0.0.4 templates/_site/Rakefile
mkblog-0.0.3 templates/_site/Rakefile
mkblog-0.0.3 templates/Rakefile
mkblog-0.0.2 templates/_site/Rakefile
mkblog-0.0.2 templates/Rakefile
mkblog-0.0.1 templates/_site/Rakefile
mkblog-0.0.1 templates/Rakefile