tumblr_client 0.6.9 → 0.6.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module Tumblr
7
7
  #Gets the info about the blog
8
8
  #
9
9
  def blog_info(blog_name)
10
- get("v2/blog/#{blog_name}/info", {:api_key => Tumblr::consumer_key})
10
+ get("v2/blog/#{blog_name}/info", {:api_key => @consumer_key})
11
11
  end
12
12
 
13
13
  #
@@ -35,7 +35,7 @@ module Tumblr
35
35
  def blog_likes(blog_name, options={})
36
36
  if valid_options([:limit, :offset], options)
37
37
  url = "v2/blog/#{blog_name}/likes"
38
- params = {:api_key => Tumblr::consumer_key}
38
+ params = {:api_key => @consumer_key}
39
39
  unless options.empty?
40
40
  params.merge!(options)
41
41
  end
@@ -50,7 +50,7 @@ module Tumblr
50
50
  url = "#{url}/#{options[:type]}"
51
51
  end
52
52
 
53
- params = {:api_key => Tumblr::consumer_key}
53
+ params = {:api_key => @consumer_key}
54
54
  unless options.empty?
55
55
  params.merge!(options)
56
56
  end
@@ -22,5 +22,18 @@ module Tumblr
22
22
  instance_variable_set("@#{key}".to_sym, attrs[key])
23
23
  end
24
24
  end
25
+
26
+ def api_host
27
+ ENV['TUMBLR_API_HOST'] || 'api.tumblr.com'
28
+ end
29
+
30
+ def credentials
31
+ {
32
+ :consumer_key => @consumer_key,
33
+ :consumer_secret => @consumer_secret,
34
+ :token => @oauth_token,
35
+ :token_secret => @oauth_token_secret
36
+ }
37
+ end
25
38
  end
26
39
  end
@@ -10,10 +10,11 @@ module Tumblr
10
10
  :accept => "application/json",
11
11
  :user_agent => "Tumblr v1.0"
12
12
  },
13
- :url => "http://api.tumblr.com/"
13
+ :url => "http://#{api_host}/"
14
14
  }
15
- Faraday.new("http://api.tumblr.com/", default_options.merge(options)) do |builder|
16
- builder.use Tumblr::Request::TumblrOAuth, Tumblr::credentials if not Tumblr::credentials.empty?
15
+ Faraday.new("http://#{api_host}/", default_options.merge(options)) do |builder|
16
+ data = { :api_host => api_host }.merge(credentials)
17
+ builder.use Tumblr::Request::TumblrOAuth, data unless credentials.empty?
17
18
  builder.use Faraday::Request::UrlEncoded
18
19
  builder.use FaradayMiddleware::ParseJson, :content_type => "application/json"
19
20
  builder.use Faraday::Adapter::NetHttp
@@ -21,7 +21,7 @@ module Tumblr
21
21
  end
22
22
  env[:request_headers]["Authorization"] = self.oauth_gen(env[:method], url, signature_params)
23
23
  env[:request_headers]["Content-type"] = "application/x-www-form-urlencoded"
24
- env[:request_headers]["Host"] = "api.tumblr.com"
24
+ env[:request_headers]["Host"] = @options[:api_host]
25
25
 
26
26
 
27
27
  @app.call(env)
@@ -33,7 +33,7 @@ module Tumblr
33
33
 
34
34
  def oauth_gen(method, url, params)
35
35
  params[:oauth_consumer_key] = @options[:consumer_key]
36
- params[:oauth_nonce] = Time.now.to_i
36
+ params[:oauth_nonce] = Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')
37
37
  params[:oauth_signature_method] = 'HMAC-SHA1'
38
38
  params[:oauth_timestamp] = Time.now.to_i
39
39
  params[:oauth_token] = @options[:token]
@@ -5,7 +5,7 @@ module Tumblr
5
5
  @@standard_options = [:before, :limit, :filter]
6
6
 
7
7
  def tagged(tag, options={})
8
- params = {:tag => tag, :api_key => Tumblr::consumer_key}
8
+ params = {:tag => tag, :api_key => @consumer_key}
9
9
  unless options.empty?
10
10
  params.merge!(options)
11
11
  end
@@ -1,23 +1,23 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.add_dependency 'faraday', '>= 0.8'
5
- gem.add_dependency 'faraday_middleware'
6
- gem.add_dependency 'json'
7
- gem.add_dependency 'oauth'
8
- gem.add_development_dependency 'rake'
9
- gem.add_development_dependency 'rspec'
10
- gem.add_development_dependency 'webmock'
11
- gem.authors = ["John Bunting"]
12
- gem.description = %q{A Ruby wrapper for the Tumblr v2 API}
13
- gem.email = ['codingjester@gmail.com']
14
- gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
15
- gem.files = `git ls-files`.split("\n")
16
- gem.homepage = "http://github.com/codingjester/tumblr_client"
17
- gem.name = "tumblr_client"
18
- gem.require_paths = ["lib"]
19
- gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
20
- gem.summary = %q{Tumblr API wrapper}
21
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- gem.version = "0.6.9"
4
+ gem.add_dependency 'faraday', '>= 0.8'
5
+ gem.add_dependency 'faraday_middleware'
6
+ gem.add_dependency 'json'
7
+ gem.add_dependency 'oauth'
8
+ gem.add_development_dependency 'rake'
9
+ gem.add_development_dependency 'rspec'
10
+ gem.add_development_dependency 'webmock'
11
+ gem.authors = ["John Bunting"]
12
+ gem.description = %q{A Ruby wrapper for the Tumblr v2 API}
13
+ gem.email = ['codingjester@gmail.com']
14
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.homepage = "http://github.com/codingjester/tumblr_client"
17
+ gem.name = "tumblr_client"
18
+ gem.require_paths = ["lib"]
19
+ gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
20
+ gem.summary = %q{Tumblr API wrapper}
21
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ gem.version = "0.6.11"
23
23
  end
metadata CHANGED
@@ -1,136 +1,117 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tumblr_client
3
- version: !ruby/object:Gem::Version
4
- version: 0.6.9
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 11
9
+ version: 0.6.11
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - John Bunting
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2013-02-02 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: faraday
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0.8'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0.8'
30
- - !ruby/object:Gem::Dependency
31
- name: faraday_middleware
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 8
30
+ version: "0.8"
38
31
  type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday_middleware
39
35
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: json
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
54
43
  type: :runtime
44
+ version_requirements: *id002
45
+ - !ruby/object:Gem::Dependency
46
+ name: json
55
47
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
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'
48
+ requirement: &id003 !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
70
55
  type: :runtime
56
+ version_requirements: *id003
57
+ - !ruby/object:Gem::Dependency
58
+ name: oauth
71
59
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
60
+ requirement: &id004 !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ type: :runtime
68
+ version_requirements: *id004
69
+ - !ruby/object:Gem::Dependency
79
70
  name: rake
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
71
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rspec
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
72
+ requirement: &id005 !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ segments:
77
+ - 0
78
+ version: "0"
102
79
  type: :development
80
+ version_requirements: *id005
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
103
83
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: webmock
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
84
+ requirement: &id006 !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ version: "0"
118
91
  type: :development
92
+ version_requirements: *id006
93
+ - !ruby/object:Gem::Dependency
94
+ name: webmock
119
95
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
96
+ requirement: &id007 !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ type: :development
104
+ version_requirements: *id007
126
105
  description: A Ruby wrapper for the Tumblr v2 API
127
- email:
106
+ email:
128
107
  - codingjester@gmail.com
129
- executables:
108
+ executables:
130
109
  - tumblr
131
110
  extensions: []
111
+
132
112
  extra_rdoc_files: []
133
- files:
113
+
114
+ files:
134
115
  - .gitignore
135
116
  - .path
136
117
  - Gemfile
@@ -151,28 +132,37 @@ files:
151
132
  - lib/tumblr/user.rb
152
133
  - lib/tumblr_client.rb
153
134
  - tumblr.gemspec
135
+ has_rdoc: true
154
136
  homepage: http://github.com/codingjester/tumblr_client
155
137
  licenses: []
138
+
156
139
  post_install_message:
157
140
  rdoc_options: []
158
- require_paths:
141
+
142
+ require_paths:
159
143
  - lib
160
- required_ruby_version: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- required_rubygems_version: !ruby/object:Gem::Requirement
167
- none: false
168
- requirements:
169
- - - ! '>='
170
- - !ruby/object:Gem::Version
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ segments:
149
+ - 0
150
+ version: "0"
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ segments:
156
+ - 1
157
+ - 3
158
+ - 6
171
159
  version: 1.3.6
172
160
  requirements: []
161
+
173
162
  rubyforge_project:
174
- rubygems_version: 1.8.21
163
+ rubygems_version: 1.3.6
175
164
  signing_key:
176
165
  specification_version: 3
177
166
  summary: Tumblr API wrapper
178
167
  test_files: []
168
+