Permalink
Browse files

Adding reblog key as post parameter.

  • Loading branch information...
mwunsch committed Mar 12, 2010
1 parent d3d6a9e commit 5c62a6fa84198684df7ad95a633d7ea0eca0b443
Showing with 14 additions and 5 deletions.
  1. +2 −2 lib/tumblr.rb
  2. +3 −3 lib/tumblr/post.rb
  3. +1 −0 lib/tumblr/reader.rb
  4. +8 −0 test/test_tumblr.rb
View
@@ -129,8 +129,8 @@ def self.create_post(document)
end
def self.basic_setup(post, post_data)
- %w(format state private slug date group generator).each do |basic|
- post.send "#{basic}=".intern, post_data[basic] if post_data[basic]
+ %w(format state private slug date group generator reblog-key).each do |basic|
+ post.send "#{basic}=".gsub('-','_').intern, post_data[basic] if post_data[basic]
end
%w(tags send-to-twitter publish-on).each do |attribute|
post.send attribute.gsub('-','_').intern, post_data[attribute] if post_data[attribute]
View
@@ -3,7 +3,7 @@
class Tumblr
class Post
BASIC_PARAMS = [:date,:tags,:format,:group,:generator,:private,
- :slug,:state,:'send-to-twitter',:'publish-on']
+ :slug,:state,:'send-to-twitter',:'publish-on',:'reblog-key']
POST_PARAMS = [:title,:body,:source,:caption,:'click-through-url',
:quote,:name,:url,:description,:conversation,
:embed,:'externally-hosted-url']
@@ -17,7 +17,7 @@ def self.parameters(*attributes)
end
attr_reader :type, :state, :post_id, :format
- attr_accessor :slug, :date, :group, :generator
+ attr_accessor :slug, :date, :group, :generator, :reblog_key
def initialize(post_id = nil)
@post_id = post_id if post_id
@@ -71,7 +71,7 @@ def publish_on(pubdate=nil)
def to_h
post_hash = {}
basics = [:post_id, :type, :date, :tags, :format, :group, :generator,
- :slug, :state, :send_to_twitter, :publish_on]
+ :slug, :state, :send_to_twitter, :publish_on, :reblog_key]
params = basics.select {|opt| respond_to?(opt) && send(opt) }
params |= self.class.parameters.select {|opt| send(opt) } unless self.class.parameters.blank?
params.each { |key| post_hash[key.to_s.gsub('_','-').to_sym] = send(key) } unless params.empty?
View
@@ -43,6 +43,7 @@ def self.build_post(post)
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
end
View
@@ -230,6 +230,7 @@ class TestTumblr < Test::Unit::TestCase
assert_equal :link, link_post.type
assert_equal :markdown, link_post.format
assert_equal link.first['link_url'], link_post.url
+ assert_equal link.first['reblog_key'], link_post.reblog_key
end
end
@@ -323,6 +324,13 @@ class TestTumblr < Test::Unit::TestCase
assert post.private?
end
+ test 'can have a reblog key' do
+ post = Tumblr::Post.new
+ assert_respond_to post, :reblog_key
+ post.reblog_key = 'reblog_me'
+ assert_equal 'reblog_me', post.reblog_key
+ end
+
test 'has a comma separated list of tags' do
post = Tumblr::Post.new
assert_respond_to post, :tags

0 comments on commit 5c62a6f

Please sign in to comment.