tumblr_client 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/LICENSE +202 -0
- data/README.md +23 -8
- data/Rakefile +19 -6
- data/lib/tumblr/blog.rb +8 -8
- data/lib/tumblr/helpers.rb +10 -0
- data/lib/tumblr/post.rb +14 -10
- data/lib/tumblr/version.rb +1 -1
- data/spec/examples/blog_spec.rb +8 -0
- data/spec/examples/post_spec.rb +1 -1
- data/spec/examples/request_spec.rb +95 -0
- data/tumblr_client.gemspec +2 -2
- metadata +143 -122
- data/LICENSE.md +0 -26
data/.travis.yml
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright 2013 Tumblr, Inc.
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
l
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Tumblr Ruby Gem
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/
|
3
|
+
[![Build Status](https://secure.travis-ci.org/tumblr/tumblr_client.png)](http://travis-ci.org/tumblr/tumblr_client)
|
4
4
|
|
5
|
-
This is
|
6
|
-
currently available on the
|
5
|
+
This is the official Ruby wrapper for the Tumblr v2 API. It supports all
|
6
|
+
endpoints currently available on the
|
7
|
+
[Tumblr API](http://www.tumblr.com/docs/en/api/v2).
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -28,7 +29,7 @@ Configuration for the gem is actually pretty easy:
|
|
28
29
|
|
29
30
|
Once you have your configuration squared away it's time to make some requests!
|
30
31
|
|
31
|
-
>> client = Tumblr.new
|
32
|
+
>> client = Tumblr::Client.new
|
32
33
|
|
33
34
|
That's it! You now have a client that can make any request to the Tumblr API.
|
34
35
|
|
@@ -40,10 +41,10 @@ Getting user information:
|
|
40
41
|
|
41
42
|
Getting a specific blog's posts and type:
|
42
43
|
|
43
|
-
#Grabbing a specific blogs posts
|
44
|
+
# Grabbing a specific blogs posts
|
44
45
|
>> client.posts("codingjester.tumblr.com")
|
45
46
|
|
46
|
-
#Grabbing only the last 10 photos off the blog
|
47
|
+
# Grabbing only the last 10 photos off the blog
|
47
48
|
>> client.posts("codingjester.tumblr.com", :type => "photo", :limit => 10)
|
48
49
|
|
49
50
|
|
@@ -85,7 +86,21 @@ console. Then you're all set!
|
|
85
86
|
No request is too small and I encourage everyone to get involved. As you can see, we're sorely lacking in tests! So
|
86
87
|
please if you would like to contribute, let me know and throw me a pull request!
|
87
88
|
|
88
|
-
|
89
89
|
### Requirements
|
90
90
|
|
91
|
-
* Ruby
|
91
|
+
* Ruby 1.9.x or 2.x.x
|
92
|
+
|
93
|
+
---
|
94
|
+
|
95
|
+
Copyright 2013 Tumblr, Inc.
|
96
|
+
|
97
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
98
|
+
use this work except in compliance with the License. You may obtain a copy of
|
99
|
+
the License in the LICENSE file, or at:
|
100
|
+
|
101
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
102
|
+
|
103
|
+
Unless required by applicable law or agreed to in writing, software
|
104
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
105
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
106
|
+
License for the specific language governing permissions and limitations.
|
data/Rakefile
CHANGED
@@ -1,10 +1,23 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
|
3
|
-
require 'bundler'
|
4
|
-
Bundler::GemHelper.install_tasks
|
5
|
-
|
6
3
|
require 'rspec/core/rake_task'
|
7
|
-
|
4
|
+
require File.dirname(__FILE__) + '/lib/tumblr/version'
|
5
|
+
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
task :build => :test do
|
9
|
+
system 'gem build tumblr_client.gemspec'
|
10
|
+
end
|
11
|
+
|
12
|
+
task :release => :build do
|
13
|
+
# tag and push
|
14
|
+
system "git tag v#{Tumblr::VERSION}"
|
15
|
+
system "git push origin --tags"
|
16
|
+
# push the gem
|
17
|
+
system "gem push ice_cube-#{Tumblr::VERSION}.gem"
|
18
|
+
end
|
8
19
|
|
9
|
-
|
10
|
-
|
20
|
+
RSpec::Core::RakeTask.new(:test) do |t|
|
21
|
+
t.pattern = 'spec/**/*_spec.rb'
|
22
|
+
fail_on_error = true # be explicit
|
23
|
+
end
|
data/lib/tumblr/blog.rb
CHANGED
@@ -3,12 +3,12 @@ module Tumblr
|
|
3
3
|
|
4
4
|
# Gets the info about the blog
|
5
5
|
def blog_info(blog_name)
|
6
|
-
get(
|
6
|
+
get(blog_path(blog_name, 'info'), :api_key => @consumer_key)
|
7
7
|
end
|
8
8
|
|
9
9
|
# Gets the avatar URL of specified size
|
10
10
|
def avatar(blog_name, size = nil)
|
11
|
-
url =
|
11
|
+
url = blog_path(blog_name, 'avatar')
|
12
12
|
url = "#{url}/#{size}" if size
|
13
13
|
get_redirect_url(url)
|
14
14
|
end
|
@@ -16,13 +16,13 @@ module Tumblr
|
|
16
16
|
# Gets the list of followers for the blog
|
17
17
|
def followers(blog_name, options = {})
|
18
18
|
validate_options([:limit, :offset], options)
|
19
|
-
get(
|
19
|
+
get(blog_path(blog_name, 'followers'), options)
|
20
20
|
end
|
21
21
|
|
22
22
|
# Gets the list of likes for the blog
|
23
23
|
def blog_likes(blog_name, options = {})
|
24
24
|
validate_options([:limit, :offset], options)
|
25
|
-
url =
|
25
|
+
url = blog_path(blog_name, 'likes')
|
26
26
|
|
27
27
|
params = { :api_key => @consumer_key }
|
28
28
|
params.merge! options
|
@@ -30,7 +30,7 @@ module Tumblr
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def posts(blog_name, options = {})
|
33
|
-
url =
|
33
|
+
url = blog_path(blog_name, 'posts')
|
34
34
|
if options.has_key?(:type)
|
35
35
|
url = "#{url}/#{options[:type]}"
|
36
36
|
end
|
@@ -42,17 +42,17 @@ module Tumblr
|
|
42
42
|
|
43
43
|
def queue(blog_name, options = {})
|
44
44
|
validate_options([:limit, :offset], options)
|
45
|
-
get(
|
45
|
+
get(blog_path(blog_name, 'posts/queue'), options)
|
46
46
|
end
|
47
47
|
|
48
48
|
def draft(blog_name, options = {})
|
49
49
|
validate_options([:limit, :offset], options)
|
50
|
-
get(
|
50
|
+
get(blog_path(blog_name, 'posts/draft'), options)
|
51
51
|
end
|
52
52
|
|
53
53
|
def submissions(blog_name, options = {})
|
54
54
|
validate_options([:limit, :offset], options)
|
55
|
-
get(
|
55
|
+
get(blog_path(blog_name, 'posts/submission'), options)
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
data/lib/tumblr/helpers.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
module Tumblr
|
2
2
|
module Helper
|
3
3
|
|
4
|
+
private
|
5
|
+
|
6
|
+
def blog_path(blog_name, ext)
|
7
|
+
"v2/blog/#{full_blog_name(blog_name)}/#{ext}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def full_blog_name(blog_name)
|
11
|
+
blog_name.include?('.') ? blog_name : "#{blog_name}.tumblr.com"
|
12
|
+
end
|
13
|
+
|
4
14
|
def validate_options(valid_opts, opts)
|
5
15
|
bad_opts = opts.select { |val| !valid_opts.include?(val) }
|
6
16
|
if bad_opts.any?
|
data/lib/tumblr/post.rb
CHANGED
@@ -4,15 +4,15 @@ module Tumblr
|
|
4
4
|
STANDARD_POST_OPTIONS = [:state, :tags, :tweet, :date, :markdown, :slug, :format]
|
5
5
|
|
6
6
|
def edit(blog_name, options = {})
|
7
|
-
post(
|
7
|
+
post(blog_path(blog_name, 'post/edit'), options)
|
8
8
|
end
|
9
9
|
|
10
10
|
def reblog(blog_name, options = {})
|
11
|
-
post(
|
11
|
+
post(blog_path(blog_name, 'post/reblog'), options)
|
12
12
|
end
|
13
13
|
|
14
14
|
def delete(blog_name, id)
|
15
|
-
post(
|
15
|
+
post(blog_path(blog_name, 'post/delete'), :id => id)
|
16
16
|
end
|
17
17
|
|
18
18
|
def photo(blog_name, options = {})
|
@@ -30,7 +30,7 @@ module Tumblr
|
|
30
30
|
|
31
31
|
options[:type] = 'photo'
|
32
32
|
extract_data!(options)
|
33
|
-
post(
|
33
|
+
post(post_path(blog_name), options)
|
34
34
|
end
|
35
35
|
|
36
36
|
def quote(blog_name, options = {})
|
@@ -38,7 +38,7 @@ module Tumblr
|
|
38
38
|
validate_options(valid_opts, options)
|
39
39
|
|
40
40
|
options[:type] = 'quote'
|
41
|
-
post(
|
41
|
+
post(post_path(blog_name), options)
|
42
42
|
end
|
43
43
|
|
44
44
|
def text(blog_name, options = {})
|
@@ -46,7 +46,7 @@ module Tumblr
|
|
46
46
|
validate_options(valid_opts, options)
|
47
47
|
|
48
48
|
options[:type] = 'text'
|
49
|
-
post(
|
49
|
+
post(post_path(blog_name), options)
|
50
50
|
end
|
51
51
|
|
52
52
|
def link(blog_name, options = {})
|
@@ -54,7 +54,7 @@ module Tumblr
|
|
54
54
|
validate_options(valid_opts, options)
|
55
55
|
|
56
56
|
options[:type] = 'link'
|
57
|
-
post(
|
57
|
+
post(post_path(blog_name), options)
|
58
58
|
end
|
59
59
|
|
60
60
|
def chat(blog_name, options = {})
|
@@ -62,7 +62,7 @@ module Tumblr
|
|
62
62
|
validate_options(valid_opts, options)
|
63
63
|
|
64
64
|
options[:type] = 'chat'
|
65
|
-
post(
|
65
|
+
post(post_path(blog_name), options)
|
66
66
|
end
|
67
67
|
|
68
68
|
def audio(blog_name, options = {})
|
@@ -72,7 +72,7 @@ module Tumblr
|
|
72
72
|
|
73
73
|
options[:type] = 'audio'
|
74
74
|
extract_data!(options)
|
75
|
-
post(
|
75
|
+
post(post_path(blog_name), options)
|
76
76
|
end
|
77
77
|
|
78
78
|
def video(blog_name, options = {})
|
@@ -82,11 +82,15 @@ module Tumblr
|
|
82
82
|
|
83
83
|
options[:type] = 'video'
|
84
84
|
extract_data!(options)
|
85
|
-
post(
|
85
|
+
post(post_path(blog_name), options)
|
86
86
|
end
|
87
87
|
|
88
88
|
private
|
89
89
|
|
90
|
+
def post_path(blog_name)
|
91
|
+
blog_path(blog_name, 'post')
|
92
|
+
end
|
93
|
+
|
90
94
|
# Look for the various ways that data can be passed, and normalize
|
91
95
|
# the result in this hash
|
92
96
|
def extract_data!(options)
|
data/lib/tumblr/version.rb
CHANGED
data/spec/examples/blog_spec.rb
CHANGED
@@ -18,6 +18,14 @@ describe Tumblr::Blog do
|
|
18
18
|
r.should == 'response'
|
19
19
|
end
|
20
20
|
|
21
|
+
it 'should make the proper request with a short blog name' do
|
22
|
+
client.should_receive(:get).once.with("v2/blog/b.tumblr.com/info", {
|
23
|
+
:api_key => consumer_key
|
24
|
+
}).and_return 'response'
|
25
|
+
r = client.blog_info 'b'
|
26
|
+
r.should == 'response'
|
27
|
+
end
|
28
|
+
|
21
29
|
end
|
22
30
|
|
23
31
|
describe :avatar do
|
data/spec/examples/post_spec.rb
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tumblr::Request do
|
4
|
+
|
5
|
+
let(:client) { Tumblr::Client.new }
|
6
|
+
|
7
|
+
describe :respond do
|
8
|
+
|
9
|
+
[200, 201].each do |rcode|
|
10
|
+
|
11
|
+
context "with a #{rcode} response" do
|
12
|
+
|
13
|
+
it 'should return the meta object' do
|
14
|
+
data = { :message => 'ohyes' }
|
15
|
+
response = OpenStruct.new(:status => rcode, :body => { 'response' => data })
|
16
|
+
client.respond(response).should == data
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with an error response' do
|
24
|
+
|
25
|
+
it 'should return the meta object' do
|
26
|
+
meta = { :message => 'ohno' }
|
27
|
+
response = OpenStruct.new(:status => 401, :body => { 'meta' => meta })
|
28
|
+
client.respond(response).should == meta
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe :get do
|
36
|
+
|
37
|
+
before do
|
38
|
+
@path = '/the/path'
|
39
|
+
@params = { :hello => 'world' }
|
40
|
+
client.should_receive(:get_response).once.with(@path, @params).
|
41
|
+
and_return(OpenStruct.new({
|
42
|
+
:status => 200,
|
43
|
+
:body => { 'response' => 'result' }
|
44
|
+
}))
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should get the response directly' do
|
48
|
+
client.get(@path, @params).should == 'result'
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe :get_redirect_url do
|
54
|
+
|
55
|
+
context 'when redirect is found' do
|
56
|
+
|
57
|
+
before do
|
58
|
+
@path = '/the/path'
|
59
|
+
@params = { :hello => 'world' }
|
60
|
+
@redirect_url = 'redirect-to-here'
|
61
|
+
client.should_receive(:get_response).once.with(@path, @params).
|
62
|
+
and_return(OpenStruct.new({
|
63
|
+
:status => 301,
|
64
|
+
:headers => { 'Location' => @redirect_url }
|
65
|
+
}))
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should return the redirect url' do
|
69
|
+
client.get_redirect_url(@path, @params).should == @redirect_url
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when error is encountered' do
|
75
|
+
|
76
|
+
before do
|
77
|
+
@path = '/the/path'
|
78
|
+
@params = { :hello => 'world' }
|
79
|
+
@meta = { :message => 'ohno' }
|
80
|
+
client.should_receive(:get_response).once.with(@path, @params).
|
81
|
+
and_return(OpenStruct.new({
|
82
|
+
:status => 401,
|
83
|
+
:body => { 'meta' => @meta }
|
84
|
+
}))
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should return the error meta' do
|
88
|
+
client.get_redirect_url(@path, @params).should == @meta
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/tumblr_client.gemspec
CHANGED
@@ -10,9 +10,9 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.add_development_dependency 'rspec'
|
11
11
|
gem.add_development_dependency 'webmock'
|
12
12
|
gem.add_development_dependency 'simplecov'
|
13
|
-
gem.authors = [
|
13
|
+
gem.authors = ['John Bunting', 'John Crepezzi']
|
14
14
|
gem.description = %q{A Ruby wrapper for the Tumblr v2 API}
|
15
|
-
gem.email = ['codingjester@gmail.com']
|
15
|
+
gem.email = ['codingjester@gmail.com', 'john@crepezzi.com']
|
16
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
17
17
|
gem.files = `git ls-files`.split("\n")
|
18
18
|
gem.homepage = "http://github.com/codingjester/tumblr_client"
|
metadata
CHANGED
@@ -1,134 +1,158 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tumblr_client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 7
|
8
|
-
- 0
|
9
|
-
version: 0.7.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.1
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- John Bunting
|
9
|
+
- John Crepezzi
|
13
10
|
autorequire:
|
14
11
|
bindir: bin
|
15
12
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
21
16
|
name: faraday
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
- 8
|
30
|
-
version: "0.8"
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.8'
|
31
23
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: faraday_middleware
|
35
24
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0.8'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: faraday_middleware
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0.8'
|
44
39
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: json
|
48
40
|
prerelease: false
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.8'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: json
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
56
55
|
type: :runtime
|
57
|
-
version_requirements: *id003
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: oauth
|
60
56
|
prerelease: false
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: oauth
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
68
71
|
type: :runtime
|
69
|
-
version_requirements: *id004
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rake
|
72
72
|
prerelease: false
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: rake
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
80
87
|
type: :development
|
81
|
-
version_requirements: *id005
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: rspec
|
84
88
|
prerelease: false
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
92
103
|
type: :development
|
93
|
-
version_requirements: *id006
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: webmock
|
96
104
|
prerelease: false
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
104
119
|
type: :development
|
105
|
-
version_requirements: *id007
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
|
-
name: simplecov
|
108
120
|
prerelease: false
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: simplecov
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
116
135
|
type: :development
|
117
|
-
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
118
143
|
description: A Ruby wrapper for the Tumblr v2 API
|
119
|
-
email:
|
144
|
+
email:
|
120
145
|
- codingjester@gmail.com
|
121
|
-
|
146
|
+
- john@crepezzi.com
|
147
|
+
executables:
|
122
148
|
- tumblr
|
123
149
|
extensions: []
|
124
|
-
|
125
150
|
extra_rdoc_files: []
|
126
|
-
|
127
|
-
files:
|
151
|
+
files:
|
128
152
|
- .gitignore
|
129
153
|
- .travis.yml
|
130
154
|
- Gemfile
|
131
|
-
- LICENSE
|
155
|
+
- LICENSE
|
132
156
|
- README.md
|
133
157
|
- Rakefile
|
134
158
|
- bin/tumblr
|
@@ -147,46 +171,43 @@ files:
|
|
147
171
|
- spec/examples/blog_spec.rb
|
148
172
|
- spec/examples/client_spec.rb
|
149
173
|
- spec/examples/post_spec.rb
|
174
|
+
- spec/examples/request_spec.rb
|
150
175
|
- spec/examples/tagged_spec.rb
|
151
176
|
- spec/examples/user_spec.rb
|
152
177
|
- spec/spec_helper.rb
|
153
178
|
- tumblr_client.gemspec
|
154
|
-
has_rdoc: true
|
155
179
|
homepage: http://github.com/codingjester/tumblr_client
|
156
180
|
licenses: []
|
157
|
-
|
158
181
|
post_install_message:
|
159
182
|
rdoc_options: []
|
160
|
-
|
161
|
-
require_paths:
|
183
|
+
require_paths:
|
162
184
|
- lib
|
163
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
187
|
+
requirements:
|
188
|
+
- - ! '>='
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
segments:
|
168
192
|
- 0
|
169
|
-
|
170
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
- 1
|
176
|
-
- 3
|
177
|
-
- 6
|
193
|
+
hash: -1559546719117937655
|
194
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
|
+
none: false
|
196
|
+
requirements:
|
197
|
+
- - ! '>='
|
198
|
+
- !ruby/object:Gem::Version
|
178
199
|
version: 1.3.6
|
179
200
|
requirements: []
|
180
|
-
|
181
201
|
rubyforge_project:
|
182
|
-
rubygems_version: 1.
|
202
|
+
rubygems_version: 1.8.25
|
183
203
|
signing_key:
|
184
204
|
specification_version: 3
|
185
205
|
summary: Tumblr API wrapper
|
186
|
-
test_files:
|
206
|
+
test_files:
|
187
207
|
- spec/examples/blog_spec.rb
|
188
208
|
- spec/examples/client_spec.rb
|
189
209
|
- spec/examples/post_spec.rb
|
210
|
+
- spec/examples/request_spec.rb
|
190
211
|
- spec/examples/tagged_spec.rb
|
191
212
|
- spec/examples/user_spec.rb
|
192
213
|
- spec/spec_helper.rb
|
data/LICENSE.md
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
Copyright (c) 2012, John Bunting, Tumblr, Inc.
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
6
|
-
|
7
|
-
* Redistributions of source code must retain the above copyright notice,
|
8
|
-
this list of conditions and the following disclaimer.
|
9
|
-
* Redistributions in binary form must reproduce the above copyright
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
11
|
-
documentation and/or other materials provided with the distribution.
|
12
|
-
* Neither the name of Tumblr, Inc. nor the names of its contributors may
|
13
|
-
be used to endorse or promote products derived from this software without
|
14
|
-
specific prior written permission.
|
15
|
-
* This license can change at any time.
|
16
|
-
|
17
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|