tumblr_client 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +43 -0
- data/bin/tumblr +51 -7
- data/lib/tumblr/blog.rb +8 -6
- data/lib/tumblr/post.rb +1 -1
- data/lib/tumblr/request.rb +12 -9
- data/tumblr.gemspec +2 -1
- metadata +19 -2
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tumblr_client (0.6.8)
|
5
|
+
faraday (>= 0.8)
|
6
|
+
faraday_middleware
|
7
|
+
json
|
8
|
+
oauth
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.3.2)
|
14
|
+
crack (0.3.2)
|
15
|
+
diff-lcs (1.1.3)
|
16
|
+
faraday (0.8.4)
|
17
|
+
multipart-post (~> 1.1)
|
18
|
+
faraday_middleware (0.9.0)
|
19
|
+
faraday (>= 0.7.4, < 0.9)
|
20
|
+
json (1.7.6)
|
21
|
+
multipart-post (1.1.5)
|
22
|
+
oauth (0.4.7)
|
23
|
+
rake (10.0.3)
|
24
|
+
rspec (2.12.0)
|
25
|
+
rspec-core (~> 2.12.0)
|
26
|
+
rspec-expectations (~> 2.12.0)
|
27
|
+
rspec-mocks (~> 2.12.0)
|
28
|
+
rspec-core (2.12.2)
|
29
|
+
rspec-expectations (2.12.1)
|
30
|
+
diff-lcs (~> 1.1.3)
|
31
|
+
rspec-mocks (2.12.1)
|
32
|
+
webmock (1.9.0)
|
33
|
+
addressable (>= 2.2.7)
|
34
|
+
crack (>= 0.1.7)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
rake
|
41
|
+
rspec
|
42
|
+
tumblr_client!
|
43
|
+
webmock
|
data/bin/tumblr
CHANGED
@@ -2,21 +2,65 @@
|
|
2
2
|
$:.unshift File.join File.dirname(__FILE__), '..', 'lib'
|
3
3
|
require 'rubygems'
|
4
4
|
require 'tumblr_client'
|
5
|
+
require 'oauth'
|
5
6
|
require 'yaml'
|
6
7
|
require 'irb'
|
7
8
|
require 'irb/completion'
|
8
9
|
|
9
|
-
|
10
|
+
path = File.join ENV['HOME'], '.tumblr'
|
10
11
|
|
11
|
-
|
12
|
+
if File.exist?(path)
|
13
|
+
|
14
|
+
# Load configuration from data
|
15
|
+
configuration = YAML.load_file path
|
16
|
+
Tumblr.configure do |config|
|
17
|
+
Tumblr::Config::VALID_OPTIONS_KEYS.each do |key|
|
18
|
+
config.send(:"#{key}=", configuration[key.to_s])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
else
|
23
|
+
|
24
|
+
Tumblr.configure do |config|
|
25
|
+
|
26
|
+
puts "Register an application at: http://www.tumblr.com/oauth/apps"
|
27
|
+
print 'OAuth Consumer key: '
|
28
|
+
config.consumer_key = gets.chomp
|
29
|
+
|
30
|
+
print 'OAuth Consumer secret: '
|
31
|
+
config.consumer_secret = gets.chomp
|
32
|
+
|
33
|
+
site = 'http://www.tumblr.com'
|
34
|
+
consumer = OAuth::Consumer.new(config.consumer_key, config.consumer_secret, :site => site)
|
35
|
+
request_token = consumer.get_request_token
|
36
|
+
|
37
|
+
puts
|
38
|
+
|
39
|
+
puts request_token.authorize_url
|
40
|
+
puts "Post-redirect, copy the oauth_verifier"
|
41
|
+
print 'OAuth Verifier: '
|
42
|
+
verifier = gets.chomp
|
43
|
+
|
44
|
+
access_token = request_token.get_access_token :oauth_verifier => verifier
|
45
|
+
config.oauth_token = access_token.token
|
46
|
+
config.oauth_token_secret = access_token.secret
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# Save credentials
|
51
|
+
File.open(path, 'w') do |f|
|
52
|
+
configuration = {}
|
53
|
+
Tumblr::Config::VALID_OPTIONS_KEYS.each do |key|
|
54
|
+
configuration[key.to_s] = Tumblr.send(key)
|
55
|
+
end
|
56
|
+
f.write YAML.dump configuration
|
57
|
+
end
|
12
58
|
|
13
|
-
Tumblr.configure do |config|
|
14
|
-
config.consumer_key = configuration["consumer_key"]
|
15
|
-
config.consumer_secret = configuration["consumer_secret"]
|
16
|
-
config.oauth_token = configuration["oauth_token"]
|
17
|
-
config.oauth_token_secret = configuration["oauth_token_secret"]
|
18
59
|
end
|
19
60
|
|
61
|
+
|
62
|
+
ENV['IRBRC'] = '.irbrc' if File.exists? '.irbrc'
|
63
|
+
|
20
64
|
puts %q[
|
21
65
|
. .o8 oooo
|
22
66
|
.o8 "888 `888
|
data/lib/tumblr/blog.rb
CHANGED
@@ -9,15 +9,17 @@ module Tumblr
|
|
9
9
|
def blog_info(blog_name)
|
10
10
|
get("v2/blog/#{blog_name}/info", {:api_key => Tumblr::consumer_key})
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
#
|
14
|
-
#Gets the avatar of specified size
|
15
|
-
#Defaults to 64
|
14
|
+
# Gets the avatar URL of specified size
|
16
15
|
#
|
17
|
-
def avatar(blog_name, size=
|
18
|
-
|
16
|
+
def avatar(blog_name, size = nil)
|
17
|
+
response = get_response("v2/blog/#{blog_name}/avatar", :size => size)
|
18
|
+
if response.status == 301
|
19
|
+
response.headers['Location']
|
20
|
+
end
|
19
21
|
end
|
20
|
-
|
22
|
+
|
21
23
|
#
|
22
24
|
# Gets the list of followers for the blog
|
23
25
|
#
|
data/lib/tumblr/post.rb
CHANGED
@@ -2,7 +2,7 @@ module Tumblr
|
|
2
2
|
class Client
|
3
3
|
module Post
|
4
4
|
|
5
|
-
@@standard_post_options = [:state, :tags, :tweet, :date, :markdown, :slug]
|
5
|
+
@@standard_post_options = [:state, :tags, :tweet, :date, :markdown, :slug, :format]
|
6
6
|
|
7
7
|
def edit(blog_name, options={})
|
8
8
|
post("v2/blog/#{blog_name}/post/edit", options)
|
data/lib/tumblr/request.rb
CHANGED
@@ -3,17 +3,20 @@ require 'json'
|
|
3
3
|
module Tumblr
|
4
4
|
module Request
|
5
5
|
|
6
|
-
#
|
7
|
-
def
|
8
|
-
|
9
|
-
req.url path
|
6
|
+
# Perform a get request and return the raw response
|
7
|
+
def get_response(path, params = {})
|
8
|
+
connection.get do |req|
|
9
|
+
req.url path
|
10
10
|
req.params = params
|
11
11
|
end
|
12
|
-
#Check for errors and encapsulate
|
13
|
-
respond(response)
|
14
12
|
end
|
15
|
-
|
16
|
-
#Performs
|
13
|
+
|
14
|
+
# Performs a get request
|
15
|
+
def get(path, params={})
|
16
|
+
respond get_response(path, params)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Performs post request
|
17
20
|
def post(path, params={})
|
18
21
|
response = connection.post do |req|
|
19
22
|
req.url path
|
@@ -30,6 +33,6 @@ module Tumblr
|
|
30
33
|
response.body['meta']
|
31
34
|
end
|
32
35
|
end
|
33
|
-
|
36
|
+
|
34
37
|
end
|
35
38
|
end
|
data/tumblr.gemspec
CHANGED
@@ -4,6 +4,7 @@ Gem::Specification.new do |gem|
|
|
4
4
|
gem.add_dependency 'faraday', '>= 0.8'
|
5
5
|
gem.add_dependency 'faraday_middleware'
|
6
6
|
gem.add_dependency 'json'
|
7
|
+
gem.add_dependency 'oauth'
|
7
8
|
gem.add_development_dependency 'rake'
|
8
9
|
gem.add_development_dependency 'rspec'
|
9
10
|
gem.add_development_dependency 'webmock'
|
@@ -18,5 +19,5 @@ Gem::Specification.new do |gem|
|
|
18
19
|
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
|
19
20
|
gem.summary = %q{Tumblr API wrapper}
|
20
21
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
-
gem.version = "0.6.
|
22
|
+
gem.version = "0.6.9"
|
22
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tumblr_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: oauth
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: rake
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +134,7 @@ files:
|
|
118
134
|
- .gitignore
|
119
135
|
- .path
|
120
136
|
- Gemfile
|
137
|
+
- Gemfile.lock
|
121
138
|
- LICENSE.md
|
122
139
|
- README.md
|
123
140
|
- Rakefile
|