aperture 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/aperture.gemspec +1 -1
- data/lib/aperture/photo_set.rb +6 -1
- data/lib/aperture.rb +1 -1
- data/test/helper.rb +2 -2
- data/test/test_photo_set.rb +12 -18
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/aperture.gemspec
CHANGED
data/lib/aperture/photo_set.rb
CHANGED
@@ -80,7 +80,12 @@ module Aperture
|
|
80
80
|
return hash
|
81
81
|
end
|
82
82
|
|
83
|
-
#
|
83
|
+
# Returns a new PhotoSet where the photos match the passed keyword
|
84
|
+
def find_by_keyword(keyword)
|
85
|
+
versions = map {|p| p.versions }.flatten
|
86
|
+
matching = versions.select {|v| v.attributes['keywords'] && v.attributes['keywords'].include?(keyword) }
|
87
|
+
return PhotoSet.new(matching.map{|v| v.photo}.uniq)
|
88
|
+
end
|
84
89
|
|
85
90
|
# def find_photos_by_rating
|
86
91
|
|
data/lib/aperture.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
1
|
+
# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
# $LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'test/unit'
|
data/test/test_photo_set.rb
CHANGED
@@ -29,24 +29,6 @@ class TestPhotoSet < Test::Unit::TestCase
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
# context "each" do
|
33
|
-
# setup do
|
34
|
-
# @photoset = PhotoSet.new()
|
35
|
-
# @photo = Photo.new(SAMPLE_PHOTO_PATH)
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
# should "iterate over all the photos" do
|
39
|
-
# versions = 0
|
40
|
-
# @photoset.each {|p| versions += p.versions.size}
|
41
|
-
# assert_equal versions, 12
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# should "give us access to inject" do
|
45
|
-
# versions = @photoset.map {|p| p.versions.size }
|
46
|
-
# assert_equal versions, [2]*6
|
47
|
-
# end
|
48
|
-
# end
|
49
|
-
|
50
32
|
context "photo_count" do
|
51
33
|
setup do
|
52
34
|
@library = SAMPLE_LIBRARY
|
@@ -89,4 +71,16 @@ class TestPhotoSet < Test::Unit::TestCase
|
|
89
71
|
end
|
90
72
|
end
|
91
73
|
|
74
|
+
context "find_by_keyword" do
|
75
|
+
setup do
|
76
|
+
@library = SAMPLE_LIBRARY
|
77
|
+
end
|
78
|
+
|
79
|
+
should "should find 9 'Racing' photos" do
|
80
|
+
assert_instance_of(Aperture::PhotoSet, @library.photos.find_by_keyword('Racing'))
|
81
|
+
assert_equal @library.photos.find_by_keyword('Racing').size, 9
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
92
86
|
end
|