flickrie 0.6.1 → 0.7.0
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/.gitignore +1 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +0 -6
- data/README.md +15 -1
- data/Rakefile +8 -13
- data/api_methods.md +1 -1
- data/flickrie.gemspec +2 -3
- data/lib/flickrie/api_methods.rb +17 -0
- data/lib/flickrie/client.rb +21 -5
- data/lib/flickrie/instance.rb +7 -2
- data/lib/flickrie/license.rb +2 -0
- data/lib/flickrie/location.rb +10 -8
- data/lib/flickrie/media/exif.rb +3 -1
- data/lib/flickrie/media/tag.rb +3 -3
- data/lib/flickrie/media/visibility.rb +6 -4
- data/lib/flickrie/media.rb +69 -84
- data/lib/flickrie/media_count.rb +3 -5
- data/lib/flickrie/photo.rb +55 -54
- data/lib/flickrie/set.rb +31 -25
- data/lib/flickrie/ticket.rb +4 -8
- data/lib/flickrie/upload_client.rb +7 -2
- data/lib/flickrie/user.rb +33 -34
- data/lib/flickrie/version.rb +1 -1
- data/lib/flickrie/video.rb +13 -12
- data/spec/api_methods_spec.rb +43 -0
- data/spec/error_spec.rb +32 -0
- data/{test → spec/files}/photo.jpg +0 -0
- data/{test → spec/files}/video.mov +0 -0
- data/spec/instance_spec.rb +22 -0
- data/spec/license_spec.rb +15 -0
- data/spec/location_spec.rb +11 -0
- data/spec/media_count_spec.rb +18 -0
- data/spec/media_spec.rb +271 -0
- data/spec/oauth_spec.rb +22 -0
- data/spec/photo_spec.rb +137 -0
- data/spec/set_spec.rb +68 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/user_spec.rb +56 -0
- data/spec/video_spec.rb +54 -0
- metadata +47 -132
- data/test/error_test.rb +0 -20
- data/test/instance_test.rb +0 -20
- data/test/license_test.rb +0 -19
- data/test/location_test.rb +0 -29
- data/test/media_count_test.rb +0 -25
- data/test/media_test.rb +0 -432
- data/test/oauth_test.rb +0 -25
- data/test/photo_test.rb +0 -212
- data/test/set_test.rb +0 -92
- data/test/test_helper.rb +0 -14
- data/test/user_test.rb +0 -70
- data/test/vcr_cassettes/error/code.yml +0 -1165
- data/test/vcr_cassettes/instance/calling_api_methods.yml +0 -182
- data/test/vcr_cassettes/license/get_licenses.yml +0 -73
- data/test/vcr_cassettes/location/square_brackets.yml +0 -85
- data/test/vcr_cassettes/media/delete.yml +0 -1380
- data/test/vcr_cassettes/media/from_contacts.yml +0 -155
- data/test/vcr_cassettes/media/from_set.yml +0 -276
- data/test/vcr_cassettes/media/from_user.yml +0 -275
- data/test/vcr_cassettes/media/get_context.yml +0 -73
- data/test/vcr_cassettes/media/get_info.yml +0 -167
- data/test/vcr_cassettes/media/remove_tag.yml +0 -264
- data/test/vcr_cassettes/media/replace.yml +0 -2252
- data/test/vcr_cassettes/media/search.yml +0 -275
- data/test/vcr_cassettes/media/tags.yml +0 -346
- data/test/vcr_cassettes/media_count/get.yml +0 -135
- data/test/vcr_cassettes/media_count/square_brackets.yml +0 -69
- data/test/vcr_cassettes/oauth/tokens.yml +0 -400
- data/test/vcr_cassettes/photo/asynchronous_upload.yml +0 -1693
- data/test/vcr_cassettes/photo/from_set.yml +0 -273
- data/test/vcr_cassettes/photo/from_user.yml +0 -275
- data/test/vcr_cassettes/photo/get_exif.yml +0 -239
- data/test/vcr_cassettes/photo/get_sizes.yml +0 -147
- data/test/vcr_cassettes/photo/other_api_calls.yml +0 -506
- data/test/vcr_cassettes/photo/search.yml +0 -271
- data/test/vcr_cassettes/photo/square_brackets.yml +0 -85
- data/test/vcr_cassettes/photo/upload.yml +0 -1229
- data/test/vcr_cassettes/set/from_user.yml +0 -477
- data/test/vcr_cassettes/set/get_info.yml +0 -951
- data/test/vcr_cassettes/set/square_brackets.yml +0 -73
- data/test/vcr_cassettes/user/find_by_email_or_username.yml +0 -135
- data/test/vcr_cassettes/user/get_info.yml +0 -151
- data/test/vcr_cassettes/user/square_brackets.yml +0 -77
- data/test/vcr_cassettes/video/get_exif.yml +0 -135
- data/test/vcr_cassettes/video/get_info.yml +0 -86
- data/test/vcr_cassettes/video/get_sizes.yml +0 -151
- data/test/vcr_cassettes/video/other_api_calls.yml +0 -643
- data/test/vcr_cassettes/video/square_brackets.yml +0 -86
- data/test/vcr_cassettes/video/upload.yml +0 -308
- data/test/video_test.rb +0 -118
data/lib/flickrie/photo.rb
CHANGED
@@ -6,8 +6,8 @@ module Flickrie
|
|
6
6
|
|
7
7
|
SIZES = {
|
8
8
|
'Square 75' => 'sq',
|
9
|
-
'Square 150' => 'q',
|
10
9
|
'Thumbnail' => 't',
|
10
|
+
'Square 150' => 'q',
|
11
11
|
'Small 240' => 's',
|
12
12
|
'Small 320' => 'n',
|
13
13
|
'Medium 500' => 'm',
|
@@ -17,68 +17,70 @@ module Flickrie
|
|
17
17
|
'Original' => 'o'
|
18
18
|
}
|
19
19
|
|
20
|
-
def square!(number)
|
21
|
-
def thumbnail
|
22
|
-
def small!(number)
|
23
|
-
def medium!(number)
|
24
|
-
def large!(number)
|
25
|
-
def original
|
26
|
-
|
27
|
-
def square(number)
|
28
|
-
def thumbnail
|
29
|
-
def small(number)
|
30
|
-
def medium(number)
|
31
|
-
def large(number)
|
32
|
-
def original
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
def
|
52
|
-
|
20
|
+
def square!(number) @size = "Square #{number}"; self end
|
21
|
+
def thumbnail!() @size = "Thumbnail"; self end
|
22
|
+
def small!(number) @size = "Small #{number}"; self end
|
23
|
+
def medium!(number) @size = "Medium #{number}"; self end
|
24
|
+
def large!(number) @size = "Large #{number}"; self end
|
25
|
+
def original!() @size = "Original"; self end
|
26
|
+
|
27
|
+
def square(number) dup.square!(number) end
|
28
|
+
def thumbnail() dup.thumbnail! end
|
29
|
+
def small(number) dup.small!(number) end
|
30
|
+
def medium(number) dup.medium!(number) end
|
31
|
+
def large(number) dup.large!(number) end
|
32
|
+
def original() dup.original! end
|
33
|
+
|
34
|
+
#--
|
35
|
+
# Alternate size methods
|
36
|
+
def square75() square(75) end
|
37
|
+
def square75!() square!(75) end
|
38
|
+
def square150() square(150) end
|
39
|
+
def square150!() square!(150) end
|
40
|
+
def small240() small(240) end
|
41
|
+
def small240!() small!(240) end
|
42
|
+
def small320() small(320) end
|
43
|
+
def small320!() small!(320) end
|
44
|
+
def medium500() medium(500) end
|
45
|
+
def medium500!() medium!(500) end
|
46
|
+
def medium640() medium(640) end
|
47
|
+
def medium640!() medium!(640) end
|
48
|
+
def medium800() medium(800) end
|
49
|
+
def medium800!() medium!(800) end
|
50
|
+
def large1024() large(1024) end
|
51
|
+
def large1024!() large!(1024) end
|
52
|
+
|
53
|
+
def largest!() @size = largest_size; self end
|
54
|
+
def largest() dup.largest! end
|
53
55
|
|
54
56
|
def available_sizes
|
55
|
-
SIZES.select { |_,
|
57
|
+
SIZES.select { |_,v| @info["url_#{v}"] }.keys
|
56
58
|
end
|
57
59
|
|
58
|
-
def width
|
59
|
-
def height
|
60
|
-
|
61
|
-
def source_url; @info["url_#{size_abbr}"] end
|
60
|
+
def width() Integer(@info["width_#{size_abbr}"]) rescue nil end
|
61
|
+
def height() Integer(@info["height_#{size_abbr}"]) rescue nil end
|
62
|
+
def source_url() @info["url_#{size_abbr}"] end
|
62
63
|
|
63
|
-
def rotation
|
64
|
+
def rotation() Integer(@info['rotation']) rescue nil end
|
64
65
|
|
65
|
-
def get_sizes(info = nil)
|
66
|
-
info ||= Flickrie.client.get_media_sizes(id).body['sizes']
|
66
|
+
def get_sizes(params = {}, info = nil)
|
67
|
+
info ||= Flickrie.client.get_media_sizes(id, params).body['sizes']
|
68
|
+
@info['usage'] ||= {}
|
67
69
|
@info['usage'].update \
|
68
70
|
'canblog' => info['canblog'],
|
69
71
|
'canprint' => info['canprint'],
|
70
72
|
'candownload' => info['candownload']
|
71
73
|
flickr_sizes = {
|
72
|
-
'Square'
|
73
|
-
'Large Square' => '
|
74
|
-
'Thumbnail'
|
75
|
-
'Small'
|
76
|
-
'Small 320'
|
77
|
-
'Medium'
|
78
|
-
'Medium 640'
|
79
|
-
'Medium 800'
|
80
|
-
'Large'
|
81
|
-
'Original'
|
74
|
+
'Square' => SIZES['Square 75'],
|
75
|
+
'Large Square' => SIZES['Square 150'],
|
76
|
+
'Thumbnail' => SIZES['Thumbnail'],
|
77
|
+
'Small' => SIZES['Small 240'],
|
78
|
+
'Small 320' => SIZES['Small 320'],
|
79
|
+
'Medium' => SIZES['Medium 500'],
|
80
|
+
'Medium 640' => SIZES['Medium 640'],
|
81
|
+
'Medium 800' => SIZES['Medium 800'],
|
82
|
+
'Large' => SIZES['Large 1024'],
|
83
|
+
'Original' => SIZES['Original']
|
82
84
|
}
|
83
85
|
info['size'].each do |size_info|
|
84
86
|
size_abbr = flickr_sizes[size_info['label']]
|
@@ -87,8 +89,7 @@ module Flickrie
|
|
87
89
|
@info["url_#{size_abbr}"] = size_info['source']
|
88
90
|
end
|
89
91
|
|
90
|
-
|
91
|
-
self
|
92
|
+
largest!
|
92
93
|
end
|
93
94
|
|
94
95
|
private
|
data/lib/flickrie/set.rb
CHANGED
@@ -1,39 +1,43 @@
|
|
1
1
|
module Flickrie
|
2
2
|
class Set
|
3
|
-
def id
|
4
|
-
def secret
|
5
|
-
def server
|
6
|
-
def farm
|
7
|
-
def title
|
8
|
-
def description
|
9
|
-
|
10
|
-
def primary_media_id
|
3
|
+
def id() @info['id'] end
|
4
|
+
def secret() @info['secret'] end
|
5
|
+
def server() @info['server'] end
|
6
|
+
def farm() @info['farm'] end
|
7
|
+
def title() @info['title'] end
|
8
|
+
def description() @info['description'] end
|
9
|
+
|
10
|
+
def primary_media_id() @info['primary'] end
|
11
11
|
alias primary_photo_id primary_media_id
|
12
12
|
alias primary_video_id primary_media_id
|
13
13
|
|
14
|
-
def views_count
|
15
|
-
def comments_count
|
16
|
-
def photos_count
|
17
|
-
def videos_count
|
18
|
-
def media_count
|
14
|
+
def views_count() Integer(@info['count_views']) rescue nil end
|
15
|
+
def comments_count() Integer(@info['count_comments']) rescue nil end
|
16
|
+
def photos_count() Integer(@info['count_photos']) rescue nil end
|
17
|
+
def videos_count() Integer(@info['count_videos']) rescue nil end
|
18
|
+
def media_count
|
19
|
+
photos_count + videos_count rescue nil
|
20
|
+
end
|
19
21
|
|
20
|
-
def owner
|
22
|
+
def owner() User.new('nsid' => @info['owner']) if @info['owner'] end
|
21
23
|
|
22
|
-
def photos(params = {})
|
23
|
-
def videos(params = {})
|
24
|
-
def media(params = {})
|
24
|
+
def photos(params = {}) Flickrie.photos_from_set(id, params) end
|
25
|
+
def videos(params = {}) Flickrie.videos_from_set(id, params) end
|
26
|
+
def media(params = {}) Flickrie.media_from_set(id, params) end
|
25
27
|
|
26
|
-
def can_comment
|
28
|
+
def can_comment?() Integer(@info['can_comment']) == 1 rescue nil end
|
27
29
|
|
28
30
|
#--
|
29
31
|
# TODO: Figure out what this is
|
30
|
-
def needs_interstitial
|
31
|
-
def visibility_can_see_set
|
32
|
+
def needs_interstitial?() Integer(@info['needs_interstitial']) == 1 rescue nil end
|
33
|
+
def visibility_can_see_set?() Integer(@info['visibility_can_see_set']) == 1 rescue nil end
|
32
34
|
|
33
|
-
def created_at
|
34
|
-
def updated_at
|
35
|
+
def created_at() Time.at(Integer(@info['date_create'])) rescue nil end
|
36
|
+
def updated_at() Time.at(Integer(@info['date_update'])) rescue nil end
|
35
37
|
|
36
|
-
def url
|
38
|
+
def url
|
39
|
+
"http://www.flickr.com/photos/#{owner.nsid}/sets/#{id}"
|
40
|
+
end
|
37
41
|
|
38
42
|
def [](key)
|
39
43
|
@info[key]
|
@@ -41,10 +45,12 @@ module Flickrie
|
|
41
45
|
|
42
46
|
def get_info(info = nil)
|
43
47
|
info ||= Flickrie.client.get_set_info(id).body['photoset']
|
44
|
-
info['title'] = info['title']['_content']
|
45
|
-
info['description'] = info['description']['_content']
|
46
48
|
@info.update(info)
|
47
49
|
|
50
|
+
# Fixes
|
51
|
+
@info['title'] = @info['title']['_content']
|
52
|
+
@info['description'] = @info['description']['_content']
|
53
|
+
|
48
54
|
self
|
49
55
|
end
|
50
56
|
|
data/lib/flickrie/ticket.rb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
module Flickrie
|
2
2
|
class Ticket
|
3
|
-
def id
|
4
|
-
def media_id
|
3
|
+
def id() @info['id'] end
|
4
|
+
def media_id() @info['photoid'] end
|
5
5
|
alias photo_id media_id
|
6
6
|
alias video_id media_id
|
7
7
|
|
8
|
-
def complete?
|
9
|
-
@info['complete'].to_i == 1
|
10
|
-
end
|
8
|
+
def complete?() Integer(@info['complete']) == 1 rescue nil end
|
11
9
|
|
12
|
-
def imported_at
|
13
|
-
Time.at(@info['imported'].to_i)
|
14
|
-
end
|
10
|
+
def imported_at() Time.at(Integer(@info['imported'])) rescue nil end
|
15
11
|
|
16
12
|
def [](key)
|
17
13
|
@info[key]
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module Flickrie
|
2
2
|
class << self
|
3
|
-
def upload_client
|
4
|
-
@upload_client ||=
|
3
|
+
def upload_client
|
4
|
+
@upload_client ||= new_upload_client
|
5
|
+
end
|
6
|
+
|
7
|
+
def new_upload_client(access_token_hash = {})
|
8
|
+
UploadClient.new(upload_params) do |conn|
|
5
9
|
conn.use FaradayMiddleware::OAuth,
|
6
10
|
:consumer_key => api_key,
|
7
11
|
:consumer_secret => shared_secret,
|
@@ -11,6 +15,7 @@ module Flickrie
|
|
11
15
|
|
12
16
|
conn.use UploadStatusCheck
|
13
17
|
conn.use FaradayMiddleware::ParseXml
|
18
|
+
conn.use OAuthStatusCheck
|
14
19
|
|
15
20
|
conn.adapter Faraday.default_adapter
|
16
21
|
end
|
data/lib/flickrie/user.rb
CHANGED
@@ -2,19 +2,19 @@ require 'date'
|
|
2
2
|
|
3
3
|
module Flickrie
|
4
4
|
class User
|
5
|
-
def id
|
6
|
-
def nsid
|
7
|
-
def username
|
8
|
-
def real_name
|
9
|
-
def location
|
10
|
-
def time_zone
|
11
|
-
def description
|
12
|
-
def profile_url
|
13
|
-
def mobile_url
|
14
|
-
def photos_url
|
15
|
-
def path_alias
|
16
|
-
def icon_server
|
17
|
-
def icon_farm
|
5
|
+
def id() @info['id'] end
|
6
|
+
def nsid() @info['nsid'] end
|
7
|
+
def username() @info['username'] end
|
8
|
+
def real_name() @info['realname'] end
|
9
|
+
def location() @info['location'] end
|
10
|
+
def time_zone() @info['timezone'] end
|
11
|
+
def description() @info['description'] end
|
12
|
+
def profile_url() @info['profileurl'] end
|
13
|
+
def mobile_url() @info['mobileurl'] end
|
14
|
+
def photos_url() @info['photosurl'] end
|
15
|
+
def path_alias() @info['path_alias'] end
|
16
|
+
def icon_server() @info['iconserver'] end
|
17
|
+
def icon_farm() @info['iconfarm'] end
|
18
18
|
|
19
19
|
def buddy_icon_url
|
20
20
|
if icon_farm
|
@@ -26,36 +26,29 @@ module Flickrie
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def first_taken
|
30
|
-
|
31
|
-
DateTime.parse(@info['photos']['firstdatetaken']).to_time
|
32
|
-
end
|
33
|
-
end
|
29
|
+
def first_taken() DateTime.parse(@info['photos']['firstdatetaken']).to_time rescue nil end
|
30
|
+
def first_uploaded() Time.at(Integer(@info['photos']['firstdate'])) rescue nil end
|
34
31
|
|
35
|
-
def
|
36
|
-
if @info['photos'] and @info['photos']['firstdate']
|
37
|
-
Time.at(@info['photos']['firstdate'].to_i)
|
38
|
-
end
|
39
|
-
end
|
32
|
+
def favorited_at() Time.at(Integer(@info['favedate'])) rescue nil end
|
40
33
|
|
41
|
-
def
|
42
|
-
|
43
|
-
@info['photos']['count'].to_i
|
44
|
-
end
|
34
|
+
def favorited_at
|
35
|
+
Time.at(@info['favedate'].to_i)
|
45
36
|
end
|
46
37
|
|
47
|
-
def
|
38
|
+
def media_count() Integer(@info['photos']['count']) rescue nil end
|
39
|
+
alias photos_count media_count
|
40
|
+
alias videos_count media_count
|
48
41
|
|
49
|
-
def
|
50
|
-
|
51
|
-
end
|
42
|
+
def public_photos() Flickrie.public_photos_from_user(nsid) end
|
43
|
+
|
44
|
+
def pro?() Integer(@info['ispro']) == 1 rescue nil end
|
52
45
|
|
53
46
|
def [](key)
|
54
47
|
@info[key]
|
55
48
|
end
|
56
49
|
|
57
|
-
def get_info(info = nil)
|
58
|
-
info ||= Flickrie.client.get_user_info(nsid).body['person']
|
50
|
+
def get_info(params = {}, info = nil)
|
51
|
+
info ||= Flickrie.client.get_user_info(nsid, params).body['person']
|
59
52
|
@info.update(info)
|
60
53
|
|
61
54
|
%w[username realname location description profileurl
|
@@ -72,16 +65,22 @@ module Flickrie
|
|
72
65
|
private
|
73
66
|
|
74
67
|
def initialize(info = {})
|
68
|
+
raise ArgumentError if info.nil?
|
69
|
+
|
75
70
|
@info = info
|
76
71
|
end
|
77
72
|
|
78
73
|
def self.from_info(info)
|
79
|
-
new.get_info(info)
|
74
|
+
new.get_info({}, info)
|
80
75
|
end
|
81
76
|
|
82
77
|
def self.from_find(info)
|
83
78
|
info['username'] = info['username']['_content']
|
84
79
|
new(info)
|
85
80
|
end
|
81
|
+
|
82
|
+
def self.from_test(info)
|
83
|
+
from_find(info)
|
84
|
+
end
|
86
85
|
end
|
87
86
|
end
|
data/lib/flickrie/version.rb
CHANGED
data/lib/flickrie/video.rb
CHANGED
@@ -2,21 +2,22 @@ module Flickrie
|
|
2
2
|
class Video
|
3
3
|
include Media
|
4
4
|
|
5
|
-
def ready
|
6
|
-
def failed
|
7
|
-
def pending
|
5
|
+
def ready?() Integer(@video['ready']) == 1 rescue nil end
|
6
|
+
def failed?() Integer(@video['failed']) == 1 rescue nil end
|
7
|
+
def pending?() Integer(@video['pending']) == 1 rescue nil end
|
8
8
|
|
9
|
-
def duration
|
9
|
+
def duration() Integer(@video['duration']) rescue nil end
|
10
10
|
|
11
|
-
def width
|
12
|
-
def height
|
11
|
+
def width() Integer(@video['width']) rescue nil end
|
12
|
+
def height() Integer(@video['height']) rescue nil end
|
13
13
|
|
14
|
-
def source_url
|
15
|
-
def download_url
|
16
|
-
def mobile_download_url
|
14
|
+
def source_url() @video['source_url'] end
|
15
|
+
def download_url() @video['download_url'] end
|
16
|
+
def mobile_download_url() @video['mobile_download_url'] end
|
17
17
|
|
18
|
-
def get_sizes(info = nil)
|
19
|
-
info ||= Flickrie.client.get_media_sizes(id).body['sizes']
|
18
|
+
def get_sizes(params = {}, info = nil)
|
19
|
+
info ||= Flickrie.client.get_media_sizes(id, params).body['sizes']
|
20
|
+
@info['usage'] ||= {}
|
20
21
|
@info['usage'].update \
|
21
22
|
'canblog' => info['canblog'],
|
22
23
|
'canprint' => info['canprint'],
|
@@ -32,7 +33,7 @@ module Flickrie
|
|
32
33
|
self
|
33
34
|
end
|
34
35
|
|
35
|
-
def get_info(info = nil)
|
36
|
+
def get_info(params = {}, info = nil)
|
36
37
|
super
|
37
38
|
@video = @info['video']
|
38
39
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
describe Flickrie::ApiMethods do
|
2
|
+
it "should have certain methods working" do
|
3
|
+
VCR.use_cassette "api_methods/upload_and_delete" do
|
4
|
+
media_id = @flickrie.upload(PHOTO_PATH)
|
5
|
+
@flickrie.public_media_from_user(USER_NSID).map(&:id).should include(media_id)
|
6
|
+
@flickrie.delete_media(media_id)
|
7
|
+
@flickrie.public_media_from_user(USER_NSID).map(&:id).should_not include(media_id)
|
8
|
+
end
|
9
|
+
|
10
|
+
VCR.use_cassette "api_methods/asynchronous_upload" do
|
11
|
+
ticket_id = @flickrie.upload(PHOTO_PATH, :async => 1)
|
12
|
+
begin
|
13
|
+
ticket = @flickrie.check_upload_tickets([ticket_id]).first
|
14
|
+
end until ticket.complete?
|
15
|
+
photo_id = ticket.photo_id
|
16
|
+
Flickrie.get_photo_info(photo_id).id.should eq(photo_id)
|
17
|
+
@flickrie.delete_photo(photo_id)
|
18
|
+
end
|
19
|
+
|
20
|
+
VCR.use_cassette "api_methods/replace" do
|
21
|
+
begin
|
22
|
+
id = @flickrie.upload(PHOTO_PATH)
|
23
|
+
@flickrie.replace(PHOTO_PATH, id)
|
24
|
+
rescue => exception
|
25
|
+
exception.code.should eq(1) # Not a pro account
|
26
|
+
ensure
|
27
|
+
@flickrie.delete_media(id)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
VCR.use_cassette "api_methods/tags" do
|
32
|
+
media = @flickrie.get_media_info(PHOTO_ID)
|
33
|
+
tags_before_change = media.tags.join(' ')
|
34
|
+
@flickrie.add_media_tags(PHOTO_ID, "janko")
|
35
|
+
media.get_info
|
36
|
+
media.tags.join(' ').should eq([tags_before_change, "janko"].join(' '))
|
37
|
+
tag_id = media.tags.find { |tag| tag.content == "janko" }.id
|
38
|
+
@flickrie.remove_media_tag(tag_id)
|
39
|
+
media.get_info
|
40
|
+
media.tags.join(' ').should eq(tags_before_change)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/error_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
describe Flickrie::Error do
|
2
|
+
before(:all) do
|
3
|
+
Flickrie.api_key = nil
|
4
|
+
end
|
5
|
+
|
6
|
+
context "was raised" do
|
7
|
+
use_vcr_cassette "error/was_raised"
|
8
|
+
|
9
|
+
it "should be raised when the request failed" do
|
10
|
+
expect { Flickrie.get_licenses }.to raise_error(described_class)
|
11
|
+
expect { Flickrie.upload(PHOTO_PATH) }.to raise_error(described_class)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "code" do
|
16
|
+
use_vcr_cassette "error/code"
|
17
|
+
|
18
|
+
it "should have #code attribute present" do
|
19
|
+
begin
|
20
|
+
Flickrie.get_licenses
|
21
|
+
rescue => exception
|
22
|
+
exception.code.should eq(100)
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
Flickrie.upload(PHOTO_PATH)
|
27
|
+
rescue => exception
|
28
|
+
exception.code.should eq(100)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
describe Flickrie::Instance do
|
3
|
+
context "calling api methods" do
|
4
|
+
use_vcr_cassette "instance/calling_api_methods"
|
5
|
+
|
6
|
+
it "should be able to call API methods" do
|
7
|
+
# this is to see if the client and upload_client were reset
|
8
|
+
Flickrie.get_photo_info(PHOTO_ID)
|
9
|
+
Flickrie.access_token = ENV['FLICKR_ACCESS_TOKEN']
|
10
|
+
Flickrie.access_secret = ENV['FLICKR_ACCESS_SECRET']
|
11
|
+
id = Flickrie.upload(PHOTO_PATH)
|
12
|
+
Flickrie.delete_photo(id)
|
13
|
+
Flickrie.access_token = Flickrie.access_secret = nil
|
14
|
+
|
15
|
+
instance = Flickrie::Instance.new(ENV['FLICKR_ACCESS_TOKEN'], ENV['FLICKR_ACCESS_SECRET'])
|
16
|
+
user = instance.test_login
|
17
|
+
user.username.should eq("Janko Marohnić")
|
18
|
+
id = instance.upload(PHOTO_PATH)
|
19
|
+
instance.delete_photo(id)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Flickrie::License do
|
2
|
+
context "get licenses" do
|
3
|
+
use_vcr_cassette "license/get"
|
4
|
+
|
5
|
+
it "should have all attributes correctly set" do
|
6
|
+
licenses = Flickrie.get_licenses
|
7
|
+
|
8
|
+
licenses.each do |license|
|
9
|
+
('0'..'8').should cover(license.id)
|
10
|
+
license.name.should be_an_instance_of(String)
|
11
|
+
license.url.should be_an_instance_of(String)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
describe Flickrie::Location do
|
2
|
+
context "blank" do
|
3
|
+
it "should have all attributes equal to nil" do
|
4
|
+
location = Flickrie::Location.public_new
|
5
|
+
attributes = location.methods - Object.instance_methods - [:[]]
|
6
|
+
attributes.each do |attribute|
|
7
|
+
location.send(attribute).should be_nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe Flickrie::MediaCount do
|
2
|
+
context "get" do
|
3
|
+
use_vcr_cassette "media_count/get"
|
4
|
+
|
5
|
+
it "should have correctly set all attributes" do
|
6
|
+
dates = [DateTime.parse("1st March 2012"), DateTime.parse("5th May 2012")].map(&:to_time)
|
7
|
+
[
|
8
|
+
@flickrie.get_media_counts(:taken_dates => dates.join(',')).first,
|
9
|
+
@flickrie.get_media_counts(:dates => dates.map(&:to_i).join(',')).first
|
10
|
+
].
|
11
|
+
each do |count|
|
12
|
+
count.value.should be_an_instance_of(Fixnum)
|
13
|
+
count.date_range.begin.should eq(dates.first)
|
14
|
+
count.date_range.end.should eq(dates.last)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|