tumblr-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ {"meta":{"status":301,"msg":"Found"},"response":{"avatar_url":"http:\/\/30.media.tumblr.com\/avatar_61d09ab16eb4_16.png"}}
@@ -0,0 +1,19 @@
1
+ {
2
+ "meta": {
3
+ "status": 200,
4
+ "msg": "OK"
5
+ },
6
+ "response": {
7
+ "blog": {
8
+ "title": "David's Log",
9
+ "posts": 3456,
10
+ "name": "david",
11
+ "url": "http:\/\/david.tumblr.com\/",
12
+ "updated": 1308953007,
13
+ "description": "<p><strong>Mr. Karp<\/strong> is tall and skinny, with unflinching blue eyes a mop of brown hair.\r\n He speaks incredibly fast and in complete paragraphs.</p>",
14
+ "ask": true,
15
+ "ask_anon": false,
16
+ "likes": 12345
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "meta": {
3
+ "status": 200,
4
+ "msg": "OK"
5
+ },
6
+ "response": {
7
+ "posts": [
8
+ {
9
+ "blog_name": "blog1",
10
+ "id": 123,
11
+ "post_url": "http:\/\/links.blog1.com\/post\/123"
12
+ },
13
+ {
14
+ "blog_name": "blog2",
15
+ "id": 456,
16
+ "post_url": "http:\/\/links.blog2.com\/post\/456"
17
+ }
18
+ ]
19
+ }
20
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "meta": {
3
+ "status": 200,
4
+ "msg": "OK"
5
+ },
6
+ "response": {
7
+ "total_users": 2684,
8
+ "users": [
9
+ {
10
+ "name": "david",
11
+ "url": "http:\/\/www.davidslog.com",
12
+ "updated": 1308781073
13
+ },
14
+ {
15
+ "name": "ben",
16
+ "url": "http:\/\/bengold.tv",
17
+ "updated": 1308841333
18
+ }
19
+ ]
20
+ }
21
+ }
22
+
23
+
@@ -0,0 +1,21 @@
1
+ {
2
+ "meta": {
3
+ "status": 200,
4
+ "msg": "OK"
5
+ },
6
+ "response": {
7
+ "total_blogs": 2,
8
+ "blogs": [
9
+ {
10
+ "name": "david",
11
+ "url": "http:\/\/www.davidslog.com",
12
+ "updated": 1308781073
13
+ },
14
+ {
15
+ "name": "matthew",
16
+ "url": "http:\/\/matthew.tumblr.com",
17
+ "updated": 1306436424
18
+ }
19
+ ]
20
+ }
21
+ }
Binary file
@@ -0,0 +1,40 @@
1
+ {
2
+ "meta": {
3
+ "status": 200,
4
+ "msg": "OK"
5
+ },
6
+ "response": {
7
+ "liked_post": [
8
+ {
9
+ "blog_name": "blog1",
10
+ "id": 3507845453,
11
+ "post_url": "http:\/\/blog1.tumblr.com\/post\/3507845453",
12
+ "type": "text",
13
+ "date": "2011-02-25 20:27:00 GMT",
14
+ "timestamp": 1298665620,
15
+ "format": "html",
16
+ "reblog_key": "b0baQtsl",
17
+ "tags": ["tumblrize","milky dog","mini comic"],
18
+ "note_count": 14,
19
+ "title": "Milky Dog",
20
+ "body": "Text"
21
+ },
22
+ {
23
+ "blog_name": "blog2",
24
+ "id": 3507845453,
25
+ "post_url": "http:\/\/blog2.tumblr.com\/post\/3507845453",
26
+ "type": "text",
27
+ "date": "2011-02-25 20:27:00 GMT",
28
+ "timestamp": 1298665620,
29
+ "format": "html",
30
+ "reblog_key": "b0baQtsl",
31
+ "tags": ["tumblrize","milky dog","mini comic"],
32
+ "note_count": 14,
33
+ "title": "Milky Dog",
34
+ "body": "Text"
35
+ }
36
+
37
+ ],
38
+ "liked_count": 2
39
+ }
40
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "meta": {
3
+ "status": 200,
4
+ "msg": "OK"
5
+ },
6
+ "response": {
7
+ "blog": {
8
+ "title": "David's Log",
9
+ "posts": 3456,
10
+ "name": "david",
11
+ "url": "http:\/\/david.tumblr.com\/",
12
+ "updated": 1308953007,
13
+ "description": "<p><strong>Mr. Karp<\/strong> is tall and skinny, with unflinching blue eyes a mop of brown hair.\r\n He speaks incredibly fast and in complete paragraphs.</p>",
14
+ "ask": true,
15
+ "ask_anon": false,
16
+ "likes": 12345
17
+ },
18
+ "posts": [
19
+ {
20
+ "blog_name": "citriccomics",
21
+ "id": 3507845453,
22
+ "post_url": "http:\/\/citriccomics.tumblr.com\/post\/3507845453",
23
+ "type": "text",
24
+ "date": "2011-02-25 20:27:00 GMT",
25
+ "timestamp": 1298665620,
26
+ "format": "html",
27
+ "reblog_key": "b0baQtsl",
28
+ "tags": ["tumblrize","milky dog","mini comic"],
29
+ "note_count": 14,
30
+ "title": "Milky Dog",
31
+ "body": "Text"
32
+ },
33
+ {
34
+ "blog_name": "citriccomics",
35
+ "id": 3507845453,
36
+ "post_url": "http:\/\/citriccomics.tumblr.com\/post\/3507845453",
37
+ "type": "text",
38
+ "date": "2011-02-25 20:27:00 GMT",
39
+ "timestamp": 1298665620,
40
+ "format": "html",
41
+ "reblog_key": "b0baQtsl",
42
+ "tags": ["tumblrize","milky dog","mini comic"],
43
+ "note_count": 14,
44
+ "title": "Milky Dog",
45
+ "body": "Text"
46
+ }
47
+
48
+ ],
49
+ "total_posts": 2
50
+ }
51
+ }
Binary file
Binary file
@@ -0,0 +1,28 @@
1
+ {
2
+ "meta": {
3
+ "status": 200,
4
+ "msg": "OK"
5
+ },
6
+ "response": {
7
+ "user": {
8
+ "following": 263,
9
+ "default_post_format": "html",
10
+ "name": "derekg",
11
+ "likes": 606,
12
+ "blogs": [
13
+ {
14
+ "name": "derekg",
15
+ "title": "Derek Gottfrid",
16
+ "url": "http://derekg.org/",
17
+ "tweet": "auto",
18
+ "primary": true,
19
+ "followers": 33004929
20
+ },
21
+ {
22
+ "name": "ihatehipstrz",
23
+ "title": "I Hate Hipstrz"
24
+ }
25
+ ]
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,23 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'tumblr'
4
+ require 'rspec'
5
+ require 'webmock/rspec'
6
+
7
+ CONSUMER_KEY = 'consumer_key'
8
+ CONSUMER_SECRET = 'consumer_secret'
9
+ OAUTH_TOKEN = 'oauth_token'
10
+ OAUTH_TOKEN_SECRET = 'oauth_token_secret'
11
+
12
+ def fixture_path
13
+ File.expand_path("../fixtures", __FILE__)
14
+ end
15
+
16
+ def fixture(file)
17
+ File.new(fixture_path + '/' + file)
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ config.mock_with :mocha
22
+ end
23
+
@@ -0,0 +1,287 @@
1
+ require "spec_helper"
2
+
3
+ describe Tumblr::Client::Blog do
4
+
5
+ let (:client) do
6
+ Tumblr::Client.new do |client|
7
+ client.consumer_key = CONSUMER_KEY
8
+ client.consumer_secret = CONSUMER_SECRET
9
+ client.oauth_token = OAUTH_TOKEN
10
+ client.oauth_token_secret = OAUTH_TOKEN_SECRET
11
+ end
12
+ end
13
+
14
+ describe "#info" do
15
+
16
+ before do
17
+ stub_request(:get, /http:\/\/api\.tumblr\.com\/v2\/blog\/test\.tumblr\.com\/info*/).to_return(:status => 200, :body => fixture('blog_info.json'), :headers => {"Content-Type" => "application/json"})
18
+ end
19
+
20
+ context "making request" do
21
+ it "should make request to correct url" do
22
+ client.stubs(:get).returns('')
23
+ client.expects(:get).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/info/}.returns('')
24
+ client.blog_info('test.tumblr.com')
25
+ end
26
+ end
27
+
28
+ context "required params present" do
29
+ subject { client.blog_info('test.tumblr.com') }
30
+ it { should_not be_nil }
31
+ its("response.blog.name"){should eq("david")}
32
+ its("response.blog.title"){should eq("David's Log")}
33
+ end
34
+ end
35
+
36
+ describe "#avatar" do
37
+
38
+ before do
39
+ stub_request(:get, /http:\/\/api\.tumblr\.com\/v2\/blog\/test\.tumblr\.com\/avatar*/).to_return(:status => 301, :body => fixture('avatar.json'),
40
+ :headers => {"Location" => "http://30.media.tumblr.com/avatar_61d09ab16eb4_16.png", "Content-Type" => "application/json"})
41
+ end
42
+
43
+ context "making request" do
44
+ it "should make request to correct url" do
45
+ client.stubs(:get).returns('')
46
+ client.expects(:get).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/avatar/}.returns('')
47
+ client.avatar('test.tumblr.com')
48
+ end
49
+ end
50
+
51
+ context "required params present" do
52
+ subject { client.avatar('test.tumblr.com') }
53
+ it { should_not be_nil }
54
+ its("meta.status"){ should eq(301) }
55
+ its("response.avatar_url"){ should eq("http://30.media.tumblr.com/avatar_61d09ab16eb4_16.png") }
56
+ end
57
+ end
58
+
59
+ describe "#followers" do
60
+
61
+ before do
62
+ stub_request(:get, /http:\/\/api\.tumblr\.com\/v2\/blog\/test\.tumblr\.com\/followers*/).to_return(:status => 200, :body => fixture('followers.json'), :headers => {"Content-Type" => "application/json"})
63
+ end
64
+
65
+ context "making request" do
66
+ it "should make request to correct url" do
67
+ client.stubs(:get).returns('')
68
+ client.expects(:get).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/followers/}.returns('')
69
+ client.followers('test.tumblr.com')
70
+ end
71
+ end
72
+
73
+ context "required params present" do
74
+ subject { client.followers('test.tumblr.com') }
75
+ it { should_not be_nil }
76
+ its("meta.status"){ should eq(200) }
77
+ its("response.users"){ should be_an_instance_of(Array) }
78
+ its("response.users.first.name"){ should eq("david") }
79
+ its("response.users.last.name"){ should eq("ben") }
80
+ end
81
+ end
82
+
83
+ describe "#posts" do
84
+
85
+ before do
86
+ stub_request(:get, /http:\/\/api\.tumblr\.com\/v2\/blog\/test\.tumblr\.com\/posts*/).to_return(:status => 200, :body => fixture('posts.json'), :headers => {"Content-Type" => "application/json"})
87
+ end
88
+
89
+ context "making request" do
90
+ it "should make request to correct url" do
91
+ client.stubs(:get).returns('')
92
+ client.expects(:get).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/posts/}.returns('')
93
+ client.posts('test.tumblr.com')
94
+ end
95
+ end
96
+
97
+ context "required params present" do
98
+ subject { client.posts('test.tumblr.com') }
99
+ it { should_not be_nil }
100
+ its('response.posts.size') { should eq(2)}
101
+ end
102
+ end
103
+
104
+ describe "#queue" do
105
+
106
+ before do
107
+ stub_request(:get, "http://api.tumblr.com/v2/blog/test.tumblr.com/posts/queue").to_return(:status => 200, :body => fixture('posts.json'), :headers => {"Content-Type" => "application/json"})
108
+ end
109
+
110
+ context "making request" do
111
+ it "should make request to correct url" do
112
+ client.stubs(:get).returns('')
113
+ client.expects(:get).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/posts\/queue/}.returns('')
114
+ client.queue('test.tumblr.com')
115
+ end
116
+ end
117
+
118
+ context "required params present" do
119
+ subject { client.queue('test.tumblr.com') }
120
+ it { should_not be_nil }
121
+ its('response.posts.size') { should eq(2)}
122
+ end
123
+ end
124
+
125
+ describe "#drafts" do
126
+
127
+ before do
128
+ stub_request(:get, "http://api.tumblr.com/v2/blog/test.tumblr.com/posts/draft").to_return(:status => 200, :body => fixture('posts.json'), :headers => {"Content-Type" => "application/json"})
129
+ end
130
+
131
+ context "making request" do
132
+ it "should make request to correct url" do
133
+ client.stubs(:get).returns('')
134
+ client.expects(:get).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/posts\/draft/}.returns('')
135
+ client.drafts('test.tumblr.com')
136
+ end
137
+ end
138
+
139
+ context "required params present" do
140
+ subject { client.drafts('test.tumblr.com') }
141
+ it { should_not be_nil }
142
+ its('response.posts.size') { should eq(2)}
143
+ end
144
+ end
145
+
146
+ describe "#submissions" do
147
+
148
+ before do
149
+ stub_request(:get, "http://api.tumblr.com/v2/blog/test.tumblr.com/posts/submission").to_return(:status => 200, :body => fixture('posts.json'), :headers => {"Content-Type" => "application/json"})
150
+ end
151
+
152
+ context "making request" do
153
+ it "should make request to correct url" do
154
+ client.stubs(:get).returns('')
155
+ client.expects(:get).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/posts\/submission/}.returns('')
156
+ client.submissions('test.tumblr.com')
157
+ end
158
+ end
159
+
160
+ context "required params present" do
161
+ subject { client.submissions('test.tumblr.com') }
162
+ it { should_not be_nil }
163
+ its('response.posts.size') { should eq(2)}
164
+ end
165
+ end
166
+
167
+ describe "#text" do
168
+
169
+ context "making request" do
170
+ it "should make request to correct url" do
171
+ client.stubs(:post).returns('')
172
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post/}.returns('')
173
+ client.text('test.tumblr.com', "body" => "test")
174
+ end
175
+ end
176
+
177
+ end
178
+
179
+ describe "#photo" do
180
+
181
+ context "making request" do
182
+ it "should make request to correct url" do
183
+ client.stubs(:post).returns('')
184
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post/}.returns('')
185
+ client.photo('test.tumblr.com', "source" => "http://test.com/image.jpg")
186
+ end
187
+ end
188
+
189
+ end
190
+
191
+ describe "#quote" do
192
+
193
+ context "making request" do
194
+ it "should make request to correct url" do
195
+ client.stubs(:post).returns('')
196
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post/}.returns('')
197
+ client.quote('test.tumblr.com', "Test")
198
+ end
199
+ end
200
+ end
201
+
202
+ describe "#link" do
203
+
204
+ context "making request" do
205
+ it "should make request to correct url" do
206
+ client.stubs(:post).returns('')
207
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post/}.returns('')
208
+ client.link('test.tumblr.com', "url" => "Test")
209
+ end
210
+ end
211
+
212
+ end
213
+
214
+ describe "#chat" do
215
+
216
+ context "making request" do
217
+ it "should make request to correct url" do
218
+ client.stubs(:post).returns('')
219
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post/}.returns('')
220
+ client.chat('test.tumblr.com', "conversation" => "Test")
221
+ end
222
+ end
223
+ end
224
+
225
+ describe "#audio" do
226
+
227
+ context "making request" do
228
+ it "should make request to correct url" do
229
+ client.stubs(:post).returns('')
230
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post/}.returns('')
231
+ client.audio('test.tumblr.com', "http://test.com/test.mp3")
232
+ end
233
+ end
234
+
235
+ end
236
+
237
+ describe "#video" do
238
+
239
+ context "making request" do
240
+ it "should make request to correct url" do
241
+ client.stubs(:post).returns('')
242
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post/}.returns('')
243
+ client.video('test.tumblr.com', "embed")
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ describe "#edit" do
250
+
251
+ context "making request" do
252
+ it "should make request to correct url" do
253
+ client.stubs(:post).returns('')
254
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post\/edit/}.returns('')
255
+ client.edit('test.tumblr.com', 123)
256
+ end
257
+ end
258
+
259
+ end
260
+
261
+ describe "#reblog" do
262
+
263
+ context "making request" do
264
+ it "should make request to correct url" do
265
+ client.stubs(:post).returns('')
266
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post\/reblog/}.returns('')
267
+ client.reblog('test.tumblr.com', "123", 456)
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ describe "#delete_post" do
274
+
275
+ context "making request" do
276
+ it "should make request to correct url" do
277
+ client.stubs(:post).returns('')
278
+ client.expects(:post).with{ |url| url =~ /\/blog\/test\.tumblr\.com\/post\/delete/}.returns('')
279
+ client.delete_post('test.tumblr.com', "id" => "456")
280
+ end
281
+ end
282
+
283
+ end
284
+
285
+
286
+
287
+ end