flickrie 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +0 -4
- data/flickrie.gemspec +2 -2
- data/lib/flickrie/api_methods.rb +4 -1
- data/lib/flickrie/license.rb +6 -1
- data/lib/flickrie/location.rb +29 -12
- data/lib/flickrie/media/exif.rb +3 -1
- data/lib/flickrie/media/note.rb +24 -13
- data/lib/flickrie/media/tag.rb +9 -6
- data/lib/flickrie/media/visibility.rb +8 -5
- data/lib/flickrie/media.rb +54 -55
- data/lib/flickrie/media_count.rb +8 -6
- data/lib/flickrie/photo.rb +48 -7
- data/lib/flickrie/set.rb +47 -31
- data/lib/flickrie/ticket.rb +8 -5
- data/lib/flickrie/user.rb +67 -25
- data/lib/flickrie/version.rb +1 -1
- data/lib/flickrie/video.rb +19 -11
- data/spec/custom_matchers.rb +51 -0
- data/spec/flickrie/api_methods_spec.rb +112 -31
- data/spec/flickrie/error_spec.rb +2 -4
- data/spec/flickrie/instance_spec.rb +11 -11
- data/spec/flickrie/media_spec.rb +74 -53
- data/spec/flickrie/photo_spec.rb +4 -5
- data/spec/flickrie/set_spec.rb +23 -12
- data/spec/flickrie/upload_client_spec.rb +3 -0
- data/spec/flickrie/user_spec.rb +31 -5
- data/spec/flickrie/video_spec.rb +13 -13
- data/spec/flickrie_spec.rb +15 -0
- data/spec/spec_helper.rb +13 -50
- data/spec/vcr_cassettes/api_methods/people/get_media_from_user.yml +108 -0
- data/spec/vcr_cassettes/api_methods/people/get_public_media_from_user.yml +108 -0
- data/spec/vcr_cassettes/api_methods/photos/add_and_remove_tags.yml +528 -0
- data/spec/vcr_cassettes/api_methods/photos/get_context.yml +108 -0
- data/spec/vcr_cassettes/api_methods/photos/get_counts.yml +108 -0
- data/spec/vcr_cassettes/api_methods/photos/get_exif.yml +73 -0
- data/spec/vcr_cassettes/api_methods/photos/get_favorites.yml +73 -0
- data/spec/vcr_cassettes/api_methods/photos/get_from_contacts.yml +73 -0
- data/spec/vcr_cassettes/api_methods/photos/get_info.yml +108 -0
- data/spec/vcr_cassettes/api_methods/photos/get_public_from_user_contacts.yml +73 -0
- data/spec/vcr_cassettes/api_methods/photos/get_sizes.yml +73 -0
- data/spec/vcr_cassettes/api_methods/photos/search.yml +108 -0
- data/spec/vcr_cassettes/api_methods/photosets/get_media.yml +108 -0
- data/spec/vcr_cassettes/api_methods/{replace.yml → upload/replace.yml} +16 -16
- data/spec/vcr_cassettes/api_methods/upload/upload.yml +82 -0
- data/spec/vcr_cassettes/api_methods/upload/upload_asynchronously.yml +117 -0
- data/spec/vcr_cassettes/error/{a_request_was_made_and_failed.yml → a_request_was_made_and_failed/be_raised.yml} +9 -9
- data/spec/vcr_cassettes/error/a_request_was_made_and_failed/have_code_attribute_present.yml +84 -0
- data/spec/vcr_cassettes/{api_methods/upload_and_delete.yml → flickrie/a_new_credential_is_filled_in/reset_the_client.yml} +113 -32
- data/spec/vcr_cassettes/instance/client_is_already_initialized/be_able_to_call_API_methods.yml +152 -0
- data/spec/vcr_cassettes/license/{get.yml → get/have_all_attributes_correctly_set.yml} +4 -4
- data/spec/vcr_cassettes/media/{from_contacts.yml → from_contacts/have_all_attributes_correctly_set.yml} +8 -8
- data/spec/vcr_cassettes/media/{from_set.yml → from_set/have_all_attributes_correctly_set.yml} +6 -6
- data/spec/vcr_cassettes/media/{from_user.yml → from_user/have_all_attributes_correctly_set.yml} +6 -6
- data/spec/vcr_cassettes/media/{get_context.yml → get_context/have_all_attributes_correctly_set.yml} +6 -6
- data/spec/vcr_cassettes/media/{get_exif.yml → get_exif/get_exif_correctly.yml} +8 -8
- data/spec/vcr_cassettes/media/get_info/have_all_attributes_correctly_set.yml +108 -0
- data/spec/vcr_cassettes/media/{public_from_user.yml → public_from_user/have_all_attributes_correctly_set.yml} +6 -6
- data/spec/vcr_cassettes/media/{search.yml → search/have_all_attributes_correctly_set.yml} +6 -6
- data/spec/vcr_cassettes/media_count/{get.yml → get/have_correctly_set_all_attributes.yml} +9 -9
- data/spec/vcr_cassettes/o_auth/{incorrect_credentials.yml → incorrect_credentials/raise_exceptions.yml} +42 -42
- data/spec/vcr_cassettes/photo/get_info/have_all_attributes_correctly_set.yml +38 -0
- data/spec/vcr_cassettes/photo/{get_sizes.yml → get_sizes/have_attributes_correctly_set.yml} +12 -12
- data/spec/vcr_cassettes/photo/{search.yml → search/have_all_sizes_available.yml} +6 -6
- data/spec/vcr_cassettes/set/{from_user.yml → from_user/have_all_attributes_correctly_set.yml} +18 -18
- data/spec/vcr_cassettes/set/{get_info.yml → get_info/have_all_attributes_correctly_set.yml} +36 -36
- data/spec/vcr_cassettes/upload_client/content_type/pass_the_content_type.yml +117 -0
- data/spec/vcr_cassettes/upload_client/invalid_credentials/raise_errors.yml +276 -0
- data/spec/vcr_cassettes/user/{find_by_username_or_email.yml → find_by_username_or_email/have_all_attributes_correctly_set.yml} +9 -9
- data/spec/vcr_cassettes/user/get_info/have_all_attributes_correctly_set.yml +73 -0
- data/spec/vcr_cassettes/video/get_info/have_all_attributes_correctly_set.yml +38 -0
- data/spec/vcr_cassettes/video/{get_sizes.yml → get_sizes/have_all_attributes_correctly_set.yml} +12 -12
- metadata +111 -74
- data/spec/vcr_cassettes/api_methods/asynchronous_upload.yml +0 -362
- data/spec/vcr_cassettes/api_methods/tag_manipulation.yml +0 -178
- data/spec/vcr_cassettes/instance/calling_api_methods.yml +0 -231
- data/spec/vcr_cassettes/media/get_info.yml +0 -108
- data/spec/vcr_cassettes/photo/get_info.yml +0 -38
- data/spec/vcr_cassettes/upload_client/content_type.yml +0 -117
- data/spec/vcr_cassettes/upload_client/invalid_credentials.yml +0 -208
- data/spec/vcr_cassettes/user/get_info.yml +0 -73
- data/spec/vcr_cassettes/video/get_info.yml +0 -38
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Flickrie changelog
|
2
2
|
|
3
|
+
## Version 1.0.3
|
4
|
+
|
5
|
+
- Before `Flickrie::User` had only the `#public_photos` method, now, I
|
6
|
+
just added the missing `#public_videos`, `#public_media`, `#photos`,
|
7
|
+
`#videos` and `#media`.
|
8
|
+
|
9
|
+
- Fixed Flickr's bug with mixing up the width and the height of a photo
|
10
|
+
(not only in the API, but also on their website).
|
11
|
+
|
12
|
+
## Version 1.0.2
|
13
|
+
|
14
|
+
- Fix some mistakes in the documentation
|
15
|
+
|
3
16
|
## Version 1.0.1
|
4
17
|
|
5
18
|
- Transfered the documentation to YARD. [Documentation](http://rubydoc.info/gems/flickrie/)
|
data/Gemfile
CHANGED
data/flickrie.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.author = "Janko Marohnić"
|
9
9
|
gem.email = "janko.marohnic@gmail.com"
|
10
10
|
gem.description = %q{This gem wraps the Flickr API with a nice object-oriented interface.}
|
11
|
-
gem.summary =
|
11
|
+
gem.summary = gem.description
|
12
12
|
gem.homepage = "https://github.com/janko-m/flickrie"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($\)
|
@@ -25,6 +25,6 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.add_dependency "multi_xml", '~> 0.4'
|
26
26
|
|
27
27
|
gem.add_development_dependency "rake", '~> 0.9'
|
28
|
-
gem.add_development_dependency "rspec", '>= 2'
|
28
|
+
gem.add_development_dependency "rspec", '>= 2.10', '< 3'
|
29
29
|
gem.add_development_dependency "vcr", '~> 2.1'
|
30
30
|
end
|
data/lib/flickrie/api_methods.rb
CHANGED
@@ -156,6 +156,7 @@ module Flickrie
|
|
156
156
|
#
|
157
157
|
# @param media_id [String, Fixnum]
|
158
158
|
# @param tags [String] A space delimited string with tags
|
159
|
+
# @return [nil]
|
159
160
|
# @api_method [flickr.photos.addTags](http://www.flickr.com/services/api/flickr.photos.addTags.html)
|
160
161
|
#
|
161
162
|
# @note This method requires authentication with "write" permissions.
|
@@ -169,6 +170,7 @@ module Flickrie
|
|
169
170
|
# Deletes the photo/video with the given ID.
|
170
171
|
#
|
171
172
|
# @param media_id [String, Fixnum]
|
173
|
+
# @return [nil]
|
172
174
|
# @api_method [flickr.photos.delete](http://www.flickr.com/services/api/flickr.photos.delete.html)
|
173
175
|
#
|
174
176
|
# @note This method requires authentication with "delete" permissions.
|
@@ -385,6 +387,7 @@ module Flickrie
|
|
385
387
|
# Remove the tag with the given ID
|
386
388
|
#
|
387
389
|
# @param tag_id [String]
|
390
|
+
# @return [nil]
|
388
391
|
# @api_method [flickr.photos.removeTag](http://www.flickr.com/services/api/flickr.photos.removeTag.html)
|
389
392
|
#
|
390
393
|
# @note This method requires authentication with "write" permissions.
|
@@ -436,7 +439,7 @@ module Flickrie
|
|
436
439
|
# ticket_id = Flickrie.upload(photo)
|
437
440
|
# sleep(10)
|
438
441
|
#
|
439
|
-
# ticket = Flickrie.
|
442
|
+
# ticket = Flickrie.check_upload_tickets(ticket_id)
|
440
443
|
# if ticket.complete?
|
441
444
|
# puts "Photo was uploaded, and its ID is #{ticket.photo_id}"
|
442
445
|
# end
|
data/lib/flickrie/license.rb
CHANGED
data/lib/flickrie/location.rb
CHANGED
@@ -1,32 +1,49 @@
|
|
1
1
|
module Flickrie
|
2
2
|
class Location
|
3
|
-
# @!parse attr_reader
|
3
|
+
# @!parse attr_reader \
|
4
|
+
# :latitude, :longitude, :accuracy, :context,
|
5
|
+
# :neighbourhood, :locality, :county, :region,
|
6
|
+
# :country, :place_id, :woeid, :hash
|
7
|
+
|
8
|
+
# @return [Fixnum]
|
4
9
|
def latitude() @info['latitude'] end
|
5
|
-
#
|
10
|
+
# @return [Fixnum]
|
6
11
|
def longitude() @info['longitude'] end
|
7
|
-
#
|
12
|
+
# @return [String]
|
8
13
|
def accuracy() @info['accuracy'] end
|
9
|
-
#
|
14
|
+
# @return [Fixnum]
|
10
15
|
def context() Integer(@info['context']) rescue nil end
|
11
16
|
|
12
|
-
#
|
17
|
+
# Returns a struct with attributes `#name`, `#place_id` and `#woeid`
|
18
|
+
#
|
19
|
+
# @return [Struct]
|
13
20
|
def neighbourhood() new_area('neighbourhood') end
|
14
|
-
#
|
21
|
+
# Returns a struct with attributes `#name`, `#place_id` and `#woeid`
|
22
|
+
#
|
23
|
+
# @return [Struct]
|
15
24
|
def locality() new_area('locality') end
|
16
|
-
#
|
25
|
+
# Returns a struct with attributes `#name`, `#place_id` and `#woeid`
|
26
|
+
#
|
27
|
+
# @return [Struct]
|
17
28
|
def county() new_area('county') end
|
18
|
-
#
|
29
|
+
# Returns a struct with attributes `#name`, `#place_id` and `#woeid`
|
30
|
+
#
|
31
|
+
# @return [Struct]
|
19
32
|
def region() new_area('region') end
|
20
|
-
#
|
33
|
+
# Returns a struct with attributes `#name`, `#place_id` and `#woeid`
|
34
|
+
#
|
35
|
+
# @return [Struct]
|
21
36
|
def country() new_area('country') end
|
22
37
|
|
23
|
-
#
|
38
|
+
# @return [String]
|
24
39
|
def place_id() @info['place_id'] end
|
25
|
-
#
|
40
|
+
# @return [String]
|
26
41
|
def woeid() @info['woeid'] end
|
27
42
|
|
28
43
|
def [](key) @info[key] end
|
29
|
-
#
|
44
|
+
# Returns the raw hash from the response. Useful if something isn't available by methods.
|
45
|
+
#
|
46
|
+
# @return [Hash]
|
30
47
|
def hash() @info end
|
31
48
|
|
32
49
|
private
|
data/lib/flickrie/media/exif.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Flickrie
|
2
2
|
module Media
|
3
3
|
class Exif
|
4
|
+
# @!parse attr_reader :hash
|
5
|
+
|
4
6
|
# Gets exif. Example:
|
5
7
|
#
|
6
8
|
# photo.exif.get('Model') # => 'Canon PowerShot G12'
|
@@ -20,7 +22,7 @@ module Flickrie
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def [](key) @info[key] end
|
23
|
-
#
|
25
|
+
# @return [Hash]
|
24
26
|
def hash() @info end
|
25
27
|
|
26
28
|
private
|
data/lib/flickrie/media/note.rb
CHANGED
@@ -1,28 +1,39 @@
|
|
1
1
|
module Flickrie
|
2
2
|
module Media
|
3
3
|
class Note
|
4
|
-
|
5
|
-
|
4
|
+
# @!parse attr_reader \
|
5
|
+
# :id, :author, :content, :coordinates, :width,
|
6
|
+
# :height, :hash
|
7
|
+
|
8
|
+
# @return [String]
|
9
|
+
def id() @info['id'] end
|
10
|
+
# @return [Flickrie::User]
|
11
|
+
def author() User.new('nsid' => @info['author'], 'username' => @info['authorname']) end
|
12
|
+
# @return [String]
|
13
|
+
def content() @info['_content'] end
|
14
|
+
# Returns a 2-element array, representing a point.
|
15
|
+
#
|
16
|
+
# @return [Array<Fixnum>]
|
17
|
+
def coordinates() [@info['x'].to_i, @info['y'].to_i] end
|
18
|
+
# @return [Fixnum]
|
19
|
+
def width() @info['w'].to_i end
|
20
|
+
# @return [Fixnum]
|
21
|
+
def height() @info['h'].to_i end
|
6
22
|
|
7
23
|
def to_s
|
8
|
-
|
24
|
+
content
|
9
25
|
end
|
10
26
|
|
11
27
|
def [](key) @info[key] end
|
12
|
-
#
|
28
|
+
# @return [Fixnum]
|
13
29
|
def hash() @info end
|
14
30
|
|
15
31
|
private
|
16
32
|
|
17
|
-
def initialize(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
'username' => hash['authorname']
|
22
|
-
@content = hash['_content']
|
23
|
-
@coordinates = [hash['x'].to_i, hash['y'].to_i]
|
24
|
-
@width = hash['w'].to_i
|
25
|
-
@height = hash['h'].to_i
|
33
|
+
def initialize(info)
|
34
|
+
raise ArgumentError if info.nil?
|
35
|
+
|
36
|
+
@info = info
|
26
37
|
end
|
27
38
|
end
|
28
39
|
end
|
data/lib/flickrie/media/tag.rb
CHANGED
@@ -1,25 +1,28 @@
|
|
1
1
|
module Flickrie
|
2
2
|
module Media
|
3
3
|
class Tag
|
4
|
-
# @!parse attr_reader
|
4
|
+
# @!parse attr_reader \
|
5
|
+
# :id, :raw, :content, :machine_tag?, :author, :hash
|
6
|
+
|
7
|
+
# @return [String]
|
5
8
|
def id() @info['id'] end
|
6
|
-
#
|
9
|
+
# @return [String]
|
7
10
|
def raw() @info['raw'] end
|
8
|
-
#
|
11
|
+
# @return [String]
|
9
12
|
def content() @info['_content'] end
|
10
13
|
|
11
|
-
#
|
14
|
+
# @return [Boolean]
|
12
15
|
def machine_tag?
|
13
16
|
@info['machine_tag'].to_i == 1 if @info['machine_tag']
|
14
17
|
end
|
15
18
|
|
16
|
-
#
|
19
|
+
# @return [Flickrie::User]
|
17
20
|
def author
|
18
21
|
User.new('nsid' => @info['author']) if @info['author']
|
19
22
|
end
|
20
23
|
|
21
24
|
def [](key) @info[key] end
|
22
|
-
#
|
25
|
+
# @return [Hash]
|
23
26
|
def hash() @info end
|
24
27
|
|
25
28
|
private
|
@@ -1,17 +1,20 @@
|
|
1
1
|
module Flickrie
|
2
2
|
module Media
|
3
3
|
class Visibility
|
4
|
-
# @!parse attr_reader
|
4
|
+
# @!parse attr_reader \
|
5
|
+
# :public?, :friends?, :family?, :contacts?, :hash
|
6
|
+
|
7
|
+
# @return [Boolean]
|
5
8
|
def public?() @info['ispublic'].to_i == 1 if @info['ispublic'] end
|
6
|
-
#
|
9
|
+
# @return [Boolean]
|
7
10
|
def friends?() @info['isfriend'].to_i == 1 if @info['isfriend'] end
|
8
|
-
#
|
11
|
+
# @return [Boolean]
|
9
12
|
def family?() @info['isfamily'].to_i == 1 if @info['isfamily'] end
|
10
|
-
#
|
13
|
+
# @return [Boolean]
|
11
14
|
def contacts?() @info['iscontact'].to_i == 1 if @info['iscontact'] end
|
12
15
|
|
13
16
|
def [](key) @info[key] end
|
14
|
-
#
|
17
|
+
# @return [Hash]
|
15
18
|
def hash() @info end
|
16
19
|
|
17
20
|
private
|
data/lib/flickrie/media.rb
CHANGED
@@ -7,24 +7,36 @@ require 'date'
|
|
7
7
|
|
8
8
|
module Flickrie
|
9
9
|
module Media
|
10
|
-
# @!parse attr_reader
|
10
|
+
# @!parse attr_reader \
|
11
|
+
# :id, :secret, :server, :farm, :title, :description,
|
12
|
+
# :media_status, :path_alias, :camera, :exif, :views_count,
|
13
|
+
# :comments_count, :location, :geo_permissions, :tags,
|
14
|
+
# :machine_tags, :license, :posted_at, :uploaded_at,
|
15
|
+
# :updated_at, :taken_at, :taken_at_granularity, :owner,
|
16
|
+
# :safety_level, :safe?, :moderate?, :restricted?,
|
17
|
+
# :url, :visibility, :primary?, :favorite?, :can_comment?,
|
18
|
+
# :can_add_meta?, :can_everyone_comment?, :can_everyone_add_meta?,
|
19
|
+
# :can_download?, :can_blog?, :can_print?, :can_share?,
|
20
|
+
# :has_people?, :faved?, :notes, :favorites, :hash
|
21
|
+
|
22
|
+
# @return [String]
|
11
23
|
def id() @info['id'] end
|
12
|
-
#
|
24
|
+
# @return [String]
|
13
25
|
def secret() @info['secret'] end
|
14
|
-
#
|
26
|
+
# @return [String]
|
15
27
|
def server() @info['server'] end
|
16
|
-
#
|
28
|
+
# @return [Fixnum]
|
17
29
|
def farm() @info['farm'] end
|
18
|
-
#
|
30
|
+
# @return [String]
|
19
31
|
def title() @info['title'] end
|
20
|
-
#
|
32
|
+
# @return [String]
|
21
33
|
def description() @info['description'] end
|
22
|
-
#
|
34
|
+
# @return [String]
|
23
35
|
def media_status() @info['media_status'] end
|
24
|
-
#
|
36
|
+
# @return [String]
|
25
37
|
def path_alias() @info['pathalias'] end
|
26
38
|
|
27
|
-
#
|
39
|
+
# @return [String]
|
28
40
|
def camera() @info['camera'] end
|
29
41
|
# Returns exif of the photo/video. Example:
|
30
42
|
#
|
@@ -35,66 +47,51 @@ module Flickrie
|
|
35
47
|
# photo.exif.get('X-Resolution') # => '180 dpi'
|
36
48
|
#
|
37
49
|
# @return [Flickrie::Media::Exif]
|
38
|
-
#
|
39
|
-
# @!parse attr_reader :exif
|
40
50
|
def exif() Exif.new(@info['exif']) rescue nil end
|
41
51
|
|
42
|
-
#
|
52
|
+
# @return [Fixnum]
|
43
53
|
def views_count() Integer(@info['views']) rescue nil end
|
44
|
-
#
|
54
|
+
# @return [Fixnum]
|
45
55
|
def comments_count() Integer(@info['comments_count']) rescue nil end
|
46
56
|
|
47
57
|
# @return [Flickrie::Location]
|
48
|
-
#
|
49
|
-
# @!parse attr_reader :location
|
50
58
|
def location() Location.new(@info['location']) rescue nil end
|
51
59
|
# @return [Flickrie::Media::Visibility]
|
52
|
-
#
|
53
|
-
# @!parse attr_reader :geo_permissions
|
54
60
|
def geo_permissions() Visibility.new(@info['geoperms']) rescue nil end
|
55
61
|
|
56
62
|
# @return [Array<Flickrie::Media::Tag>]
|
57
|
-
#
|
58
|
-
# @!parse attr_reader :tags
|
59
63
|
def tags() @info['tags'].map { |info| Tag.new(info) } rescue nil end
|
60
64
|
# @return [Array<Flickrie::Media::Tag>]
|
61
|
-
#
|
62
|
-
# @!parse attr_reader :machine_tags
|
63
65
|
def machine_tags() tags.select { |tag| tag.machine_tag? } rescue nil end
|
64
66
|
|
65
67
|
# @return [Flickrie::License]
|
66
|
-
# @!parse attr_reader :license
|
67
68
|
def license() License.new(@info['license']) rescue nil end
|
68
69
|
|
69
|
-
#
|
70
|
+
# @return [Time]
|
70
71
|
def posted_at() Time.at(Integer(@info['dates']['posted'])) rescue nil end
|
71
|
-
#
|
72
|
+
# @return [Time]
|
72
73
|
def uploaded_at() Time.at(Integer(@info['dates']['uploaded'])) rescue nil end
|
73
|
-
#
|
74
|
+
# @return [Time]
|
74
75
|
def updated_at() Time.at(Integer(@info['dates']['lastupdate'])) rescue nil end
|
75
|
-
#
|
76
|
+
# @return [Time]
|
76
77
|
def taken_at() DateTime.parse(@info['dates']['taken']).to_time rescue nil end
|
77
|
-
#
|
78
|
+
# @return [Fixnum]
|
78
79
|
def taken_at_granularity() Integer(@info['dates']['takengranularity']) rescue nil end
|
79
80
|
|
80
81
|
# @return [Flickrie::User]
|
81
|
-
#
|
82
|
-
# @!parse attr_reader :owner
|
83
82
|
def owner() User.new(@info['owner']) rescue nil end
|
84
83
|
|
85
|
-
#
|
84
|
+
# @return [Fixnum]
|
86
85
|
def safety_level() Integer(@info['safety_level']) rescue nil end
|
87
86
|
|
88
|
-
#
|
87
|
+
# @return [Boolean]
|
89
88
|
def safe?() safety_level <= 1 if safety_level end
|
90
|
-
#
|
89
|
+
# @return [Boolean]
|
91
90
|
def moderate?() safety_level == 2 if safety_level end
|
92
|
-
#
|
91
|
+
# @return [Boolean]
|
93
92
|
def restricted?() safety_level == 3 if safety_level end
|
94
93
|
|
95
|
-
# @
|
96
|
-
#
|
97
|
-
# @!parse attr_reader :url
|
94
|
+
# @return [String]
|
98
95
|
def url
|
99
96
|
if owner and id
|
100
97
|
"http://www.flickr.com/photos/#{owner.nsid}/#{id}"
|
@@ -104,56 +101,54 @@ module Flickrie
|
|
104
101
|
end
|
105
102
|
|
106
103
|
# @return [Flickrie::Media::Visibility]
|
107
|
-
#
|
108
|
-
# @!parse attr_reader :visibility
|
109
104
|
def visibility() Visibility.new(@info['visibility']) rescue nil end
|
110
105
|
|
111
|
-
#
|
106
|
+
# @return [Boolean]
|
112
107
|
def primary?() Integer(@info['isprimary']) == 1 rescue nil end
|
113
108
|
|
114
|
-
#
|
109
|
+
# @return [Boolean]
|
115
110
|
def favorite?() Integer(@info['isfavorite']) == 1 rescue nil end
|
116
111
|
|
117
|
-
#
|
112
|
+
# @return [Boolean]
|
118
113
|
def can_comment?() Integer(@info['editability']['cancomment']) == 1 rescue nil end
|
119
|
-
#
|
114
|
+
# @return [Boolean]
|
120
115
|
def can_add_meta?() Integer(@info['editability']['canaddmeta']) == 1 rescue nil end
|
121
116
|
|
122
|
-
#
|
117
|
+
# @return [Boolean]
|
123
118
|
def can_everyone_comment?() Integer(@info['publiceditability']['cancomment']) == 1 rescue nil end
|
124
|
-
#
|
119
|
+
# @return [Boolean]
|
125
120
|
def can_everyone_add_meta?() Integer(@info['publiceditability']['canaddmeta']) == 1 rescue nil end
|
126
121
|
|
127
|
-
#
|
122
|
+
# @return [Boolean]
|
128
123
|
def can_download?() Integer(@info['usage']['candownload']) == 1 rescue nil end
|
129
|
-
#
|
124
|
+
# @return [Boolean]
|
130
125
|
def can_blog?() Integer(@info['usage']['canblog']) == 1 rescue nil end
|
131
|
-
#
|
126
|
+
# @return [Boolean]
|
132
127
|
def can_print?() Integer(@info['usage']['canprint']) == 1 rescue nil end
|
133
|
-
#
|
128
|
+
# @return [Boolean]
|
134
129
|
def can_share?() Integer(@info['usage']['canshare']) == 1 rescue nil end
|
135
130
|
|
136
|
-
#
|
131
|
+
# @return [Boolean]
|
137
132
|
def has_people?() Integer(@info['people']['haspeople']) == 1 rescue nil end
|
138
133
|
|
139
|
-
#
|
134
|
+
# @return [Boolean]
|
140
135
|
def faved?() Integer(@info['is_faved']) == 1 rescue nil end
|
141
136
|
|
142
137
|
# @return [Array<Flickrie::Media::Note>]
|
143
|
-
#
|
144
|
-
# @!parse attr_reader :notes
|
145
138
|
def notes() @info['notes']['note'].map { |hash| Note.new(hash) } rescue nil end
|
146
139
|
|
147
140
|
# @return [Array<Flickrie::User>]
|
148
|
-
#
|
149
|
-
# @!parse attr_reader :favorites
|
150
141
|
def favorites() @info['person'].map { |info| User.new(info) } rescue nil end
|
151
142
|
|
152
143
|
def [](key) @info[key] end
|
153
|
-
#
|
144
|
+
# Returns the raw hash from the response. Useful if something isn't available by methods.
|
145
|
+
#
|
146
|
+
# @return [Hash]
|
154
147
|
def hash() @info end
|
155
148
|
|
156
149
|
# Same as calling `Flickrie.get_(photo|video)_info(id)`.
|
150
|
+
#
|
151
|
+
# @return [self]
|
157
152
|
def get_info(params = {}, info = nil)
|
158
153
|
info ||= Flickrie.client.get_media_info(id, params).body['photo']
|
159
154
|
@info.update(info)
|
@@ -169,6 +164,8 @@ module Flickrie
|
|
169
164
|
end
|
170
165
|
|
171
166
|
# Same as calling `Flickrie.get_(photo|video)_info(id)`.
|
167
|
+
#
|
168
|
+
# @return [self]
|
172
169
|
def get_exif(params = {}, info = nil)
|
173
170
|
info ||= Flickrie.client.get_media_exif(id, params).body['photo']
|
174
171
|
@info.update(info)
|
@@ -177,6 +174,8 @@ module Flickrie
|
|
177
174
|
end
|
178
175
|
|
179
176
|
# Same as calling `Flickrie.get_(photo|video)_info(id)`.
|
177
|
+
#
|
178
|
+
# @return [self]
|
180
179
|
def get_favorites(params = {}, info = nil)
|
181
180
|
info ||= Flickrie.client.get_media_favorites(id, params).body['photo']
|
182
181
|
@info.update(info)
|
data/lib/flickrie/media_count.rb
CHANGED
@@ -2,12 +2,12 @@ require 'date'
|
|
2
2
|
|
3
3
|
module Flickrie
|
4
4
|
class MediaCount
|
5
|
-
# @!parse attr_reader
|
5
|
+
# @!parse attr_reader \
|
6
|
+
# :value, :date_range, :from, :to, :hash
|
7
|
+
|
6
8
|
def value() Integer(@info['count']) rescue nil end
|
7
9
|
|
8
10
|
# @return [Range]
|
9
|
-
#
|
10
|
-
# @!parse attr_reader :date_range
|
11
11
|
def date_range
|
12
12
|
dates =
|
13
13
|
case @dates_kind
|
@@ -23,13 +23,15 @@ module Flickrie
|
|
23
23
|
end
|
24
24
|
alias time_interval date_range
|
25
25
|
|
26
|
-
#
|
26
|
+
# @return [Time]
|
27
27
|
def from() date_range.begin end
|
28
|
-
#
|
28
|
+
# @return [Time]
|
29
29
|
def to() date_range.end end
|
30
30
|
|
31
31
|
def [](key) @info[key] end
|
32
|
-
#
|
32
|
+
# Returns the raw hash from the response. Useful if something isn't available by methods.
|
33
|
+
#
|
34
|
+
# @return [Hash]
|
33
35
|
def hash() @info end
|
34
36
|
|
35
37
|
private
|
data/lib/flickrie/photo.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Flickrie
|
2
2
|
class Photo
|
3
3
|
include Media
|
4
|
+
# @!parse attr_reader \
|
5
|
+
# :size, :width, :height, :source_url, :rotation
|
4
6
|
|
5
7
|
SIZES = {
|
6
8
|
'Square 75' => 'sq',
|
@@ -15,59 +17,94 @@ module Flickrie
|
|
15
17
|
'Original' => 'o'
|
16
18
|
}
|
17
19
|
|
18
|
-
#
|
20
|
+
# Returns the current Flickr size of the photo ("Medium 500", for example).
|
21
|
+
#
|
22
|
+
# @return [String]
|
19
23
|
def size() @size end
|
20
24
|
|
25
|
+
# @return [self]
|
21
26
|
def square!(number) @size = "Square #{number}"; self end
|
27
|
+
# @return [self]
|
22
28
|
def thumbnail!() @size = "Thumbnail"; self end
|
29
|
+
# @return [self]
|
23
30
|
def small!(number) @size = "Small #{number}"; self end
|
31
|
+
# @return [self]
|
24
32
|
def medium!(number) @size = "Medium #{number}"; self end
|
33
|
+
# @return [self]
|
25
34
|
def large!(number) @size = "Large #{number}"; self end
|
35
|
+
# @return [self]
|
26
36
|
def original!() @size = "Original"; self end
|
27
37
|
|
38
|
+
# @return [self]
|
28
39
|
def square(number) dup.square!(number) end
|
40
|
+
# @return [self]
|
29
41
|
def thumbnail() dup.thumbnail! end
|
42
|
+
# @return [self]
|
30
43
|
def small(number) dup.small!(number) end
|
44
|
+
# @return [self]
|
31
45
|
def medium(number) dup.medium!(number) end
|
46
|
+
# @return [self]
|
32
47
|
def large(number) dup.large!(number) end
|
48
|
+
# @return [self]
|
33
49
|
def original() dup.original! end
|
34
50
|
|
35
51
|
# @comment Alternate size methods
|
52
|
+
# @return [self]
|
36
53
|
def square75() square(75) end
|
54
|
+
# @return [self]
|
37
55
|
def square75!() square!(75) end
|
56
|
+
# @return [self]
|
38
57
|
def square150() square(150) end
|
58
|
+
# @return [self]
|
39
59
|
def square150!() square!(150) end
|
60
|
+
# @return [self]
|
40
61
|
def small240() small(240) end
|
62
|
+
# @return [self]
|
41
63
|
def small240!() small!(240) end
|
64
|
+
# @return [self]
|
42
65
|
def small320() small(320) end
|
66
|
+
# @return [self]
|
43
67
|
def small320!() small!(320) end
|
68
|
+
# @return [self]
|
44
69
|
def medium500() medium(500) end
|
70
|
+
# @return [self]
|
45
71
|
def medium500!() medium!(500) end
|
72
|
+
# @return [self]
|
46
73
|
def medium640() medium(640) end
|
74
|
+
# @return [self]
|
47
75
|
def medium640!() medium!(640) end
|
76
|
+
# @return [self]
|
48
77
|
def medium800() medium(800) end
|
78
|
+
# @return [self]
|
49
79
|
def medium800!() medium!(800) end
|
80
|
+
# @return [self]
|
50
81
|
def large1024() large(1024) end
|
82
|
+
# @return [self]
|
51
83
|
def large1024!() large!(1024) end
|
52
84
|
|
85
|
+
# @return [self]
|
53
86
|
def largest!() @size = largest_size; self end
|
87
|
+
# @return [self]
|
54
88
|
def largest() dup.largest! end
|
55
89
|
|
90
|
+
# @return [Array<String>]
|
56
91
|
def available_sizes
|
57
92
|
SIZES.select { |_,v| @info["url_#{v}"] }.keys
|
58
93
|
end
|
59
94
|
|
60
|
-
#
|
61
|
-
def width()
|
62
|
-
#
|
63
|
-
def height()
|
64
|
-
#
|
95
|
+
# @return [Fixnum]
|
96
|
+
def width() flickr_size.min rescue nil end
|
97
|
+
# @return [Fixnum]
|
98
|
+
def height() flickr_size.max rescue nil end
|
99
|
+
# @return [String]
|
65
100
|
def source_url() @info["url_#{size_abbr}"] end
|
66
101
|
|
67
|
-
#
|
102
|
+
# @return [Fixnum]
|
68
103
|
def rotation() Integer(@info['rotation']) rescue nil end
|
69
104
|
|
70
105
|
# Same as calling `Flickrie.get_photo_sizes(photo.id)`.
|
106
|
+
#
|
107
|
+
# @return [self]
|
71
108
|
def get_sizes(params = {}, info = nil)
|
72
109
|
info ||= Flickrie.client.get_media_sizes(id, params).body['sizes']
|
73
110
|
@info['usage'] ||= {}
|
@@ -111,5 +148,9 @@ module Flickrie
|
|
111
148
|
def size_abbr
|
112
149
|
SIZES[size]
|
113
150
|
end
|
151
|
+
|
152
|
+
def flickr_size
|
153
|
+
[Integer(@info["width_#{size_abbr}"]), Integer(@info["height_#{size_abbr}"])]
|
154
|
+
end
|
114
155
|
end
|
115
156
|
end
|