module Tumblargh

require 'action_view/helpers/date_helper'

Constants

VERSION

Attributes

config[RW]

Public Class Methods

render_file(file, blog, options={}) click to toggle source
# File lib/tumblargh.rb, line 20
def render_file(file, blog, options={})
  render(:file, file, blog, options)
end
render_html(string, blog, options={}) click to toggle source
# File lib/tumblargh.rb, line 24
def render_html(string, blog, options={})
  render(:html, string, blog, options)
end

Private Class Methods

create_blog(blog) click to toggle source
# File lib/tumblargh.rb, line 41
def create_blog(blog)
  if blog.is_a? Resource::Blog
    blog
  elsif blog.is_a? Hash
    create_blog_from_hash blog
  elsif File.exists? blog
    json = ActiveSupport::JSON.decode(open(blog).read)
    create_blog_from_hash json
  else
    Resource::Blog.new(blog)
  end
end
create_blog_from_hash(hash) click to toggle source
# File lib/tumblargh.rb, line 54
def create_blog_from_hash(hash)
  hash = hash["response"] if hash.key? "response"
  Resource::Blog.new("#{hash["blog"]["name"]}.tumblr.com", hash)
end
render(setter, theme, blog, options) click to toggle source
# File lib/tumblargh.rb, line 30
def render(setter, theme, blog, options)
  parser = Parser.new
  parser.send("#{setter}=", theme)

  blog = create_blog blog

  options = parser.options.merge(options)

  Renderer::Document.new(parser.tree, blog, options).render
end