tumblr4r 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/lib/tumblr4r.rb +7 -2
- data/test/tumblr4r_test.rb +37 -13
- metadata +2 -2
data/ChangeLog
CHANGED
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.
|
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
|
|
data/test/tumblr4r_test.rb
CHANGED
@@ -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
|
58
|
-
assert_equal
|
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
|
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
|
155
|
-
assert_equal "http://tumblr4rtest.tumblr.com/post/
|
156
|
-
assert_equal "http://tumblr4rtest.tumblr.com/post/
|
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-
|
159
|
-
assert_equal "
|
160
|
-
assert_equal
|
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 [
|
182
|
+
assert_equal [], posts[0].tags
|
163
183
|
assert_equal false, posts[0].bookmarklet
|
164
184
|
|
165
|
-
assert_equal "
|
166
|
-
assert_equal "
|
167
|
-
assert_equal "http://
|
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.
|
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-
|
12
|
+
date: 2009-10-15 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|