Skip to content

Commit

Permalink
Adding files and getting ready for testing. I know. Not TDD :(
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjester committed Jan 21, 2012
1 parent f4ba155 commit 049895f
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "http://rubygems.org"

gemspec
File renamed without changes.
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env rake

require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :test => :spec
task :default => :spec
6 changes: 3 additions & 3 deletions lib/tumblr/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def blog_info(blog_name)
#Defaults to 64
#
def avatar(blog_name, size=64)
avatar = get("v2/blog/#{blog_name}/avatar",{})
avatar = get("v2/blog/#{blog_name}/avatar", {:size => size})
end

#
# Gets the list of followers for the blog
#
def followers(blog_name)
followers = get("v2/blog/#{blog_name}/followers", {})
def followers(blog_name, options={})
followers = get("v2/blog/#{blog_name}/followers", options)
end

def posts(blog_name, type=false, options={})
Expand Down
9 changes: 8 additions & 1 deletion lib/tumblr/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ def delete(blog_name, id)
post("v2/blog/#{blog_name}/post/delete", {:id => id})
end

#TODO Decide if you want people to just pass in a filename
def photo(blog_name, options={})
options[:type] = "photo"
if options.has_key?(:data)
options[:data] = File.open(options[:data],'rb').read()
end
post("v2/blog/#{blog_name}/post", options)
end

Expand Down Expand Up @@ -51,6 +53,11 @@ def video(blog_name, options={})
post("v2/blog/#{blog_name}/post", options)
end

def answer(blog_name, options={})
options[:type] = "answer"
post("v2/blog/#{blog_name}/post", options)
end

end
end
end
7 changes: 4 additions & 3 deletions lib/tumblr/request.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'json'
require 'oauth'

module Tumblr
module Request
Expand All @@ -10,7 +9,8 @@ def get(path, params={})
req.url path
req.params = params
end
JSON.parse(response.body)
#check for errors and encapsulate
JSON.parse(response.body)["response"]
end

#Performs post request
Expand All @@ -19,7 +19,8 @@ def post(path, params={})
req.url path
req.body = params unless params.empty?
end
JSON.parse(response.body)
#Check for errors and encapsulate
JSON.parse(response.body)["response"]
end
end
end
1 change: 1 addition & 0 deletions lib/tumblr/request/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def call(env)
end
header = SimpleOAuth::Header.new(env[:method], env[:url], signature_params, @options)
env[:request_headers]["Authorization"] = header.to_s
puts header.to_s
env[:request_headers]["Content-type"] = "application/x-www-form-urlencoded"
env[:request_headers]["Host"] = "api.tumblr.com"
@app.call(env)
Expand Down
8 changes: 4 additions & 4 deletions lib/tumblr/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ def info
info = post("v2/user/info")
end

def dashboard
dash = get("v2/user/dashboard")
def dashboard(params={})
dash = get("v2/user/dashboard", params)
end

def likes
likes = get("v2/user/likes")
end

def following
following = get("v2/user/following")
def following(offset=0, limit=20)
following = get("v2/user/following", {:limit => limit, :offset => offset})
end

def follow(url)
Expand Down
22 changes: 22 additions & 0 deletions tumblr.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# encoding: utf-8

Gem::Specification.new do |gem|
gem.add_dependency 'faraday', '~> 0.7'
gem.add_dependency 'simple_oauth', '~> 0.1'
gem.add_dependency 'json'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'webmock'
gem.authors = ["John Bunting"]
gem.description = %q{A Ruby wrapper for the Tumblr API}
gem.email = ['[email protected]']
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
gem.files = `git ls-files`.split("\n")
gem.homepage = "http://github.com/codingjester/tumblr"
gem.name = "tumblr"
gem.require_libs = ["lib"]
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
gem.summary = %q{Tumblr API wrapper}
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.version = "0.5"
end

0 comments on commit 049895f

Please sign in to comment.