picasa 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/lib/picasa/presenter/album.rb +2 -2
- data/lib/picasa/presenter/album_list.rb +2 -2
- data/lib/picasa/presenter/comment.rb +1 -1
- data/lib/picasa/presenter/comment_list.rb +2 -2
- data/lib/picasa/presenter/media.rb +1 -1
- data/lib/picasa/presenter/photo.rb +1 -1
- data/lib/picasa/presenter/tag.rb +1 -1
- data/lib/picasa/presenter/tag_list.rb +2 -2
- data/lib/picasa/utils.rb +13 -1
- data/lib/picasa/version.rb +1 -1
- data/test/api/album_test.rb +4 -0
- data/test/utils_test.rb +6 -0
- metadata +2 -2
data/Gemfile
CHANGED
@@ -10,13 +10,13 @@ module Picasa
|
|
10
10
|
|
11
11
|
# @return [Array<Presenter::Photo>]
|
12
12
|
def entries
|
13
|
-
@entries ||= safe_retrieve(parsed_body, "entry").map { |photo| Photo.new(photo) }
|
13
|
+
@entries ||= array_wrap(safe_retrieve(parsed_body, "entry")).map { |photo| Photo.new(photo) }
|
14
14
|
end
|
15
15
|
alias :photos :entries
|
16
16
|
|
17
17
|
# @return [Array<Presenter::Link>]
|
18
18
|
def links
|
19
|
-
@links ||= safe_retrieve(parsed_body, "link").map { |link| Link.new(link) }
|
19
|
+
@links ||= array_wrap(safe_retrieve(parsed_body, "link")).map { |link| Link.new(link) }
|
20
20
|
end
|
21
21
|
|
22
22
|
# @return [Presenter::Media]
|
@@ -10,13 +10,13 @@ module Picasa
|
|
10
10
|
|
11
11
|
# @return [Array<Presenter::Album>]
|
12
12
|
def entries
|
13
|
-
@entries ||= safe_retrieve(parsed_body, "entry").map { |entry| Album.new(entry) }
|
13
|
+
@entries ||= array_wrap(safe_retrieve(parsed_body, "entry")).map { |entry| Album.new(entry) }
|
14
14
|
end
|
15
15
|
alias :albums :entries
|
16
16
|
|
17
17
|
# @return [Array<Presenter::Link>]
|
18
18
|
def links
|
19
|
-
@links ||= safe_retrieve(parsed_body, "link").map { |link| Link.new(link) }
|
19
|
+
@links ||= array_wrap(safe_retrieve(parsed_body, "link")).map { |link| Link.new(link) }
|
20
20
|
end
|
21
21
|
|
22
22
|
# @return [String]
|
@@ -10,7 +10,7 @@ module Picasa
|
|
10
10
|
|
11
11
|
# @return [Array<Presenter::Link>]
|
12
12
|
def links
|
13
|
-
@links ||= safe_retrieve(parsed_body, "link").map { |link| Link.new(link) }
|
13
|
+
@links ||= array_wrap(safe_retrieve(parsed_body, "link")).map { |link| Link.new(link) }
|
14
14
|
end
|
15
15
|
|
16
16
|
# @return [DateTime]
|
@@ -10,13 +10,13 @@ module Picasa
|
|
10
10
|
|
11
11
|
# @return [Array<Presenter::Comment>]
|
12
12
|
def entries
|
13
|
-
@entries ||= safe_retrieve(parsed_body, "entry").map { |entry| Comment.new(entry) }
|
13
|
+
@entries ||= array_wrap(safe_retrieve(parsed_body, "entry")).map { |entry| Comment.new(entry) }
|
14
14
|
end
|
15
15
|
alias :comments :entries
|
16
16
|
|
17
17
|
# @return [Array<Presenter::Link>]
|
18
18
|
def links
|
19
|
-
@links ||= safe_retrieve(parsed_body, "link").map { |link| Link.new(link) }
|
19
|
+
@links ||= array_wrap(safe_retrieve(parsed_body, "link")).map { |link| Link.new(link) }
|
20
20
|
end
|
21
21
|
|
22
22
|
# @return [String]
|
@@ -5,7 +5,7 @@ module Picasa
|
|
5
5
|
class Media < Base
|
6
6
|
# @return [Array<Presenter::Thumbnail>]
|
7
7
|
def thumbnails
|
8
|
-
@thumbnails ||= safe_retrieve(parsed_body, "media$thumbnail").map { |thumbnail| Thumbnail.new(thumbnail) }
|
8
|
+
@thumbnails ||= array_wrap(safe_retrieve(parsed_body, "media$thumbnail")).map { |thumbnail| Thumbnail.new(thumbnail) }
|
9
9
|
end
|
10
10
|
|
11
11
|
# @return [String]
|
@@ -5,7 +5,7 @@ module Picasa
|
|
5
5
|
class Photo < Base
|
6
6
|
# @return [Array<Presenter::Link>]
|
7
7
|
def links
|
8
|
-
@links ||= safe_retrieve(parsed_body, "link").map { |link| Link.new(link) }
|
8
|
+
@links ||= array_wrap(safe_retrieve(parsed_body, "link")).map { |link| Link.new(link) }
|
9
9
|
end
|
10
10
|
|
11
11
|
# @return [Presenter::Media]
|
data/lib/picasa/presenter/tag.rb
CHANGED
@@ -10,7 +10,7 @@ module Picasa
|
|
10
10
|
|
11
11
|
# @return [Array<Presenter::Link>]
|
12
12
|
def links
|
13
|
-
@links ||= safe_retrieve(parsed_body, "link").map { |link| Link.new(link) }
|
13
|
+
@links ||= array_wrap(safe_retrieve(parsed_body, "link")).map { |link| Link.new(link) }
|
14
14
|
end
|
15
15
|
|
16
16
|
# @return [DateTime]
|
@@ -10,13 +10,13 @@ module Picasa
|
|
10
10
|
|
11
11
|
# @return [Array<Presenter::Tag>]
|
12
12
|
def entries
|
13
|
-
@entries ||= safe_retrieve(parsed_body, "entry").map { |entry| Tag.new(entry) }
|
13
|
+
@entries ||= array_wrap(safe_retrieve(parsed_body, "entry")).map { |entry| Tag.new(entry) }
|
14
14
|
end
|
15
15
|
alias :tags :entries
|
16
16
|
|
17
17
|
# @return [Array<Presenter::Link>]
|
18
18
|
def links
|
19
|
-
@links ||= safe_retrieve(parsed_body, "link").map { |link| Link.new(link) }
|
19
|
+
@links ||= array_wrap(safe_retrieve(parsed_body, "link")).map { |link| Link.new(link) }
|
20
20
|
end
|
21
21
|
|
22
22
|
# @return [String]
|
data/lib/picasa/utils.rb
CHANGED
@@ -12,6 +12,7 @@ module Picasa
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
|
15
16
|
def retrieve(hash, keys)
|
16
17
|
return if !hash.kind_of?(Hash) || !hash.has_key?(keys.first)
|
17
18
|
|
@@ -22,6 +23,17 @@ module Picasa
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
26
|
+
# Ported from activesupport gem
|
27
|
+
def array_wrap(object)
|
28
|
+
if object.nil?
|
29
|
+
[]
|
30
|
+
elsif object.respond_to?(:to_ary)
|
31
|
+
object.to_ary || [object]
|
32
|
+
else
|
33
|
+
[object]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
25
37
|
def map_to_integer(value)
|
26
38
|
value && value.to_i
|
27
39
|
end
|
@@ -45,6 +57,6 @@ module Picasa
|
|
45
57
|
end.join("&")
|
46
58
|
end
|
47
59
|
|
48
|
-
module_function :safe_retrieve, :retrieve, :map_to_integer, :map_to_boolean, :map_to_date, :inline_query
|
60
|
+
module_function :safe_retrieve, :retrieve, :array_wrap, :map_to_integer, :map_to_boolean, :map_to_date, :inline_query
|
49
61
|
end
|
50
62
|
end
|
data/lib/picasa/version.rb
CHANGED
data/test/api/album_test.rb
CHANGED
data/test/utils_test.rb
CHANGED
@@ -43,6 +43,12 @@ describe Picasa::Utils do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
describe "#array_wrap" do
|
47
|
+
it "wraps hash into array" do
|
48
|
+
assert_equal [{:wt => :f}], Picasa::Utils.array_wrap({:wt => :f})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
46
52
|
describe "#map_to_integer" do
|
47
53
|
it "does not convert nil value" do
|
48
54
|
assert_nil Picasa::Utils.map_to_integer(nil)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picasa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
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: 2012-11-
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|