flickrie 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.md +42 -27
- data/Rakefile +2 -2
- data/lib/flickrie/api_methods.rb +117 -0
- data/lib/flickrie/client.rb +26 -6
- data/lib/flickrie/instance.rb +15 -0
- data/lib/flickrie/version.rb +1 -1
- data/lib/flickrie.rb +3 -114
- data/test/client_test.rb +1 -2
- data/test/instance_test.rb +21 -0
- data/test/license_test.rb +1 -5
- data/test/location_test.rb +1 -1
- data/test/media_test.rb +1 -5
- data/test/photo_test.rb +3 -4
- data/test/set_test.rb +3 -4
- data/test/test.rb +9 -0
- data/test/user_test.rb +1 -2
- data/test/video_test.rb +3 -4
- metadata +12 -6
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -27,8 +27,8 @@ You first need to install the gem.
|
|
27
27
|
[sudo] gem install flickrie
|
28
28
|
```
|
29
29
|
|
30
|
-
Then in your app you set the API key and secret (
|
31
|
-
for [here](http://www.flickr.com/services/apps/create/apply)).
|
30
|
+
Then in your app you set the API key and secret (if you don't have them
|
31
|
+
already, you can apply for them [here](http://www.flickr.com/services/apps/create/apply)).
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
require 'flickrie'
|
@@ -140,15 +140,25 @@ request_token.get_authorization_url(:permissions => "read")
|
|
140
140
|
to ask only for "read" permissions from the user. Available permissions
|
141
141
|
are "read", "write" and "delete".
|
142
142
|
|
143
|
-
|
144
|
-
|
143
|
+
If you want to make authentication in your web application, check out my [flickr_auth](https://github.com/janko-m/flickr_auth) gem.
|
144
|
+
Or, if you want to do it manually, check out [this wiki](https://github.com/janko-m/flickrie/wiki/Authentication-in-web-applications) for instructions.
|
145
145
|
|
146
146
|
## A few words
|
147
147
|
|
148
|
-
Now, I covered only a few out of many Flickr's API methods using this approach,
|
148
|
+
Now, I covered only a few out of many Flickr's API methods using this approach,
|
149
|
+
but I'll constantly update this gem with new API methods. For all of the methods
|
150
|
+
I didn't cover, you can still call them using
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
Flickrie.client.get(method_name, params = {})
|
154
|
+
Flickrie.client.post(method_name, params = {})
|
155
|
+
```
|
156
|
+
|
157
|
+
For example:
|
149
158
|
|
150
159
|
```ruby
|
151
160
|
response = Flickrie.client.get "flickr.photos.getContext", :photo_id => 2842732
|
161
|
+
|
152
162
|
reponse.body # =>
|
153
163
|
# {
|
154
164
|
# "count" => {"_content" => 99},
|
@@ -163,9 +173,12 @@ reponse.body # =>
|
|
163
173
|
# ...
|
164
174
|
# }
|
165
175
|
# }
|
176
|
+
response.body['prevphoto']['id'] # => "6946978706"
|
166
177
|
```
|
167
178
|
|
168
|
-
It's not nearly as pretty, but at least you can get to the data
|
179
|
+
It's not nearly as pretty, but at least you can get to the data for the
|
180
|
+
time being. Notice that the `:api_key` parameter is always passed in by
|
181
|
+
default.
|
169
182
|
|
170
183
|
## Issues
|
171
184
|
|
@@ -180,27 +193,29 @@ basis of this gem.
|
|
180
193
|
|
181
194
|
## Currently covered API methods
|
182
195
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
196
|
+
```ruby
|
197
|
+
# people
|
198
|
+
"flickr.people.findByEmail" -> Flickrie.find_user_by_email
|
199
|
+
"flickr.people.findByUsername" -> Flickrie.find_user_by_username
|
200
|
+
"flickr.people.getInfo" -> Flickrie.get_user_info
|
201
|
+
"flickr.people.getPublicPhotos" -> Flickrie.public_photos_from_user
|
202
|
+
|
203
|
+
# photos
|
204
|
+
"flickr.photos.addTags" -> Flickrie.add_photo_tags
|
205
|
+
"flickr.photos.delete" -> Flickrie.delete_photo
|
206
|
+
"flickr.photos.getInfo" -> Flickrie.get_photo_info
|
207
|
+
"flickr.photos.getSizes" -> Flickrie.get_photo_sizes
|
208
|
+
"flickr.photos.removeTag" -> Flickrie.remove_photo_tag
|
209
|
+
"flickr.photos.search" -> Flickrie.search_photos
|
210
|
+
|
211
|
+
# photos.licenses
|
212
|
+
"flickr.photos.licenses.getInfo" -> Flickrie.get_licenses
|
213
|
+
|
214
|
+
# photosets
|
215
|
+
"flickr.photosets.getInfo" -> Flickrie.get_set_info
|
216
|
+
"flickr.photosets.getList" -> Flickrie.sets_from_user
|
217
|
+
"flickr.photosets.getPhotos" -> Flickrie.photos_from_set
|
218
|
+
```
|
204
219
|
|
205
220
|
## License
|
206
221
|
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ CURRENT_DIR = File.expand_path(File.dirname(__FILE__))
|
|
5
5
|
|
6
6
|
task :test do
|
7
7
|
Dir["#{CURRENT_DIR}/test/**/*_test.rb"].each do |test|
|
8
|
-
system "
|
8
|
+
system "turn -Ilib -Itest #{test}"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -13,7 +13,7 @@ namespace :test do
|
|
13
13
|
test_rbs = Dir["#{CURRENT_DIR}/test/*_test.rb"]
|
14
14
|
test_rbs.map { |t| File.basename(t).chomp('_test.rb') }.each do |test_name|
|
15
15
|
task(test_name.to_sym) do
|
16
|
-
system "
|
16
|
+
system "turn -Ilib -Itest test/#{test_name}_test.rb"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'flickrie/client'
|
2
|
+
require 'flickrie/oauth'
|
3
|
+
require 'flickrie/license'
|
4
|
+
require 'flickrie/user'
|
5
|
+
require 'flickrie/media'
|
6
|
+
require 'flickrie/photo'
|
7
|
+
require 'flickrie/video'
|
8
|
+
require 'flickrie/set'
|
9
|
+
|
10
|
+
module Flickrie
|
11
|
+
module ApiMethods
|
12
|
+
# people
|
13
|
+
def find_user_by_email(email)
|
14
|
+
response = client.find_user_by_email(email)
|
15
|
+
User.from_find(response.body['user'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_user_by_username(username)
|
19
|
+
response = client.find_user_by_username(username)
|
20
|
+
User.from_find(response.body['user'])
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_user_info(user_nsid)
|
24
|
+
response = client.get_user_info(user_nsid)
|
25
|
+
User.from_info(response.body['person'])
|
26
|
+
end
|
27
|
+
|
28
|
+
def public_media_from_user(user_nsid, params = {})
|
29
|
+
response = client.public_media_from_user(user_nsid, params)
|
30
|
+
Media.from_user(response.body['photos'])
|
31
|
+
end
|
32
|
+
def public_photos_from_user(user_nsid, params = {})
|
33
|
+
public_media_from_user(user_nsid, params).select do |media|
|
34
|
+
media.is_a?(Photo)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def public_videos_from_user(user_nsid, params = {})
|
38
|
+
public_media_from_user(user_nsid, params).select do |media|
|
39
|
+
media.is_a?(Video)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# photos
|
44
|
+
def add_media_tags(media_id, tags)
|
45
|
+
client.add_media_tags(media_id, tags)
|
46
|
+
end
|
47
|
+
alias add_photo_tags add_media_tags
|
48
|
+
alias add_video_tags add_media_tags
|
49
|
+
|
50
|
+
def delete_media(media_id)
|
51
|
+
client.delete_media(media_id)
|
52
|
+
end
|
53
|
+
alias delete_photo delete_media
|
54
|
+
alias delete_video delete_media
|
55
|
+
|
56
|
+
def get_media_info(media_id)
|
57
|
+
response = client.get_media_info(media_id)
|
58
|
+
Media.from_info(response.body['photo'])
|
59
|
+
end
|
60
|
+
alias get_photo_info get_media_info
|
61
|
+
alias get_video_info get_media_info
|
62
|
+
|
63
|
+
def get_photo_sizes(photo_id)
|
64
|
+
response = client.get_media_sizes(photo_id)
|
65
|
+
Photo.from_sizes(response.body['sizes'])
|
66
|
+
end
|
67
|
+
def get_video_sizes(video_id)
|
68
|
+
response = client.get_media_sizes(video_id)
|
69
|
+
Video.from_sizes(response.body['sizes'])
|
70
|
+
end
|
71
|
+
|
72
|
+
def remove_media_tag(tag_id)
|
73
|
+
client.remove_media_tag(tag_id)
|
74
|
+
end
|
75
|
+
alias remove_photo_tag remove_media_tag
|
76
|
+
alias remove_video_tag remove_media_tag
|
77
|
+
|
78
|
+
def search_media(search_params = {})
|
79
|
+
response = client.search_media(search_params)
|
80
|
+
Media.from_search(response.body['photos'])
|
81
|
+
end
|
82
|
+
def search_photos(search_params = {})
|
83
|
+
search_media(search_params.merge(:media => 'photos'))
|
84
|
+
end
|
85
|
+
def search_videos(search_params = {})
|
86
|
+
search_media(search_params.merge(:media => 'videos'))
|
87
|
+
end
|
88
|
+
|
89
|
+
# licenses
|
90
|
+
def get_licenses
|
91
|
+
response = client.get_licenses
|
92
|
+
License.from_hash(response.body['licenses']['license'])
|
93
|
+
end
|
94
|
+
|
95
|
+
# photosets
|
96
|
+
def get_set_info(set_id)
|
97
|
+
response = client.get_set_info(set_id)
|
98
|
+
Set.from_info(response.body['photoset'])
|
99
|
+
end
|
100
|
+
|
101
|
+
def sets_from_user(user_nsid)
|
102
|
+
response = client.sets_from_user(user_nsid)
|
103
|
+
Set.from_user(response.body['photosets']['photoset'], user_nsid)
|
104
|
+
end
|
105
|
+
|
106
|
+
def media_from_set(set_id, params = {})
|
107
|
+
response = client.media_from_set(set_id, params)
|
108
|
+
Media.from_set(response.body['photoset'])
|
109
|
+
end
|
110
|
+
def photos_from_set(set_id, params = {})
|
111
|
+
media_from_set(set_id, params.merge(:media => 'photos'))
|
112
|
+
end
|
113
|
+
def videos_from_set(set_id, params = {})
|
114
|
+
media_from_set(set_id, params.merge(:media => 'videos'))
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/lib/flickrie/client.rb
CHANGED
@@ -1,23 +1,34 @@
|
|
1
1
|
require 'faraday_middleware'
|
2
|
-
require 'simple_oauth'
|
3
2
|
|
4
3
|
module Flickrie
|
5
4
|
class << self
|
6
|
-
|
7
|
-
|
5
|
+
def self.attr_accessor_with_client_reset(*attributes)
|
6
|
+
attr_reader *attributes
|
8
7
|
|
9
|
-
|
8
|
+
attributes.each do |attribute|
|
9
|
+
define_method "#{attribute}=" do |value|
|
10
|
+
instance_variable_set "@#{attribute}", value
|
11
|
+
@client = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_accessor_with_client_reset :api_key, :shared_secret,
|
17
|
+
:timeout, :open_timeout, :access_token, :access_secret
|
18
|
+
|
19
|
+
def client(access_token_hash = {})
|
10
20
|
@client ||= begin
|
11
21
|
client = Client.new(params) do |conn|
|
12
22
|
conn.request :oauth,
|
13
23
|
:consumer_key => api_key,
|
14
24
|
:consumer_secret => shared_secret,
|
15
|
-
:token => access_token,
|
16
|
-
:token_secret => access_secret
|
25
|
+
:token => access_token_hash[:token] || access_token,
|
26
|
+
:token_secret => access_token_hash[:secret] || access_secret
|
17
27
|
conn.response :json, :content_type => /(text\/plain)|(json)$/
|
18
28
|
conn.adapter Faraday.default_adapter
|
19
29
|
end
|
20
30
|
|
31
|
+
client.builder.insert_after FaradayMiddleware::ParseJson, OAuthStatusCheck
|
21
32
|
client.builder.insert_before FaradayMiddleware::ParseJson, StatusCheck
|
22
33
|
client
|
23
34
|
end
|
@@ -52,6 +63,15 @@ module Flickrie
|
|
52
63
|
end
|
53
64
|
end
|
54
65
|
|
66
|
+
class OAuthStatusCheck < Faraday::Response::Middleware
|
67
|
+
def on_complete(env)
|
68
|
+
if env[:status] != 200
|
69
|
+
message = env[:body][/(?<=oauth_problem=)[^&]+/]
|
70
|
+
raise Error, message.gsub('_', ' ').capitalize
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
55
75
|
class Client < Faraday::Connection
|
56
76
|
def get(method, params = {})
|
57
77
|
super() do |req|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Flickrie
|
2
|
+
class Instance
|
3
|
+
attr_reader :access_token, :access_secret
|
4
|
+
|
5
|
+
def initialize(access_token, access_secret)
|
6
|
+
@access_token, @access_secret = access_token, access_secret
|
7
|
+
end
|
8
|
+
|
9
|
+
def client
|
10
|
+
Flickrie.client(:token => access_token, :secret => access_secret)
|
11
|
+
end
|
12
|
+
|
13
|
+
include ApiMethods
|
14
|
+
end
|
15
|
+
end
|
data/lib/flickrie/version.rb
CHANGED
data/lib/flickrie.rb
CHANGED
@@ -1,117 +1,6 @@
|
|
1
|
-
require 'flickrie/
|
2
|
-
require 'flickrie/
|
3
|
-
require 'flickrie/license'
|
4
|
-
require 'flickrie/user'
|
5
|
-
require 'flickrie/media'
|
6
|
-
require 'flickrie/photo'
|
7
|
-
require 'flickrie/video'
|
8
|
-
require 'flickrie/set'
|
1
|
+
require 'flickrie/api_methods'
|
2
|
+
require 'flickrie/instance'
|
9
3
|
|
10
4
|
module Flickrie
|
11
|
-
|
12
|
-
# people
|
13
|
-
def find_user_by_email(email)
|
14
|
-
response = client.find_user_by_email(email)
|
15
|
-
User.from_find(response.body['user'])
|
16
|
-
end
|
17
|
-
|
18
|
-
def find_user_by_username(username)
|
19
|
-
response = client.find_user_by_username(username)
|
20
|
-
User.from_find(response.body['user'])
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_user_info(user_nsid)
|
24
|
-
response = client.get_user_info(user_nsid)
|
25
|
-
User.from_info(response.body['person'])
|
26
|
-
end
|
27
|
-
|
28
|
-
def public_media_from_user(user_nsid, params = {})
|
29
|
-
response = client.public_media_from_user(user_nsid, params)
|
30
|
-
Media.from_user(response.body['photos'])
|
31
|
-
end
|
32
|
-
def public_photos_from_user(user_nsid, params = {})
|
33
|
-
public_media_from_user(user_nsid, params).select do |media|
|
34
|
-
media.is_a?(Photo)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
def public_videos_from_user(user_nsid, params = {})
|
38
|
-
public_media_from_user(user_nsid, params).select do |media|
|
39
|
-
media.is_a?(Video)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# photos
|
44
|
-
def add_media_tags(media_id, tags)
|
45
|
-
client.add_media_tags(media_id, tags)
|
46
|
-
end
|
47
|
-
alias add_photo_tags add_media_tags
|
48
|
-
alias add_video_tags add_media_tags
|
49
|
-
|
50
|
-
def delete_media(media_id)
|
51
|
-
client.delete_media(media_id)
|
52
|
-
end
|
53
|
-
alias delete_photo delete_media
|
54
|
-
alias delete_video delete_media
|
55
|
-
|
56
|
-
def get_media_info(media_id)
|
57
|
-
response = client.get_media_info(media_id)
|
58
|
-
Media.from_info(response.body['photo'])
|
59
|
-
end
|
60
|
-
alias get_photo_info get_media_info
|
61
|
-
alias get_video_info get_media_info
|
62
|
-
|
63
|
-
def get_photo_sizes(photo_id)
|
64
|
-
response = client.get_media_sizes(photo_id)
|
65
|
-
Photo.from_sizes(response.body['sizes'])
|
66
|
-
end
|
67
|
-
def get_video_sizes(video_id)
|
68
|
-
response = client.get_media_sizes(video_id)
|
69
|
-
Video.from_sizes(response.body['sizes'])
|
70
|
-
end
|
71
|
-
|
72
|
-
def remove_media_tag(tag_id)
|
73
|
-
client.remove_media_tag(tag_id)
|
74
|
-
end
|
75
|
-
alias remove_photo_tag remove_media_tag
|
76
|
-
alias remove_video_tag remove_media_tag
|
77
|
-
|
78
|
-
def search_media(search_params = {})
|
79
|
-
response = client.search_media(search_params)
|
80
|
-
Media.from_search(response.body['photos'])
|
81
|
-
end
|
82
|
-
def search_photos(search_params = {})
|
83
|
-
search_media(search_params.merge(:media => 'photos'))
|
84
|
-
end
|
85
|
-
def search_videos(search_params = {})
|
86
|
-
search_media(search_params.merge(:media => 'videos'))
|
87
|
-
end
|
88
|
-
|
89
|
-
# licenses
|
90
|
-
def get_licenses
|
91
|
-
response = client.get_licenses
|
92
|
-
License.from_hash(response.body['licenses']['license'])
|
93
|
-
end
|
94
|
-
|
95
|
-
# photosets
|
96
|
-
def get_set_info(set_id)
|
97
|
-
response = client.get_set_info(set_id)
|
98
|
-
Set.from_info(response.body['photoset'])
|
99
|
-
end
|
100
|
-
|
101
|
-
def sets_from_user(user_nsid)
|
102
|
-
response = client.sets_from_user(user_nsid)
|
103
|
-
Set.from_user(response.body['photosets']['photoset'], user_nsid)
|
104
|
-
end
|
105
|
-
|
106
|
-
def media_from_set(set_id, params = {})
|
107
|
-
response = client.media_from_set(set_id, params)
|
108
|
-
Media.from_set(response.body['photoset'])
|
109
|
-
end
|
110
|
-
def photos_from_set(set_id, params = {})
|
111
|
-
media_from_set(set_id, params.merge(:media => 'photos'))
|
112
|
-
end
|
113
|
-
def videos_from_set(set_id, params = {})
|
114
|
-
media_from_set(set_id, params.merge(:media => 'videos'))
|
115
|
-
end
|
116
|
-
end
|
5
|
+
extend ApiMethods
|
117
6
|
end
|
data/test/client_test.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'test
|
2
|
+
require 'test'
|
3
3
|
require 'flickrie/client'
|
4
4
|
|
5
5
|
class ClientTest < Test::Unit::TestCase
|
6
6
|
def setup
|
7
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
8
7
|
@client = Flickrie.client
|
9
8
|
@set_id = 72157629851991663
|
10
9
|
@media_id = 7093038981
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'flickrie'
|
3
|
+
|
4
|
+
class InstanceTest < Test::Unit::TestCase
|
5
|
+
def test_if_it_works
|
6
|
+
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
7
|
+
Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
|
8
|
+
|
9
|
+
flickr = Flickrie::Instance.new \
|
10
|
+
ENV['FLICKR_ACCESS_TOKEN'], ENV['FLICKR_ACCESS_SECRET']
|
11
|
+
|
12
|
+
photo_id = 6946979188
|
13
|
+
flickr.add_photo_tags(photo_id, "janko")
|
14
|
+
photo = flickr.get_photo_info(photo_id)
|
15
|
+
|
16
|
+
tag = photo.tags.find { |tag| tag.content == "janko" }
|
17
|
+
assert_not_nil tag
|
18
|
+
|
19
|
+
flickr.remove_photo_tag tag.id
|
20
|
+
end
|
21
|
+
end
|
data/test/license_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test
|
1
|
+
require 'test'
|
2
2
|
require 'flickrie'
|
3
3
|
|
4
4
|
Flickrie::License.instance_eval do
|
@@ -8,10 +8,6 @@ Flickrie::License.instance_eval do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class LicenseTest < Test::Unit::TestCase
|
11
|
-
def setup
|
12
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
13
|
-
end
|
14
|
-
|
15
11
|
def test_licenses_staying_the_same
|
16
12
|
licenses_array = Flickrie.client.get_licenses.body['licenses']['license']
|
17
13
|
assert_equal licenses_array.sort_by { |hash| hash['id'] },
|
data/test/location_test.rb
CHANGED
data/test/media_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'test
|
2
|
+
require 'test'
|
3
3
|
require 'flickrie'
|
4
4
|
|
5
5
|
Flickrie::Photo.instance_eval do
|
@@ -10,10 +10,6 @@ end
|
|
10
10
|
|
11
11
|
class MediaTest < Test::Unit::TestCase
|
12
12
|
def setup
|
13
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
|
-
Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
|
15
|
-
Flickrie.access_token = ENV['FLICKR_ACCESS_TOKEN']
|
16
|
-
Flickrie.access_secret = ENV['FLICKR_ACCESS_SECRET']
|
17
13
|
@media_id = 6946979188
|
18
14
|
@set_id = 72157629851991663
|
19
15
|
@user_nsid = '67131352@N04'
|
data/test/photo_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'test
|
2
|
+
require 'test'
|
3
3
|
require 'flickrie'
|
4
4
|
|
5
5
|
Flickrie::Photo.instance_eval do
|
@@ -10,7 +10,6 @@ end
|
|
10
10
|
|
11
11
|
class PhotoTest < Test::Unit::TestCase
|
12
12
|
def setup
|
13
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
13
|
@photo_id = 6946979188
|
15
14
|
@set_id = 72157629851991663
|
16
15
|
@user_nsid = '67131352@N04'
|
@@ -43,8 +42,8 @@ class PhotoTest < Test::Unit::TestCase
|
|
43
42
|
|
44
43
|
def get_sizes_assertions(photo)
|
45
44
|
assert_equal true, photo.can_download?
|
46
|
-
assert_equal
|
47
|
-
assert_equal
|
45
|
+
assert_equal true, photo.can_blog?
|
46
|
+
assert_equal true, photo.can_print?
|
48
47
|
|
49
48
|
assert_sizes(photo)
|
50
49
|
end
|
data/test/set_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'test
|
2
|
+
require 'test'
|
3
3
|
require 'flickrie'
|
4
4
|
|
5
5
|
Flickrie::Set.instance_eval do
|
@@ -10,7 +10,6 @@ end
|
|
10
10
|
|
11
11
|
class SetTest < Test::Unit::TestCase
|
12
12
|
def setup
|
13
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
13
|
@set_id = 72157629851991663
|
15
14
|
@user_nsid = '67131352@N04'
|
16
15
|
end
|
@@ -41,7 +40,7 @@ class SetTest < Test::Unit::TestCase
|
|
41
40
|
assert set.media.find { |media| media.is_a?(Flickrie::Photo) }
|
42
41
|
assert set.media.find { |media| media.is_a?(Flickrie::Video) }
|
43
42
|
|
44
|
-
assert_equal
|
43
|
+
assert_equal true, set.can_comment?
|
45
44
|
|
46
45
|
assert_instance_of Time, set.created_at
|
47
46
|
assert_instance_of Time, set.updated_at
|
@@ -73,7 +72,7 @@ class SetTest < Test::Unit::TestCase
|
|
73
72
|
assert set.media.find { |media| media.is_a?(Flickrie::Photo) }
|
74
73
|
assert set.media.find { |media| media.is_a?(Flickrie::Video) }
|
75
74
|
|
76
|
-
assert_equal
|
75
|
+
assert_equal true, set.can_comment?
|
77
76
|
assert_equal false, set.needs_interstitial?
|
78
77
|
assert_equal true, set.visibility_can_see_set?
|
79
78
|
|
data/test/test.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'flickrie/client'
|
3
|
+
|
4
|
+
Flickrie.timeout = 20
|
5
|
+
Flickrie.open_timeout = 20
|
6
|
+
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
7
|
+
Flickrie.shared_secret = ENV['FLICKR_SHARED_SECRET']
|
8
|
+
Flickrie.access_token = ENV['FLICKR_ACCESS_TOKEN']
|
9
|
+
Flickrie.access_secret = ENV['FLICKR_ACCESS_SECRET']
|
data/test/user_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'test
|
2
|
+
require 'test'
|
3
3
|
require 'flickrie'
|
4
4
|
|
5
5
|
Flickrie::User.instance_eval do
|
@@ -10,7 +10,6 @@ end
|
|
10
10
|
|
11
11
|
class UserTest < Test::Unit::TestCase
|
12
12
|
def setup
|
13
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
13
|
@user_nsid = '67131352@N04'
|
15
14
|
end
|
16
15
|
|
data/test/video_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'test
|
2
|
+
require 'test'
|
3
3
|
require 'flickrie'
|
4
4
|
|
5
5
|
Flickrie::Video.instance_eval do
|
@@ -10,7 +10,6 @@ end
|
|
10
10
|
|
11
11
|
class VideoTest < Test::Unit::TestCase
|
12
12
|
def setup
|
13
|
-
Flickrie.api_key = ENV['FLICKR_API_KEY']
|
14
13
|
@video_id = 7093038981
|
15
14
|
@set_id = 72157629851991663
|
16
15
|
@user_nsid = '67131352@N04'
|
@@ -45,8 +44,8 @@ class VideoTest < Test::Unit::TestCase
|
|
45
44
|
|
46
45
|
def get_sizes_assertions(video)
|
47
46
|
assert_equal true, video.can_download?
|
48
|
-
assert_equal
|
49
|
-
assert_equal
|
47
|
+
assert_equal true, video.can_blog?
|
48
|
+
assert_equal true, video.can_print?
|
50
49
|
|
51
50
|
refute video.source_url.empty?
|
52
51
|
refute video.download_url.empty?
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
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: &70199659891200 !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: *70199659891200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simple_oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &70199659890040 !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: *70199659890040
|
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
|
@@ -47,7 +47,9 @@ files:
|
|
47
47
|
- Rakefile
|
48
48
|
- flickrie.gemspec
|
49
49
|
- lib/flickrie.rb
|
50
|
+
- lib/flickrie/api_methods.rb
|
50
51
|
- lib/flickrie/client.rb
|
52
|
+
- lib/flickrie/instance.rb
|
51
53
|
- lib/flickrie/license.rb
|
52
54
|
- lib/flickrie/location.rb
|
53
55
|
- lib/flickrie/media.rb
|
@@ -61,12 +63,14 @@ files:
|
|
61
63
|
- lib/flickrie/version.rb
|
62
64
|
- lib/flickrie/video.rb
|
63
65
|
- test/client_test.rb
|
66
|
+
- test/instance_test.rb
|
64
67
|
- test/license_test.rb
|
65
68
|
- test/location_test.rb
|
66
69
|
- test/media_test.rb
|
67
70
|
- test/oauth_test.rb
|
68
71
|
- test/photo_test.rb
|
69
72
|
- test/set_test.rb
|
73
|
+
- test/test.rb
|
70
74
|
- test/user_test.rb
|
71
75
|
- test/video_test.rb
|
72
76
|
homepage: https://github.com/janko-m/flickrie
|
@@ -98,12 +102,14 @@ summary: The reason why I did this gem is because the other ones either weren't
|
|
98
102
|
a while you realize it's not pretty. So I wanted to make it pretty :)
|
99
103
|
test_files:
|
100
104
|
- test/client_test.rb
|
105
|
+
- test/instance_test.rb
|
101
106
|
- test/license_test.rb
|
102
107
|
- test/location_test.rb
|
103
108
|
- test/media_test.rb
|
104
109
|
- test/oauth_test.rb
|
105
110
|
- test/photo_test.rb
|
106
111
|
- test/set_test.rb
|
112
|
+
- test/test.rb
|
107
113
|
- test/user_test.rb
|
108
114
|
- test/video_test.rb
|
109
115
|
has_rdoc:
|