myflickr 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -4
- data/lib/myflickr/set.rb +12 -3
- data/lib/myflickr/version.rb +1 -1
- data/spec/set_spec.rb +13 -0
- metadata +1 -1
data/History.txt
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
== 0.0.
|
2
|
-
|
3
|
-
* Initial release
|
1
|
+
== 0.0.2 2007-12-19
|
4
2
|
|
3
|
+
* Added tags collection for sets (Collects unique tags from the images inside the set)
|
4
|
+
|
5
5
|
== 0.0.2 2007-12-19
|
6
6
|
|
7
7
|
* Specs written, classes revised
|
8
|
-
* All 'works'
|
8
|
+
* All 'works'
|
9
|
+
|
10
|
+
== 0.0.1 2007-12-15
|
11
|
+
|
12
|
+
* Initial release
|
data/lib/myflickr/set.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module Myflickr
|
2
2
|
class Set < Struct.new :id, :photo_count, :title, :description
|
3
|
-
attr_reader :photos
|
4
|
-
|
5
3
|
# Get a list of available photosets
|
6
4
|
def self.list
|
7
5
|
parse(Query.api_call('flickr.photosets.getList'))
|
@@ -22,8 +20,19 @@ module Myflickr
|
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
23
|
+
# Return a list of tags for the set (This is rough as guts as far as queries go)
|
24
|
+
def tags
|
25
|
+
tags = []
|
26
|
+
photos.each do |photo|
|
27
|
+
photo.tags.each do |tag|
|
28
|
+
tags << tag
|
29
|
+
end
|
30
|
+
end
|
31
|
+
tags
|
32
|
+
end
|
33
|
+
|
25
34
|
private
|
26
|
-
def self.parse(collection)
|
35
|
+
def self.parse(collection)
|
27
36
|
photosets = (collection/:photoset)
|
28
37
|
photosets.empty? ? [] : photosets.parallel_map(MAX_THREADS) do |set|
|
29
38
|
Set.new(set[:id], set[:photos], (set/:title).inner_text, (set/:description).inner_text)
|
data/lib/myflickr/version.rb
CHANGED
data/spec/set_spec.rb
CHANGED
@@ -37,4 +37,17 @@ describe Set, "class" do
|
|
37
37
|
photos.should be_an_instance_of(Array)
|
38
38
|
photos.first.should be_an_instance_of(Photo)
|
39
39
|
end
|
40
|
+
|
41
|
+
it "should collect tags for the photos in the set" do
|
42
|
+
myset = Set.find "72157603414539843"
|
43
|
+
tags = myset.tags
|
44
|
+
tags.should be_an_instance_of(Array)
|
45
|
+
tags.first.should be_an_instance_of(Tag)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should collect unique tags" do
|
49
|
+
myset = Set.find "72157603414539843"
|
50
|
+
tags = myset.tags
|
51
|
+
tags.uniq.should eql tags
|
52
|
+
end
|
40
53
|
end
|