module Tumblargh::API

Constants

API_ROOT

Attributes

api_key[RW]
set_api_key[RW]

Public Class Methods

blog(domain) click to toggle source
# File lib/tumblargh/api.rb, line 30
def blog(domain)
  fetch("#{domain}/info")['blog']
end
disable!() click to toggle source
# File lib/tumblargh/api.rb, line 48
def disable!
  @enabled = false
end
enable!() click to toggle source
# File lib/tumblargh/api.rb, line 44
def enable!
  @enabled = true
end
enabled?() click to toggle source
# File lib/tumblargh/api.rb, line 52
def enabled?
  @enabled
end
fetch(path, query={}) click to toggle source
# File lib/tumblargh/api.rb, line 21
def fetch(path, query={})
  raise "API is disabled" unless enabled?

  query = query.merge(:api_key => api_key).to_query
  url = "#{API_ROOT}#{path}?#{query}"
  resp = APICache.get(url) { open(url).read }
  ActiveSupport::JSON.decode(resp)['response']
end
notes(domain, query) click to toggle source
# File lib/tumblargh/api.rb, line 38
def notes(domain, query)
  query.merge!(:notes_info => 'true')
  fetch("#{domain}/posts", query)['posts'][0]['notes']
end
posts(domain, query={}) click to toggle source
# File lib/tumblargh/api.rb, line 34
def posts(domain, query={})
  fetch("#{domain}/posts")['posts']
end