tumblr4r 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/ChangeLog +4 -0
  2. data/lib/tumblr4r.rb +7 -2
  3. data/test/tumblr4r_test.rb +37 -13
  4. metadata +2 -2
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.7.2 / 2009-10-15
2
+ * new: photoset support added.(Thanks to http://github.com/smajda for the patch.)
3
+
4
+
1
5
  == 0.7.1 / 2009-09-11
2
6
  * fix: missing Site#delete
3
7
  * fix: the number of the records is wrong when finding with :limit and :offset options.
data/lib/tumblr4r.rb CHANGED
@@ -5,7 +5,7 @@ require 'active_support'
5
5
  require 'logger'
6
6
  require 'cgi'
7
7
  module Tumblr4r
8
- VERSION = '0.7.1'
8
+ VERSION = '0.7.2'
9
9
  class TumblrError < StandardError
10
10
  end
11
11
 
@@ -207,7 +207,7 @@ module Tumblr4r
207
207
  end
208
208
 
209
209
  class Photo < Post
210
- attr_accessor :photo_caption, :photo_link_url, :photo_url
210
+ attr_accessor :photo_caption, :photo_link_url, :photo_url, :photoset
211
211
  #TODO: photo_url の max-width って何?
212
212
  attr_accessor :data
213
213
 
@@ -219,6 +219,7 @@ module Tumblr4r
219
219
  {"source" => @photo_url,
220
220
  "caption" => @photo_caption,
221
221
  "click-through-url" => @photo_link_url,
222
+ "photoset" => @photoset,
222
223
  "data" => @data})
223
224
  end
224
225
  end
@@ -469,6 +470,10 @@ module Tumblr4r
469
470
  post.photo_caption = rexml_post.elements["photo-caption"].try(:text) || ""
470
471
  post.photo_link_url = rexml_post.elements["photo-link-url"].try(:text) || ""
471
472
  post.photo_url = rexml_post.elements["photo-url"].try(:text) || ""
473
+ post.photoset = []
474
+ rexml_post.elements.each("photoset/photo") do |photo|
475
+ post.photoset.push(photo.elements["photo-url"].try(:text) || "")
476
+ end
472
477
  post
473
478
  end
474
479
 
@@ -54,8 +54,8 @@ class Tumblr4rTest < Test::Unit::TestCase
54
54
 
55
55
  def test_find
56
56
  posts = @site.find(:all)
57
- assert_equal 8, posts.size
58
- assert_equal Video, posts[0].class
57
+ assert_equal 9, posts.size
58
+ assert_equal Photo, posts[0].class
59
59
  end
60
60
 
61
61
  def test_find_all
@@ -149,22 +149,46 @@ EOF
149
149
 
150
150
  def test_find_with_type_photo
151
151
  posts = @site.find(:all, :type => "photo")
152
- assert_equal 1, posts.size
152
+ assert_equal 2, posts.size
153
+
154
+ # normal
155
+ assert_equal Photo, posts[1].class
156
+ assert_equal 123461063, posts[1].post_id
157
+ assert_equal "http://tumblr4rtest.tumblr.com/post/123461063", posts[1].url
158
+ assert_equal "http://tumblr4rtest.tumblr.com/post/123461063/photo", posts[1].url_with_slug
159
+ assert_equal "photo", posts[1].type
160
+ assert_equal "2009-06-14 16:34:50 GMT", posts[1].date_gmt
161
+ assert_equal "Mon, 15 Jun 2009 01:34:50", posts[1].date
162
+ assert_equal 1244997290, posts[1].unix_timestamp
163
+ assert_equal "html", posts[1].format
164
+ assert_equal ["test", "photo"], posts[1].tags
165
+ assert_equal false, posts[1].bookmarklet
166
+
167
+ assert_equal "<p>Photoのテストです。</p>\n\n<p>ギコです。</p>", posts[1].photo_caption
168
+ assert_equal "http://www.google.co.jp/", posts[1].photo_link_url
169
+ assert_equal "http://5.media.tumblr.com/GyEYZujUYopiula4XKmXhCgmo1_250.jpg", posts[1].photo_url
170
+ assert_equal [], posts[1].photoset
171
+
172
+ # photoset
153
173
  assert_equal Photo, posts[0].class
154
- assert_equal 123461063, posts[0].post_id
155
- assert_equal "http://tumblr4rtest.tumblr.com/post/123461063", posts[0].url
156
- assert_equal "http://tumblr4rtest.tumblr.com/post/123461063/photo", posts[0].url_with_slug
174
+ assert_equal 211868268, posts[0].post_id
175
+ assert_equal "http://tumblr4rtest.tumblr.com/post/211868268", posts[0].url
176
+ assert_equal "http://tumblr4rtest.tumblr.com/post/211868268/photoset-test", posts[0].url_with_slug
157
177
  assert_equal "photo", posts[0].type
158
- assert_equal "2009-06-14 16:34:50 GMT", posts[0].date_gmt
159
- assert_equal "Mon, 15 Jun 2009 01:34:50", posts[0].date
160
- assert_equal 1244997290, posts[0].unix_timestamp
178
+ assert_equal "2009-10-13 10:19:04 GMT", posts[0].date_gmt
179
+ assert_equal "Tue, 13 Oct 2009 19:19:04", posts[0].date
180
+ assert_equal 1255429144, posts[0].unix_timestamp
161
181
  assert_equal "html", posts[0].format
162
- assert_equal ["test", "photo"], posts[0].tags
182
+ assert_equal [], posts[0].tags
163
183
  assert_equal false, posts[0].bookmarklet
164
184
 
165
- assert_equal "<p>Photoのテストです。</p>\n\n<p>ギコです。</p>", posts[0].photo_caption
166
- assert_equal "http://www.google.co.jp/", posts[0].photo_link_url
167
- assert_equal "http://5.media.tumblr.com/GyEYZujUYopiula4XKmXhCgmo1_250.jpg", posts[0].photo_url
185
+ assert_equal "Photoset test.", posts[0].photo_caption
186
+ assert_equal "", posts[0].photo_link_url
187
+ assert_equal "http://22.media.tumblr.com/tumblr_krg7btBOD21qzfaavo1_250.jpg", posts[0].photo_url
188
+ assert_equal ["http://22.media.tumblr.com/tumblr_krg7btBOD21qzfaavo1_250.jpg",
189
+ "http://6.media.tumblr.com/tumblr_krg7btBOD21qzfaavo2_500.jpg",
190
+ "http://16.media.tumblr.com/tumblr_krg7btBOD21qzfaavo3_500.png"], posts[0].photoset
191
+
168
192
  end
169
193
 
170
194
  def test_find_with_type_quote
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tumblr4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoki MAEDA
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-12 00:00:00 +09:00
12
+ date: 2009-10-15 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency