picasa 0.6.7 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Rakefile +1 -1
- data/lib/picasa/api/album.rb +4 -4
- data/lib/picasa/api/comment.rb +3 -3
- data/lib/picasa/api/photo.rb +2 -2
- data/lib/picasa/api/tag.rb +3 -3
- data/lib/picasa/client.rb +5 -5
- data/lib/picasa/connection.rb +17 -5
- data/lib/picasa/http.rb +1 -8
- data/lib/picasa/presenter/base.rb +1 -2
- data/lib/picasa/utils.rb +0 -1
- data/lib/picasa/version.rb +1 -1
- data/picasa.gemspec +25 -21
- data/test/fixtures/lena.jpg +0 -0
- data/test/helper.rb +2 -1
- metadata +67 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13c65c05a5b00067765a40f4339e4e11f04680f1
|
4
|
+
data.tar.gz: 66624e0d8ce131805533eae31ff58803a66f13af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d233fded3ee7fd4348ba64f3b1849579050467eb64690442ea1367e088b7fbaedd42490a63219b5bd9d8324d58c45c8d15c263d3436b2938e690c8a3ed27b0e9
|
7
|
+
data.tar.gz: 7b4311985a57ebec4c687061f98bf8085c8440f7ee7807c8497cd7efb5b9ea434c77a1972a2c38fcda1e69d3286fe7faa470269c58568a8f5952a3b29a1b69da
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/picasa/api/album.rb
CHANGED
@@ -14,7 +14,7 @@ module Picasa
|
|
14
14
|
# @return [Presenter::AlbumList]
|
15
15
|
def list(options = {})
|
16
16
|
path = "/data/feed/api/user/#{user_id}"
|
17
|
-
response = Connection.new.get(:
|
17
|
+
response = Connection.new.get(path: path, query: options, headers: auth_header)
|
18
18
|
|
19
19
|
Presenter::AlbumList.new(response.parsed_response["feed"])
|
20
20
|
end
|
@@ -31,7 +31,7 @@ module Picasa
|
|
31
31
|
# @raise [NotFoundError] raised when album cannot be found
|
32
32
|
def show(album_id, options = {})
|
33
33
|
path = "/data/feed/api/user/#{user_id}/albumid/#{album_id}"
|
34
|
-
response = Connection.new.get(:
|
34
|
+
response = Connection.new.get(path: path, query: options, headers: auth_header)
|
35
35
|
|
36
36
|
Presenter::Album.new(response.parsed_response["feed"])
|
37
37
|
end
|
@@ -54,7 +54,7 @@ module Picasa
|
|
54
54
|
|
55
55
|
template = Template.new(:new_album, params)
|
56
56
|
path = "/data/feed/api/user/#{user_id}"
|
57
|
-
response = Connection.new.post(:
|
57
|
+
response = Connection.new.post(path: path, body: template.render, headers: auth_header)
|
58
58
|
|
59
59
|
Presenter::Album.new(response.parsed_response["entry"])
|
60
60
|
end
|
@@ -71,7 +71,7 @@ module Picasa
|
|
71
71
|
def destroy(album_id, options = {})
|
72
72
|
headers = auth_header.merge({"If-Match" => options.fetch(:etag, "*")})
|
73
73
|
path = "/data/entry/api/user/#{user_id}/albumid/#{album_id}"
|
74
|
-
Connection.new.delete(:
|
74
|
+
Connection.new.delete(path: path, headers: headers)
|
75
75
|
true
|
76
76
|
end
|
77
77
|
alias :delete :destroy
|
data/lib/picasa/api/comment.rb
CHANGED
@@ -19,7 +19,7 @@ module Picasa
|
|
19
19
|
path << "/albumid/#{album_id}" if album_id
|
20
20
|
path << "/photoid/#{photo_id}" if photo_id
|
21
21
|
|
22
|
-
response = Connection.new.get(:
|
22
|
+
response = Connection.new.get(path: path, query: options.merge(kind: "comment"), headers: auth_header)
|
23
23
|
|
24
24
|
Presenter::CommentList.new(response.parsed_response["feed"])
|
25
25
|
end
|
@@ -41,7 +41,7 @@ module Picasa
|
|
41
41
|
|
42
42
|
template = Template.new("new_comment", params)
|
43
43
|
|
44
|
-
response = Connection.new.post(:
|
44
|
+
response = Connection.new.post(path: path, body: template.render, headers: auth_header)
|
45
45
|
|
46
46
|
Presenter::Comment.new(response.parsed_response["entry"])
|
47
47
|
end
|
@@ -59,7 +59,7 @@ module Picasa
|
|
59
59
|
photo_id = params.delete(:photo_id) || raise(ArgumentError, "You must specify photo_id")
|
60
60
|
|
61
61
|
path = "/data/entry/api/user/#{user_id}/albumid/#{album_id}/photoid/#{photo_id}/commentid/#{comment_id}"
|
62
|
-
Connection.new.delete(:
|
62
|
+
Connection.new.delete(path: path, headers: auth_header)
|
63
63
|
true
|
64
64
|
end
|
65
65
|
alias :delete :destroy
|
data/lib/picasa/api/photo.rb
CHANGED
@@ -23,7 +23,7 @@ module Picasa
|
|
23
23
|
headers = auth_header.merge({"Content-Type" => "multipart/related; boundary=\"#{params[:boundary]}\""})
|
24
24
|
|
25
25
|
path = "/data/feed/api/user/#{user_id}/albumid/#{album_id}"
|
26
|
-
response = Connection.new.post(:
|
26
|
+
response = Connection.new.post(path: path, body: template.render, headers: headers)
|
27
27
|
|
28
28
|
Presenter::Photo.new(response.parsed_response["entry"])
|
29
29
|
end
|
@@ -41,7 +41,7 @@ module Picasa
|
|
41
41
|
def destroy(album_id, photo_id, options = {})
|
42
42
|
headers = auth_header.merge({"If-Match" => options.fetch(:etag, "*")})
|
43
43
|
path = "/data/entry/api/user/#{user_id}/albumid/#{album_id}/photoid/#{photo_id}"
|
44
|
-
Connection.new.delete(:
|
44
|
+
Connection.new.delete(path: path, headers: headers)
|
45
45
|
true
|
46
46
|
end
|
47
47
|
alias :delete :destroy
|
data/lib/picasa/api/tag.rb
CHANGED
@@ -19,7 +19,7 @@ module Picasa
|
|
19
19
|
path << "/albumid/#{album_id}" if album_id
|
20
20
|
path << "/photoid/#{photo_id}" if photo_id
|
21
21
|
|
22
|
-
response = Connection.new.get(:
|
22
|
+
response = Connection.new.get(path: path, query: options.merge(kind: "tag"), headers: auth_header)
|
23
23
|
|
24
24
|
Presenter::TagList.new(response.parsed_response["feed"])
|
25
25
|
end
|
@@ -41,7 +41,7 @@ module Picasa
|
|
41
41
|
|
42
42
|
template = Template.new("new_tag", params)
|
43
43
|
|
44
|
-
response = Connection.new.post(:
|
44
|
+
response = Connection.new.post(path: path, body: template.render, headers: auth_header)
|
45
45
|
|
46
46
|
Presenter::Tag.new(response.parsed_response["entry"])
|
47
47
|
end
|
@@ -59,7 +59,7 @@ module Picasa
|
|
59
59
|
photo_id = params.delete(:photo_id) || raise(ArgumentError, "You must specify photo_id")
|
60
60
|
|
61
61
|
path = "/data/entry/api/user/#{user_id}/albumid/#{album_id}/photoid/#{photo_id}/tag/#{tag_id}"
|
62
|
-
Connection.new.delete(:
|
62
|
+
Connection.new.delete(path: path, headers: auth_header)
|
63
63
|
true
|
64
64
|
end
|
65
65
|
alias :delete :destroy
|
data/lib/picasa/client.rb
CHANGED
@@ -64,10 +64,10 @@ module Picasa
|
|
64
64
|
# @return [String]
|
65
65
|
def authenticate
|
66
66
|
response = Connection.new.post(
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
67
|
+
host: HTTP::API_AUTH_URL,
|
68
|
+
headers: {"Content-Type" => "application/x-www-form-urlencoded"},
|
69
|
+
path: "/accounts/ClientLogin",
|
70
|
+
body: Utils.inline_query(
|
71
71
|
"accountType" => "HOSTED_OR_GOOGLE",
|
72
72
|
"Email" => user_id,
|
73
73
|
"Passwd" => password,
|
@@ -87,7 +87,7 @@ module Picasa
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def credentials
|
90
|
-
{:
|
90
|
+
{user_id: user_id}.tap do |credentials|
|
91
91
|
credentials[:authorization_header] = authorization_header if authorization_header
|
92
92
|
end
|
93
93
|
end
|
data/lib/picasa/connection.rb
CHANGED
@@ -6,8 +6,6 @@ module Picasa
|
|
6
6
|
# @option params [String] :query request url query
|
7
7
|
# @option params [String] :headers request headers
|
8
8
|
def get(params = {})
|
9
|
-
# FIXME: how to add headers to default ones instead of replacing?
|
10
|
-
params[:headers] = Picasa::HTTP.headers.merge(params[:headers]) if params.has_key?(:headers)
|
11
9
|
exec_request(params) { |uri, options| HTTP.get(uri, options) }
|
12
10
|
end
|
13
11
|
|
@@ -20,7 +18,6 @@ module Picasa
|
|
20
18
|
def post(params = {})
|
21
19
|
params[:headers] ||= {}
|
22
20
|
params[:headers]["Content-Type"] ||= "application/atom+xml"
|
23
|
-
params[:headers] = Picasa::HTTP.headers.merge(params[:headers])
|
24
21
|
exec_request(params) { |uri, options| HTTP.post(uri, options) }
|
25
22
|
end
|
26
23
|
|
@@ -30,15 +27,26 @@ module Picasa
|
|
30
27
|
# @option params [String] :query request url query
|
31
28
|
# @option params [String] :headers request headers
|
32
29
|
def delete(params = {})
|
33
|
-
params[:headers] = Picasa::HTTP.headers.merge(params[:headers]) if params.has_key?(:headers)
|
34
30
|
exec_request(params) { |uri, options| HTTP.delete(uri, options) }
|
35
31
|
end
|
36
32
|
|
37
33
|
private
|
38
34
|
|
35
|
+
# Additional params for HTTParty gem can be passed
|
36
|
+
# https://github.com/jnunemaker/httparty/blob/v0.12.0/lib/httparty.rb#L43
|
39
37
|
def exec_request(params, &block)
|
40
38
|
uri = "#{params.delete(:host)}#{params.delete(:path)}"
|
41
|
-
|
39
|
+
|
40
|
+
params.tap do |p|
|
41
|
+
p[:headers] = HTTP.headers.merge(p.fetch(:headers, {}))
|
42
|
+
if p.keys.none? { |name| [:http_proxyaddr, :http_proxyport, :http_proxyuser, :http_proxypass].include?(name) }
|
43
|
+
p[:http_proxyaddr] = proxy_uri.host
|
44
|
+
p[:http_proxyport] = proxy_uri.port
|
45
|
+
p[:http_proxyuser] = proxy_uri.user
|
46
|
+
p[:http_proxypass] = proxy_uri.password
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
handle_response(yield(uri, params))
|
43
51
|
end
|
44
52
|
|
@@ -58,5 +66,9 @@ module Picasa
|
|
58
66
|
raise ResponseError.new(response.body, response)
|
59
67
|
end
|
60
68
|
end
|
69
|
+
|
70
|
+
def proxy_uri
|
71
|
+
@proxy_uri ||= URI.parse(ENV["https_proxy"] || ENV["HTTPS_PROXY"] || "")
|
72
|
+
end
|
61
73
|
end
|
62
74
|
end
|
data/lib/picasa/http.rb
CHANGED
@@ -9,20 +9,13 @@ module Picasa
|
|
9
9
|
API_AUTH_URL = "https://www.google.com"
|
10
10
|
API_VERSION = "2"
|
11
11
|
|
12
|
-
def self.proxy
|
13
|
-
proxy_uri = URI.parse(ENV["https_proxy"] || ENV["HTTPS_PROXY"] || "")
|
14
|
-
[proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password]
|
15
|
-
end
|
16
|
-
|
17
12
|
format :json
|
18
|
-
default_params :
|
13
|
+
default_params alt: :json
|
19
14
|
|
20
15
|
headers "User-Agent" => "ruby-gem-picasa-v#{VERSION} (gzip)",
|
21
16
|
"GData-Version" => API_VERSION,
|
22
17
|
"Accept-Encoding" => "gzip, deflate"
|
23
18
|
|
24
19
|
base_uri API_URL
|
25
|
-
|
26
|
-
http_proxy *proxy
|
27
20
|
end
|
28
21
|
end
|
data/lib/picasa/utils.rb
CHANGED
data/lib/picasa/version.rb
CHANGED
data/picasa.gemspec
CHANGED
@@ -1,27 +1,31 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "picasa/version"
|
3
5
|
|
4
|
-
Gem::Specification.new do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "picasa"
|
8
|
+
spec.version = Picasa::VERSION
|
9
|
+
spec.authors = ["Wojciech Wnętrzak"]
|
10
|
+
spec.email = ["w.wnetrzak@gmail.com"]
|
11
|
+
spec.description = %q{Ruby client for Google Picasa API}
|
12
|
+
spec.summary = %q{Simple Google Picasa managment}
|
13
|
+
spec.homepage = "https://github.com/morgoth/picasa"
|
14
|
+
spec.license = "MIT"
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
gem.require_paths = ["lib"]
|
17
|
-
gem.version = Picasa::VERSION
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
18
20
|
|
19
|
-
|
21
|
+
spec.required_ruby_version = ">= 1.9.3"
|
20
22
|
|
21
|
-
|
22
|
-
gem.add_development_dependency "webmock"
|
23
|
-
gem.add_development_dependency "mocha", ">= 0.13.0"
|
24
|
-
gem.add_development_dependency "vcr", ">= 2.4.0"
|
23
|
+
spec.add_dependency "httparty"
|
25
24
|
|
26
|
-
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "minitest", ">= 5.0.0"
|
28
|
+
spec.add_development_dependency "webmock"
|
29
|
+
spec.add_development_dependency "mocha", ">= 0.13.0"
|
30
|
+
spec.add_development_dependency "vcr", ">= 2.4.0"
|
27
31
|
end
|
data/test/fixtures/lena.jpg
CHANGED
Binary file
|
data/test/helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "yaml"
|
2
2
|
require "zlib"
|
3
|
+
require "multi_json"
|
3
4
|
|
4
5
|
require "minitest/autorun"
|
5
6
|
require "webmock/minitest"
|
@@ -16,7 +17,7 @@ MultiJson.adapter = ENV["JSON_PARSER"] || "oj"
|
|
16
17
|
VCR.configure do |c|
|
17
18
|
c.cassette_library_dir = "test/cassettes"
|
18
19
|
c.hook_into :webmock
|
19
|
-
c.default_cassette_options = {:
|
20
|
+
c.default_cassette_options = {preserve_exact_body_bytes: true}
|
20
21
|
c.filter_sensitive_data("<FILTERED>") { AuthHeader }
|
21
22
|
c.filter_sensitive_data("<FILTERED>") { Password }
|
22
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picasa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wojciech Wnętrzak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: minitest
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +109,8 @@ dependencies:
|
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: 2.4.0
|
83
111
|
description: Ruby client for Google Picasa API
|
84
|
-
email:
|
112
|
+
email:
|
113
|
+
- w.wnetrzak@gmail.com
|
85
114
|
executables: []
|
86
115
|
extensions: []
|
87
116
|
extra_rdoc_files: []
|
@@ -168,8 +197,7 @@ homepage: https://github.com/morgoth/picasa
|
|
168
197
|
licenses:
|
169
198
|
- MIT
|
170
199
|
metadata: {}
|
171
|
-
post_install_message:
|
172
|
-
If you still need 1.8.7 freeze gem version to ~> 0.6.7
|
200
|
+
post_install_message:
|
173
201
|
rdoc_options: []
|
174
202
|
require_paths:
|
175
203
|
- lib
|
@@ -177,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
205
|
requirements:
|
178
206
|
- - '>='
|
179
207
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
208
|
+
version: 1.9.3
|
181
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
210
|
requirements:
|
183
211
|
- - '>='
|
@@ -185,8 +213,39 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
213
|
version: '0'
|
186
214
|
requirements: []
|
187
215
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
216
|
+
rubygems_version: 2.1.11
|
189
217
|
signing_key:
|
190
218
|
specification_version: 4
|
191
219
|
summary: Simple Google Picasa managment
|
192
|
-
test_files:
|
220
|
+
test_files:
|
221
|
+
- test/api/album_test.rb
|
222
|
+
- test/api/comment_test.rb
|
223
|
+
- test/api/photo_test.rb
|
224
|
+
- test/api/tag_test.rb
|
225
|
+
- test/cassettes/album-404.yml
|
226
|
+
- test/cassettes/album-create.yml
|
227
|
+
- test/cassettes/album-destroy.yml
|
228
|
+
- test/cassettes/album-list.yml
|
229
|
+
- test/cassettes/album-show.yml
|
230
|
+
- test/cassettes/auth-failed.yml
|
231
|
+
- test/cassettes/auth-success.yml
|
232
|
+
- test/cassettes/comment-400.yml
|
233
|
+
- test/cassettes/comment-create.yml
|
234
|
+
- test/cassettes/comment-destroy.yml
|
235
|
+
- test/cassettes/comment-list.yml
|
236
|
+
- test/cassettes/photo-412.yml
|
237
|
+
- test/cassettes/photo-create.yml
|
238
|
+
- test/cassettes/photo-destroy.yml
|
239
|
+
- test/cassettes/tag-create.yml
|
240
|
+
- test/cassettes/tag-destroy.yml
|
241
|
+
- test/cassettes/tag-list.yml
|
242
|
+
- test/cassettes/video-create.yml
|
243
|
+
- test/client_test.rb
|
244
|
+
- test/connection_test.rb
|
245
|
+
- test/file_test.rb
|
246
|
+
- test/fixtures/lena.jpg
|
247
|
+
- test/fixtures/sample.3gp
|
248
|
+
- test/fixtures/sample.txt
|
249
|
+
- test/helper.rb
|
250
|
+
- test/template_test.rb
|
251
|
+
- test/utils_test.rb
|