flickr-objects 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +49 -63
- data/lib/flickr/api/abstract/params_processor.rb +68 -0
- data/lib/flickr/api/abstract.rb +113 -0
- data/lib/flickr/api/general.rb +75 -0
- data/lib/flickr/api/person.rb +91 -39
- data/lib/flickr/api/photo.rb +213 -108
- data/lib/flickr/api/set.rb +114 -55
- data/lib/flickr/api/upload_ticket.rb +17 -6
- data/lib/flickr/api.rb +90 -35
- data/lib/flickr/attributes.rb +200 -0
- data/lib/flickr/base_converter.rb +29 -0
- data/lib/flickr/client/data.rb +47 -0
- data/lib/flickr/client/oauth.rb +44 -0
- data/lib/flickr/client/upload.rb +55 -0
- data/lib/flickr/client.rb +77 -33
- data/lib/flickr/configuration.rb +85 -14
- data/lib/flickr/error.rb +58 -0
- data/lib/flickr/middleware.rb +52 -28
- data/lib/flickr/oauth.rb +89 -74
- data/lib/flickr/object/attribute_locations/list.rb +25 -0
- data/lib/flickr/object/attribute_locations/location.rb +29 -0
- data/lib/flickr/object/attribute_locations/permissions.rb +31 -0
- data/lib/flickr/object/attribute_locations/person/upload_status.rb +32 -0
- data/lib/flickr/object/attribute_locations/person.rb +78 -0
- data/lib/flickr/object/attribute_locations/photo/exif.rb +29 -0
- data/lib/flickr/object/attribute_locations/photo/note.rb +36 -0
- data/lib/flickr/object/attribute_locations/photo/tag.rb +23 -0
- data/lib/flickr/object/attribute_locations/photo.rb +164 -0
- data/lib/flickr/object/attribute_locations/set.rb +53 -0
- data/lib/flickr/object/attribute_locations/upload_ticket.rb +30 -0
- data/lib/flickr/object/attribute_locations/visibility.rb +24 -0
- data/lib/flickr/object/list/kaminari.rb +30 -0
- data/lib/flickr/object/list/normal.rb +27 -0
- data/lib/flickr/object/list/will_paginate.rb +31 -0
- data/lib/flickr/object/list.rb +87 -0
- data/lib/flickr/object/location.rb +35 -0
- data/lib/flickr/object/permissions.rb +18 -0
- data/lib/flickr/object/person/upload_status.rb +22 -0
- data/lib/flickr/object/person.rb +93 -0
- data/lib/flickr/object/photo/exif.rb +35 -0
- data/lib/flickr/object/photo/note.rb +20 -0
- data/lib/flickr/object/photo/size.rb +67 -0
- data/lib/flickr/object/photo/tag.rb +23 -0
- data/lib/flickr/object/photo.rb +349 -0
- data/lib/flickr/object/set.rb +114 -0
- data/lib/flickr/object/upload_ticket.rb +31 -0
- data/lib/flickr/object/visibility.rb +16 -0
- data/lib/flickr/object.rb +118 -27
- data/lib/flickr/sanitized_file.rb +70 -0
- data/lib/flickr/version.rb +4 -2
- data/lib/flickr.rb +69 -15
- metadata +89 -103
- data/lib/flickr/api/api_methods/flickr.rb +0 -5
- data/lib/flickr/api/api_methods/person.rb +0 -14
- data/lib/flickr/api/api_methods/photo.rb +0 -26
- data/lib/flickr/api/api_methods/set.rb +0 -18
- data/lib/flickr/api/api_methods/upload_ticket.rb +0 -5
- data/lib/flickr/api/flickr.rb +0 -35
- data/lib/flickr/api_caller.rb +0 -98
- data/lib/flickr/client/methods_client.rb +0 -22
- data/lib/flickr/client/upload_client.rb +0 -62
- data/lib/flickr/errors.rb +0 -19
- data/lib/flickr/helpers/base_58.rb +0 -15
- data/lib/flickr/helpers/boolean.rb +0 -4
- data/lib/flickr/helpers/core_ext.rb +0 -5
- data/lib/flickr/object/attribute/converter.rb +0 -49
- data/lib/flickr/object/attribute/finder.rb +0 -32
- data/lib/flickr/object/attribute.rb +0 -45
- data/lib/flickr/objects/attribute_values/list.rb +0 -10
- data/lib/flickr/objects/attribute_values/location.rb +0 -14
- data/lib/flickr/objects/attribute_values/note.rb +0 -11
- data/lib/flickr/objects/attribute_values/permissions.rb +0 -12
- data/lib/flickr/objects/attribute_values/person/upload_status.rb +0 -16
- data/lib/flickr/objects/attribute_values/person.rb +0 -24
- data/lib/flickr/objects/attribute_values/photo.rb +0 -84
- data/lib/flickr/objects/attribute_values/set.rb +0 -17
- data/lib/flickr/objects/attribute_values/tag.rb +0 -9
- data/lib/flickr/objects/attribute_values/upload_ticket.rb +0 -9
- data/lib/flickr/objects/attribute_values/visibility.rb +0 -10
- data/lib/flickr/objects/list.rb +0 -86
- data/lib/flickr/objects/location.rb +0 -26
- data/lib/flickr/objects/note.rb +0 -14
- data/lib/flickr/objects/permissions.rb +0 -14
- data/lib/flickr/objects/person/upload_status.rb +0 -14
- data/lib/flickr/objects/person.rb +0 -43
- data/lib/flickr/objects/photo.rb +0 -113
- data/lib/flickr/objects/set.rb +0 -29
- data/lib/flickr/objects/tag.rb +0 -17
- data/lib/flickr/objects/upload_ticket.rb +0 -18
- data/lib/flickr/objects/visibility.rb +0 -12
- data/lib/flickr/objects.rb +0 -25
data/lib/flickr/objects/photo.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
require_relative "attribute_values/photo"
|
2
|
-
require "flickr/api/photo"
|
3
|
-
require "flickr/helpers/base_58"
|
4
|
-
|
5
|
-
class Flickr
|
6
|
-
class Photo < Object
|
7
|
-
|
8
|
-
attribute :id, String
|
9
|
-
attribute :secret, String
|
10
|
-
attribute :server, String
|
11
|
-
attribute :farm, Integer
|
12
|
-
attribute :title, String
|
13
|
-
attribute :description, String
|
14
|
-
attribute :license, Integer
|
15
|
-
attribute :visibility, Visibility
|
16
|
-
attribute :safety_level, Integer
|
17
|
-
|
18
|
-
attribute :owner, Person
|
19
|
-
|
20
|
-
attribute :uploaded_at, Time
|
21
|
-
attribute :posted_at, Time
|
22
|
-
attribute :taken_at, Time
|
23
|
-
attribute :taken_at_granularity, Integer
|
24
|
-
attribute :updated_at, Time
|
25
|
-
|
26
|
-
attribute :views_count, Integer
|
27
|
-
attribute :comments_count, Integer
|
28
|
-
|
29
|
-
attribute :editability, Permissions
|
30
|
-
attribute :public_editability, Permissions
|
31
|
-
attribute :usage, Permissions
|
32
|
-
|
33
|
-
attribute :notes, Array[Note]
|
34
|
-
attribute :tags, Array[Tag]
|
35
|
-
|
36
|
-
attribute :has_people?, Boolean
|
37
|
-
attribute :favorite?, Boolean
|
38
|
-
|
39
|
-
attribute :path_alias, String
|
40
|
-
|
41
|
-
attribute :location, Location
|
42
|
-
attribute :location_visibility, Visibility
|
43
|
-
|
44
|
-
attribute :rotation, Integer
|
45
|
-
|
46
|
-
attribute :largest_size, String
|
47
|
-
attribute :available_sizes, Array[String]
|
48
|
-
|
49
|
-
attribute :source_url, String
|
50
|
-
attribute :height, Integer
|
51
|
-
attribute :width, Integer
|
52
|
-
|
53
|
-
def safe?; safety_level <= 1 end
|
54
|
-
def moderate?; safety_level == 2 end
|
55
|
-
def restricted?; safety_level == 3 end
|
56
|
-
|
57
|
-
def url
|
58
|
-
"http://www.flickr.com/photos/#{owner.id}/#{id}/" if owner
|
59
|
-
end
|
60
|
-
|
61
|
-
include Base58
|
62
|
-
def short_url
|
63
|
-
"http://flic.kr/p/#{to_base58(id)}"
|
64
|
-
end
|
65
|
-
|
66
|
-
SIZES = {
|
67
|
-
"Square 75" => "sq",
|
68
|
-
"Thumbnail" => "t",
|
69
|
-
"Square 150" => "q",
|
70
|
-
"Small 240" => "s",
|
71
|
-
"Small 320" => "n",
|
72
|
-
"Medium 500" => "m",
|
73
|
-
"Medium 640" => "z",
|
74
|
-
"Medium 800" => "c",
|
75
|
-
"Large 1024" => "l",
|
76
|
-
"Large 1600" => "h",
|
77
|
-
"Large 2048" => "k",
|
78
|
-
"Original" => "o"
|
79
|
-
}
|
80
|
-
|
81
|
-
attr_reader :size
|
82
|
-
|
83
|
-
SIZES.keys.each do |size|
|
84
|
-
size_name, size_number = size.split(" ").map(&:downcase)
|
85
|
-
|
86
|
-
define_method("#{size_name}#{size_number}!") { @size = size; self }
|
87
|
-
define_method("#{size_name}#{size_number}") { dup.send("#{__method__}!") }
|
88
|
-
|
89
|
-
if size_number
|
90
|
-
define_method("#{size_name}!") { |size_number| send("#{size_name}#{size_number}!") }
|
91
|
-
define_method("#{size_name}") { |size_number| send("#{size_name}#{size_number}") }
|
92
|
-
end
|
93
|
-
|
94
|
-
define_method("#{size_name}#{size_number}_or_smaller!") do
|
95
|
-
sizes = SIZES.keys.reverse.drop_while { |s| s != size }
|
96
|
-
@size = sizes.find { |s| @hash["url_#{SIZES[s]}"] }
|
97
|
-
self
|
98
|
-
end
|
99
|
-
define_method("#{size_name}#{size_number}_or_smaller") { dup.send("#{__method__}!") }
|
100
|
-
|
101
|
-
define_method("#{size_name}#{size_number}_at_least!") do
|
102
|
-
sizes = SIZES.keys.drop_while { |s| s != size }.reverse
|
103
|
-
@size = sizes.find { |s| @hash["url_#{SIZES[s]}"] }
|
104
|
-
self
|
105
|
-
end
|
106
|
-
define_method("#{size_name}#{size_number}_at_least") { dup.send("#{__method__}!") }
|
107
|
-
end
|
108
|
-
|
109
|
-
def largest!; @size = largest_size; self end
|
110
|
-
def largest; dup.largest! end
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|
data/lib/flickr/objects/set.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative "attribute_values/set"
|
2
|
-
require "flickr/api/set"
|
3
|
-
|
4
|
-
class Flickr
|
5
|
-
class Set < Object
|
6
|
-
|
7
|
-
attribute :id, String
|
8
|
-
attribute :secret, String
|
9
|
-
attribute :server, String
|
10
|
-
attribute :farm, Integer
|
11
|
-
attribute :url, String
|
12
|
-
attribute :title, String
|
13
|
-
attribute :description, String
|
14
|
-
|
15
|
-
attribute :owner, Person
|
16
|
-
|
17
|
-
attribute :photos_count, Integer
|
18
|
-
attribute :views_count, Integer
|
19
|
-
attribute :comments_count, Integer
|
20
|
-
|
21
|
-
attribute :permissions, Permissions
|
22
|
-
|
23
|
-
attribute :created_at, Time
|
24
|
-
attribute :updated_at, Time
|
25
|
-
|
26
|
-
attribute :primary_photo, Photo
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
data/lib/flickr/objects/tag.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative "attribute_values/tag"
|
2
|
-
|
3
|
-
class Flickr
|
4
|
-
class Tag < Object
|
5
|
-
|
6
|
-
attribute :id, String
|
7
|
-
attribute :author, Person
|
8
|
-
attribute :raw, String
|
9
|
-
attribute :content, String
|
10
|
-
attribute :machine_tag?, Boolean
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
content
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative "attribute_values/upload_ticket"
|
2
|
-
require "flickr/api/upload_ticket"
|
3
|
-
|
4
|
-
class Flickr
|
5
|
-
class UploadTicket < Object
|
6
|
-
|
7
|
-
attribute :id, String
|
8
|
-
attribute :status, Integer
|
9
|
-
attribute :invalid, Integer
|
10
|
-
|
11
|
-
attribute :photo, Photo
|
12
|
-
|
13
|
-
def complete?; status == 1 end
|
14
|
-
def failed?; status == 2 end
|
15
|
-
|
16
|
-
def invalid?; invalid == 1 end
|
17
|
-
end
|
18
|
-
end
|
data/lib/flickr/objects.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require "flickr/object"
|
2
|
-
|
3
|
-
class Flickr
|
4
|
-
# Official objects
|
5
|
-
class Person < Object; end
|
6
|
-
class Photo < Object; end
|
7
|
-
class Set < Object; end
|
8
|
-
|
9
|
-
# Meta objects
|
10
|
-
class Visibility < Object; end
|
11
|
-
class Permissions < Object; end
|
12
|
-
class Note < Object; end
|
13
|
-
class Tag < Object; end
|
14
|
-
class Location < Object; end
|
15
|
-
class UploadTicket < Object; end
|
16
|
-
class Person::UploadStatus < Object; end
|
17
|
-
|
18
|
-
autoload :List, "flickr/objects/list"
|
19
|
-
end
|
20
|
-
|
21
|
-
objects = Flickr::Object.children.dup
|
22
|
-
objects.each do |object|
|
23
|
-
underscored_name = object.name.split("::")[1..-1].map { |s| s.split(/(?<=\w)(?=[A-Z])/).map(&:downcase).join("_") }
|
24
|
-
require "flickr/objects/#{underscored_name.join("/")}"
|
25
|
-
end
|