Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Nicer internal API

  • Loading branch information...
commit aa4710ad7d52bfdd37d543c8a5cdec6e61c19374 1 parent 5c62a6f
@mwunsch mwunsch authored
Showing with 11 additions and 9 deletions.
  1. +10 −8 lib/tumblr/reader.rb
  2. +1 −1  test/test_tumblr.rb
View
18 lib/tumblr/reader.rb
@@ -38,13 +38,13 @@ def self.get_posts(response, type = nil)
# Build a Post object from Reader's Post XML
def self.build_post(post)
- tumblr_post = setup_post(post)
- tumblr_post.date = post['date_gmt']
- tumblr_post.format = post['format'].to_sym if post['format']
- tumblr_post.slug = post['slug']
- tumblr_post.tags post['tag'] if post['tag']
- tumblr_post.reblog_key = post['reblog_key'] if post['reblog_key']
- tumblr_post
+ setup_post(post) do |tumblr_post|
+ tumblr_post.date = post['date_gmt']
+ tumblr_post.format = post['format'].to_sym if post['format']
+ tumblr_post.slug = post['slug']
+ tumblr_post.tags post['tag'] if post['tag']
+ tumblr_post.reblog_key = post['reblog_key'] if post['reblog_key']
+ end
end
# Helper method to facilitate standard GET Read and Authenticated Read
@@ -84,7 +84,7 @@ def self.read(username, via = :get, params = {})
def self.setup_post(post)
post_type = post['type'].to_sym
- case post_type
+ tumblr_post = case post_type
when :regular
build_regular(post)
when :photo
@@ -102,6 +102,8 @@ def self.setup_post(post)
else
raise "#{post_type} is not a recognized Tumblr post type."
end
+ yield tumblr_post if block_given?
+ tumblr_post
end
def self.build_regular(post)
View
2  test/test_tumblr.rb
@@ -288,7 +288,7 @@ class TestTumblr < Test::Unit::TestCase
end
end
- describe 'Post' do
+ describe 'Post' do
describe 'Basic' do
test 'has a set of post-specific parameters' do
klass = Class.new(Tumblr::Post)
Please sign in to comment.
Something went wrong with that request. Please try again.