flickrie 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +9 -5
- data/lib/flickrie/media/tag.rb +2 -2
- data/lib/flickrie/media.rb +12 -3
- data/lib/flickrie/version.rb +1 -1
- data/test/media_test.rb +6 -6
- data/test/photo_test.rb +13 -0
- data/test/video_test.rb +16 -0
- metadata +5 -7
- data/test/client_test.rb +0 -40
data/README.md
CHANGED
@@ -13,12 +13,20 @@ not a string representing that time (often in a timestamp (integer) format).
|
|
13
13
|
That's what wrappers should be for.
|
14
14
|
|
15
15
|
The method names here aren't called the same as Flickr's API methods, but they follow a pattern which
|
16
|
-
shouldn't be too difficult to learn.
|
16
|
+
shouldn't be too difficult to learn. Take a look at the "Covered API
|
17
|
+
methods" section of this readme.
|
18
|
+
|
19
|
+
Also, some attribute names that you
|
17
20
|
get from the response are changed. So, for example, the `last_update`
|
18
21
|
attribute is called `updated_at`, and the `candownload` attribute is
|
19
22
|
called `can_download?`. After all, this is a **ruby** wrapper, so it
|
20
23
|
should be written in Ruby/Rails fashion :)
|
21
24
|
|
25
|
+
There are 2 things that are different from the Flickr's API documentation:
|
26
|
+
- "photoset" is here just "set". This is because the word "photoset" is actually
|
27
|
+
incorrect, since sets can also hold videos.
|
28
|
+
- "person" is here refered to as "user".
|
29
|
+
|
22
30
|
## Examples of usage
|
23
31
|
|
24
32
|
You first need to install the gem.
|
@@ -50,10 +58,6 @@ photo.owner # => #<User: nsid="67313352@N04", ...>
|
|
50
58
|
photo.owner.nsid # => "67313352@N04"
|
51
59
|
```
|
52
60
|
|
53
|
-
Note that, what Flickr refers to as "photoset" in its documentation, I
|
54
|
-
refer to as "set". This is because the word "photoset" is actually
|
55
|
-
incorrect, since sets can also hold videos.
|
56
|
-
|
57
61
|
You can also throw in some parameters to `Flickrie.photos_from_set` to get more information about photos. For example,
|
58
62
|
|
59
63
|
```ruby
|
data/lib/flickrie/media/tag.rb
CHANGED
@@ -6,11 +6,11 @@ module Flickrie
|
|
6
6
|
def content; @info['_content'] end
|
7
7
|
|
8
8
|
def machine_tag?
|
9
|
-
@info['machine_tag'].to_i == 1
|
9
|
+
@info['machine_tag'].to_i == 1 if @info['machine_tag']
|
10
10
|
end
|
11
11
|
|
12
12
|
def author
|
13
|
-
User.new('nsid' => @info['author'])
|
13
|
+
User.new('nsid' => @info['author']) if @info['author']
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize(info)
|
data/lib/flickrie/media.rb
CHANGED
@@ -13,7 +13,6 @@ module Flickrie
|
|
13
13
|
def title; @info['title'] end
|
14
14
|
def description; @info['description'] end
|
15
15
|
def tags; @info['tags'] end
|
16
|
-
def machine_tags; @info['machine_tags'] end
|
17
16
|
def media_status; @info['media_status'] end
|
18
17
|
def path_alias; @info['pathalias'] end
|
19
18
|
|
@@ -29,6 +28,10 @@ module Flickrie
|
|
29
28
|
Location.new(@info['location']) if @info['location']
|
30
29
|
end
|
31
30
|
|
31
|
+
def machine_tags
|
32
|
+
tags.select { |tag| tag.machine_tag? } if tags
|
33
|
+
end
|
34
|
+
|
32
35
|
def geo_permissions
|
33
36
|
if @info['geoperms']
|
34
37
|
Visibility.new \
|
@@ -152,6 +155,12 @@ module Flickrie
|
|
152
155
|
}
|
153
156
|
info['usage'] = {}
|
154
157
|
|
158
|
+
unless info['tags'].nil?
|
159
|
+
info['tags'] = info['tags'].split(' ').map do |tag_content|
|
160
|
+
Tag.new('_content' => tag_content)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
155
164
|
new(info)
|
156
165
|
end
|
157
166
|
end
|
@@ -178,8 +187,8 @@ module Flickrie
|
|
178
187
|
new.get_sizes(info)
|
179
188
|
end
|
180
189
|
|
181
|
-
def from_search(
|
182
|
-
from_user(
|
190
|
+
def from_search(hash)
|
191
|
+
from_user(hash)
|
183
192
|
end
|
184
193
|
end
|
185
194
|
extend(ClassMethods)
|
data/lib/flickrie/version.rb
CHANGED
data/test/media_test.rb
CHANGED
@@ -135,8 +135,8 @@ class MediaTest < Test::Unit::TestCase
|
|
135
135
|
assert_equal '7049', media.server
|
136
136
|
assert_equal 8, media.farm
|
137
137
|
assert_equal 'IMG_0796', media.title
|
138
|
-
assert_equal 'luka', media.tags
|
139
|
-
assert_equal '', media.machine_tags
|
138
|
+
assert_equal 'luka', media.tags.join(' ')
|
139
|
+
assert_equal '', media.machine_tags.join(' ')
|
140
140
|
assert_equal 2, media.views_count
|
141
141
|
assert_equal '0', media.license.id
|
142
142
|
assert_equal true, media.primary?
|
@@ -178,8 +178,8 @@ class MediaTest < Test::Unit::TestCase
|
|
178
178
|
assert_equal '7049', media.server
|
179
179
|
assert_equal 8, media.farm
|
180
180
|
assert_equal 'IMG_0796', media.title
|
181
|
-
assert_equal 'luka', media.tags
|
182
|
-
assert_equal '', media.machine_tags
|
181
|
+
assert_equal 'luka', media.tags.join(' ')
|
182
|
+
assert_equal '', media.machine_tags.join(' ')
|
183
183
|
assert_equal 2, media.views_count
|
184
184
|
assert_equal '0', media.license.id
|
185
185
|
assert_not_nil media.url
|
@@ -226,8 +226,8 @@ class MediaTest < Test::Unit::TestCase
|
|
226
226
|
assert_equal '7049', media.server
|
227
227
|
assert_equal 8, media.farm
|
228
228
|
assert_equal 'IMG_0796', media.title
|
229
|
-
assert_equal 'luka', media.tags
|
230
|
-
assert_equal '', media.machine_tags
|
229
|
+
assert_equal 'luka', media.tags.join(' ')
|
230
|
+
assert_equal '', media.machine_tags.join(' ')
|
231
231
|
assert_equal 2, media.views_count
|
232
232
|
assert_equal '0', media.license.id
|
233
233
|
assert_not_nil media.url
|
data/test/photo_test.rb
CHANGED
@@ -145,4 +145,17 @@ class PhotoTest < Test::Unit::TestCase
|
|
145
145
|
assert_nil photo.height
|
146
146
|
end
|
147
147
|
end
|
148
|
+
|
149
|
+
def test_other_api_calls
|
150
|
+
# add_photo_tags, get_photo_info, remove_photo_tag,
|
151
|
+
# search_photos, photos_from_contacts
|
152
|
+
|
153
|
+
assert_nothing_raised do
|
154
|
+
Flickrie.add_photo_tags(@photo_id, "janko")
|
155
|
+
photo = Flickrie.get_photo_info(@photo_id)
|
156
|
+
tag = photo.tags.find { |tag| tag.content == "janko" }
|
157
|
+
Flickrie.remove_photo_tag(tag.id)
|
158
|
+
Flickrie.search_photos(:user_id => @user_nsid)
|
159
|
+
end
|
160
|
+
end
|
148
161
|
end
|
data/test/video_test.rb
CHANGED
@@ -65,4 +65,20 @@ class VideoTest < Test::Unit::TestCase
|
|
65
65
|
assert_nil video.download_url
|
66
66
|
assert_nil video.mobile_download_url
|
67
67
|
end
|
68
|
+
|
69
|
+
def test_other_api_calls
|
70
|
+
# add_video_tags, remove_video_tag,
|
71
|
+
# search_videos, videos_from_contacts,
|
72
|
+
# public_videos_from_user, videos_from_set
|
73
|
+
|
74
|
+
assert_nothing_raised do
|
75
|
+
Flickrie.add_video_tags(@video_id, "janko")
|
76
|
+
video = Flickrie.get_video_info(@video_id)
|
77
|
+
tag = video.tags.find { |tag| tag.content == "janko" }
|
78
|
+
Flickrie.remove_video_tag(tag.id)
|
79
|
+
Flickrie.search_videos(:user_id => @user_nsid)
|
80
|
+
Flickrie.public_videos_from_user(@user_nsid)
|
81
|
+
Flickrie.videos_from_set(@set_id)
|
82
|
+
end
|
83
|
+
end
|
68
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flickrie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday_middleware
|
16
|
-
requirement: &
|
16
|
+
requirement: &70134907783700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70134907783700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simple_oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &70134907780840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70134907780840
|
36
36
|
description: This gem is a nice wrapper for the Flickr API with an intuitive interface.
|
37
37
|
email:
|
38
38
|
- janko.marohnic@gmail.com
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- lib/flickrie/user.rb
|
63
63
|
- lib/flickrie/version.rb
|
64
64
|
- lib/flickrie/video.rb
|
65
|
-
- test/client_test.rb
|
66
65
|
- test/instance_test.rb
|
67
66
|
- test/license_test.rb
|
68
67
|
- test/location_test.rb
|
@@ -101,7 +100,6 @@ summary: The reason why I did this gem is because the other ones either weren't
|
|
101
100
|
call wasn't processed almost at all. It doesn't seem too bad at first, but after
|
102
101
|
a while you realize it's not pretty. So I wanted to make it pretty :)
|
103
102
|
test_files:
|
104
|
-
- test/client_test.rb
|
105
103
|
- test/instance_test.rb
|
106
104
|
- test/license_test.rb
|
107
105
|
- test/location_test.rb
|
data/test/client_test.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'test'
|
3
|
-
require 'flickrie/client'
|
4
|
-
|
5
|
-
class ClientTest < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@client = Flickrie.client
|
8
|
-
@set_id = 72157629851991663
|
9
|
-
@media_id = 7093038981
|
10
|
-
@user_nsid = '67131352@N04'
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_internals
|
14
|
-
assert_equal ENV['FLICKR_API_KEY'], Flickrie.api_key
|
15
|
-
assert_instance_of Flickrie::Client, @client
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_api_calls
|
19
|
-
assert_nothing_raised do
|
20
|
-
# people
|
21
|
-
@client.find_user_by_email('janko.marohnic@gmail.com')
|
22
|
-
@client.find_user_by_username('Janko Marohnić')
|
23
|
-
@client.get_user_info(@user_nsid)
|
24
|
-
@client.public_media_from_user(@user_nsid)
|
25
|
-
|
26
|
-
# photos
|
27
|
-
@client.get_media_info(@media_id)
|
28
|
-
@client.get_media_sizes(@media_id)
|
29
|
-
@client.search_media(:user_id => @user_nsid)
|
30
|
-
|
31
|
-
# licenses
|
32
|
-
@client.get_licenses
|
33
|
-
|
34
|
-
# photosets
|
35
|
-
@client.get_set_info(@set_id)
|
36
|
-
@client.sets_from_user(@user_nsid)
|
37
|
-
@client.media_from_set(@set_id)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|