flickr-objects 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +55 -85
- data/lib/flickr/api/api_methods/flickr.rb +0 -1
- data/lib/flickr/api/api_methods/person.rb +3 -3
- data/lib/flickr/api/api_methods/photo.rb +12 -1
- data/lib/flickr/api/api_methods/set.rb +6 -5
- data/lib/flickr/api/flickr.rb +9 -9
- data/lib/flickr/api/person.rb +13 -29
- data/lib/flickr/api/photo.rb +51 -4
- data/lib/flickr/api/set.rb +20 -25
- data/lib/flickr/api/upload_ticket.rb +4 -2
- data/lib/flickr/api.rb +0 -2
- data/lib/flickr/api_caller.rb +5 -11
- data/lib/flickr/client/upload_client.rb +4 -16
- data/lib/flickr/client.rb +1 -1
- data/lib/flickr/configuration.rb +2 -0
- data/lib/flickr/errors.rb +19 -0
- data/lib/flickr/middleware.rb +63 -0
- data/lib/flickr/oauth.rb +109 -0
- data/lib/flickr/object/attribute/finder.rb +2 -2
- data/lib/flickr/object/attribute.rb +8 -8
- data/lib/flickr/object.rb +13 -2
- data/lib/flickr/objects/attribute_values/{collection.rb → list.rb} +1 -1
- data/lib/flickr/objects/attribute_values/photo.rb +81 -16
- data/lib/flickr/objects/attribute_values/set.rb +1 -5
- data/lib/flickr/objects/attribute_values/upload_ticket.rb +3 -5
- data/lib/flickr/objects/list.rb +86 -0
- data/lib/flickr/objects/location.rb +2 -0
- data/lib/flickr/objects/note.rb +3 -1
- data/lib/flickr/objects/permissions.rb +2 -0
- data/lib/flickr/objects/person.rb +8 -5
- data/lib/flickr/objects/photo.rb +98 -30
- data/lib/flickr/objects/set.rb +4 -5
- data/lib/flickr/objects/tag.rb +2 -0
- data/lib/flickr/objects/upload_ticket.rb +8 -6
- data/lib/flickr/objects/visibility.rb +2 -0
- data/lib/flickr/objects.rb +2 -7
- data/lib/flickr/version.rb +1 -1
- data/lib/flickr.rb +5 -0
- metadata +60 -32
- data/lib/flickr/api/api_methods/collection.rb +0 -4
- data/lib/flickr/api/api_methods/location.rb +0 -4
- data/lib/flickr/api/api_methods/media.rb +0 -14
- data/lib/flickr/api/api_methods/note.rb +0 -4
- data/lib/flickr/api/api_methods/permissions.rb +0 -4
- data/lib/flickr/api/api_methods/tag.rb +0 -4
- data/lib/flickr/api/api_methods/video.rb +0 -4
- data/lib/flickr/api/api_methods/visibility.rb +0 -4
- data/lib/flickr/api/collection.rb +0 -4
- data/lib/flickr/api/location.rb +0 -4
- data/lib/flickr/api/media.rb +0 -52
- data/lib/flickr/api/note.rb +0 -4
- data/lib/flickr/api/permissions.rb +0 -4
- data/lib/flickr/api/tag.rb +0 -4
- data/lib/flickr/api/video.rb +0 -11
- data/lib/flickr/api/visibility.rb +0 -4
- data/lib/flickr/client/middleware/retry.rb +0 -29
- data/lib/flickr/client/middleware.rb +0 -42
- data/lib/flickr/helpers/inheritable_attr_accessor.rb +0 -18
- data/lib/flickr/objects/attribute_values/media.rb +0 -70
- data/lib/flickr/objects/attribute_values/video.rb +0 -27
- data/lib/flickr/objects/collection.rb +0 -56
- data/lib/flickr/objects/media.rb +0 -72
- data/lib/flickr/objects/video.rb +0 -21
data/lib/flickr/objects/photo.rb
CHANGED
@@ -1,45 +1,113 @@
|
|
1
|
+
require_relative "attribute_values/photo"
|
2
|
+
require "flickr/api/photo"
|
3
|
+
require "flickr/helpers/base_58"
|
4
|
+
|
1
5
|
class Flickr
|
2
|
-
class Photo <
|
3
|
-
|
4
|
-
attribute :
|
5
|
-
|
6
|
-
attribute :
|
7
|
-
attribute :
|
8
|
-
attribute :
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
+
|
26
83
|
SIZES.keys.each do |size|
|
27
84
|
size_name, size_number = size.split(" ").map(&:downcase)
|
28
85
|
|
29
86
|
define_method("#{size_name}#{size_number}!") { @size = size; self }
|
30
|
-
define_method("#{size_name}#{size_number}") { dup.send("#{
|
87
|
+
define_method("#{size_name}#{size_number}") { dup.send("#{__method__}!") }
|
31
88
|
|
32
89
|
if size_number
|
33
|
-
define_method("#{size_name}!") {|size_number| send("#{size_name}#{size_number}!") }
|
34
|
-
define_method("#{size_name}") {|size_number| send("#{size_name}#{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}") }
|
35
92
|
end
|
36
|
-
end
|
37
93
|
|
38
|
-
|
39
|
-
|
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__}!") }
|
40
107
|
end
|
41
108
|
|
42
109
|
def largest!; @size = largest_size; self end
|
43
110
|
def largest; dup.largest! end
|
111
|
+
|
44
112
|
end
|
45
113
|
end
|
data/lib/flickr/objects/set.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require_relative "attribute_values/set"
|
2
|
+
require "flickr/api/set"
|
3
|
+
|
1
4
|
class Flickr
|
2
5
|
class Set < Object
|
3
6
|
|
@@ -11,20 +14,16 @@ class Flickr
|
|
11
14
|
|
12
15
|
attribute :owner, Person
|
13
16
|
|
14
|
-
attribute :
|
17
|
+
attribute :photos_count, Integer
|
15
18
|
attribute :views_count, Integer
|
16
19
|
attribute :comments_count, Integer
|
17
|
-
attribute :photos_count, Integer
|
18
|
-
attribute :videos_count, Integer
|
19
20
|
|
20
21
|
attribute :permissions, Permissions
|
21
22
|
|
22
23
|
attribute :created_at, Time
|
23
24
|
attribute :updated_at, Time
|
24
25
|
|
25
|
-
attribute :primary_media, Media
|
26
26
|
attribute :primary_photo, Photo
|
27
|
-
attribute :primary_video, Video
|
28
27
|
|
29
28
|
end
|
30
29
|
end
|
data/lib/flickr/objects/tag.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
+
require_relative "attribute_values/upload_ticket"
|
2
|
+
require "flickr/api/upload_ticket"
|
3
|
+
|
1
4
|
class Flickr
|
2
5
|
class UploadTicket < Object
|
3
6
|
|
4
|
-
attribute :id,
|
5
|
-
attribute :status,
|
6
|
-
attribute :invalid
|
7
|
+
attribute :id, String
|
8
|
+
attribute :status, Integer
|
9
|
+
attribute :invalid, Integer
|
7
10
|
|
8
|
-
attribute :
|
9
|
-
attribute :photo, Photo
|
10
|
-
attribute :video, Video
|
11
|
+
attribute :photo, Photo
|
11
12
|
|
12
13
|
def complete?; status == 1 end
|
13
14
|
def failed?; status == 2 end
|
14
15
|
|
16
|
+
def invalid?; invalid == 1 end
|
15
17
|
end
|
16
18
|
end
|
data/lib/flickr/objects.rb
CHANGED
@@ -3,9 +3,7 @@ require "flickr/object"
|
|
3
3
|
class Flickr
|
4
4
|
# Official objects
|
5
5
|
class Person < Object; end
|
6
|
-
class
|
7
|
-
class Photo < Media; end
|
8
|
-
class Video < Media; end
|
6
|
+
class Photo < Object; end
|
9
7
|
class Set < Object; end
|
10
8
|
|
11
9
|
# Meta objects
|
@@ -16,14 +14,11 @@ class Flickr
|
|
16
14
|
class Location < Object; end
|
17
15
|
class UploadTicket < Object; end
|
18
16
|
|
19
|
-
|
17
|
+
autoload :List, "flickr/objects/list"
|
20
18
|
end
|
21
19
|
|
22
20
|
objects = Flickr::Object.children.dup
|
23
21
|
objects.each do |object|
|
24
22
|
underscored_name = object.name.split("::").last.split(/(?<=\w)(?=[A-Z])/).map(&:downcase).join("_")
|
25
23
|
require "flickr/objects/#{underscored_name}"
|
26
|
-
require "flickr/objects/attribute_values/#{underscored_name}"
|
27
|
-
require "flickr/api/#{underscored_name}"
|
28
|
-
require "flickr/api/api_methods/#{underscored_name}"
|
29
24
|
end
|
data/lib/flickr/version.rb
CHANGED
data/lib/flickr.rb
CHANGED
@@ -15,7 +15,12 @@ class Flickr
|
|
15
15
|
def self.api_methods
|
16
16
|
@api_methods ||= Hash.new { |hash, key| hash[key] = [] }
|
17
17
|
end
|
18
|
+
|
19
|
+
def self.deprecation_warn(message)
|
20
|
+
warn "[FLICKR OBJECTS] #{message}"
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
require "flickr/objects"
|
21
25
|
require "flickr/api"
|
26
|
+
require "flickr/oauth"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flickr-objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '2
|
101
|
+
version: '2'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '2
|
109
|
+
version: '2'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: vcr
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '2
|
117
|
+
version: '2'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '2
|
125
|
+
version: '2'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rack-test
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +139,54 @@ dependencies:
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: activesupport
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '3'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '3'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: will_paginate
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '3'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '3'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: kaminari
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0.14'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0.14'
|
142
190
|
description: This gem is an object-oriented wrapper for the Flickr API.
|
143
191
|
email:
|
144
192
|
- janko.marohnic@gmail.com
|
@@ -148,51 +196,34 @@ extra_rdoc_files: []
|
|
148
196
|
files:
|
149
197
|
- README.md
|
150
198
|
- LICENSE
|
151
|
-
- lib/flickr/api/api_methods/collection.rb
|
152
199
|
- lib/flickr/api/api_methods/flickr.rb
|
153
|
-
- lib/flickr/api/api_methods/location.rb
|
154
|
-
- lib/flickr/api/api_methods/media.rb
|
155
|
-
- lib/flickr/api/api_methods/note.rb
|
156
|
-
- lib/flickr/api/api_methods/permissions.rb
|
157
200
|
- lib/flickr/api/api_methods/person.rb
|
158
201
|
- lib/flickr/api/api_methods/photo.rb
|
159
202
|
- lib/flickr/api/api_methods/set.rb
|
160
|
-
- lib/flickr/api/api_methods/tag.rb
|
161
203
|
- lib/flickr/api/api_methods/upload_ticket.rb
|
162
|
-
- lib/flickr/api/api_methods/video.rb
|
163
|
-
- lib/flickr/api/api_methods/visibility.rb
|
164
|
-
- lib/flickr/api/collection.rb
|
165
204
|
- lib/flickr/api/flickr.rb
|
166
|
-
- lib/flickr/api/location.rb
|
167
|
-
- lib/flickr/api/media.rb
|
168
|
-
- lib/flickr/api/note.rb
|
169
|
-
- lib/flickr/api/permissions.rb
|
170
205
|
- lib/flickr/api/person.rb
|
171
206
|
- lib/flickr/api/photo.rb
|
172
207
|
- lib/flickr/api/set.rb
|
173
|
-
- lib/flickr/api/tag.rb
|
174
208
|
- lib/flickr/api/upload_ticket.rb
|
175
|
-
- lib/flickr/api/video.rb
|
176
|
-
- lib/flickr/api/visibility.rb
|
177
209
|
- lib/flickr/api.rb
|
178
210
|
- lib/flickr/api_caller.rb
|
179
211
|
- lib/flickr/client/methods_client.rb
|
180
|
-
- lib/flickr/client/middleware/retry.rb
|
181
|
-
- lib/flickr/client/middleware.rb
|
182
212
|
- lib/flickr/client/upload_client.rb
|
183
213
|
- lib/flickr/client.rb
|
184
214
|
- lib/flickr/configuration.rb
|
215
|
+
- lib/flickr/errors.rb
|
185
216
|
- lib/flickr/helpers/base_58.rb
|
186
217
|
- lib/flickr/helpers/boolean.rb
|
187
218
|
- lib/flickr/helpers/core_ext.rb
|
188
|
-
- lib/flickr/
|
219
|
+
- lib/flickr/middleware.rb
|
220
|
+
- lib/flickr/oauth.rb
|
189
221
|
- lib/flickr/object/attribute/converter.rb
|
190
222
|
- lib/flickr/object/attribute/finder.rb
|
191
223
|
- lib/flickr/object/attribute.rb
|
192
224
|
- lib/flickr/object.rb
|
193
|
-
- lib/flickr/objects/attribute_values/
|
225
|
+
- lib/flickr/objects/attribute_values/list.rb
|
194
226
|
- lib/flickr/objects/attribute_values/location.rb
|
195
|
-
- lib/flickr/objects/attribute_values/media.rb
|
196
227
|
- lib/flickr/objects/attribute_values/note.rb
|
197
228
|
- lib/flickr/objects/attribute_values/permissions.rb
|
198
229
|
- lib/flickr/objects/attribute_values/person.rb
|
@@ -200,11 +231,9 @@ files:
|
|
200
231
|
- lib/flickr/objects/attribute_values/set.rb
|
201
232
|
- lib/flickr/objects/attribute_values/tag.rb
|
202
233
|
- lib/flickr/objects/attribute_values/upload_ticket.rb
|
203
|
-
- lib/flickr/objects/attribute_values/video.rb
|
204
234
|
- lib/flickr/objects/attribute_values/visibility.rb
|
205
|
-
- lib/flickr/objects/
|
235
|
+
- lib/flickr/objects/list.rb
|
206
236
|
- lib/flickr/objects/location.rb
|
207
|
-
- lib/flickr/objects/media.rb
|
208
237
|
- lib/flickr/objects/note.rb
|
209
238
|
- lib/flickr/objects/permissions.rb
|
210
239
|
- lib/flickr/objects/person.rb
|
@@ -212,7 +241,6 @@ files:
|
|
212
241
|
- lib/flickr/objects/set.rb
|
213
242
|
- lib/flickr/objects/tag.rb
|
214
243
|
- lib/flickr/objects/upload_ticket.rb
|
215
|
-
- lib/flickr/objects/video.rb
|
216
244
|
- lib/flickr/objects/visibility.rb
|
217
245
|
- lib/flickr/objects.rb
|
218
246
|
- lib/flickr/version.rb
|
@@ -239,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
267
|
version: '0'
|
240
268
|
segments:
|
241
269
|
- 0
|
242
|
-
hash: -
|
270
|
+
hash: -330563932466293642
|
243
271
|
requirements: []
|
244
272
|
rubyforge_project:
|
245
273
|
rubygems_version: 1.8.23
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Flickr
|
2
|
-
class Media < Object
|
3
|
-
class_api_method :get_from_contacts, "flickr.photos.getContactsPhotos"
|
4
|
-
class_api_method :search, "flickr.photos.search"
|
5
|
-
|
6
|
-
instance_api_method :add_tags, "flickr.photos.addTags"
|
7
|
-
instance_api_method :delete, "flickr.photos.delete"
|
8
|
-
instance_api_method :get_info!, "flickr.photos.getInfo"
|
9
|
-
instance_api_method :get_sizes!, "flickr.photos.getSizes"
|
10
|
-
instance_api_method :remove_tag, "flickr.photos.removeTag"
|
11
|
-
instance_api_method :set_content_type, "flickr.photos.setContentType", aliases: [:content_type=]
|
12
|
-
instance_api_method :set_tags, "flickr.photos.setTags", aliases: [:tags=]
|
13
|
-
end
|
14
|
-
end
|
data/lib/flickr/api/location.rb
DELETED
data/lib/flickr/api/media.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
class Flickr
|
2
|
-
class Media < Object
|
3
|
-
def add_tags(tags, params = {})
|
4
|
-
client.post flickr_method(__method__), params.merge(photo_id: id, tags: tags)
|
5
|
-
tags
|
6
|
-
end
|
7
|
-
|
8
|
-
def delete(params = {})
|
9
|
-
client.post flickr_method(__method__), params.merge(photo_id: id)
|
10
|
-
self
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.get_from_contacts(params = {})
|
14
|
-
response = client.get flickr_method(__method__), handle_extras(params)
|
15
|
-
Collection.new(response["photos"].delete("photo"), Media, response["photos"], client)
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_info!(params = {})
|
19
|
-
response = client.get flickr_method(__method__), params.merge(photo_id: id)
|
20
|
-
@hash.update(response["photo"])
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
def get_sizes!(params = {})
|
25
|
-
response = client.get flickr_method(__method__), params.merge(photo_id: id)
|
26
|
-
@hash.update(response["sizes"])
|
27
|
-
self
|
28
|
-
end
|
29
|
-
|
30
|
-
def remove_tag(tag_id, params = {})
|
31
|
-
client.post flickr_method(__method__), params.merge(photo_id: id, tag_id: tag_id)
|
32
|
-
tag_id
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.search(params = {})
|
36
|
-
response = client.get flickr_method(__method__), handle_extras(params)
|
37
|
-
Collection.new(response["photos"].delete("photo"), self, response["photos"], client)
|
38
|
-
end
|
39
|
-
|
40
|
-
def set_content_type(content_type, params = {})
|
41
|
-
client.post flickr_method(__method__), params.merge(photo_id: id, content_type: content_type)
|
42
|
-
content_type
|
43
|
-
end
|
44
|
-
alias content_type= set_content_type
|
45
|
-
|
46
|
-
def set_tags(tags, params = {})
|
47
|
-
client.post flickr_method(__method__), params.merge(photo_id: id, tags: tags)
|
48
|
-
tags
|
49
|
-
end
|
50
|
-
alias tags= set_tags
|
51
|
-
end
|
52
|
-
end
|
data/lib/flickr/api/note.rb
DELETED
data/lib/flickr/api/tag.rb
DELETED
data/lib/flickr/api/video.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
class Flickr
|
2
|
-
class Client < Faraday::Connection
|
3
|
-
module Middleware
|
4
|
-
class Retry < Faraday::Middleware
|
5
|
-
def initialize(app, options = {})
|
6
|
-
super(app)
|
7
|
-
@retries, options = options, {} if options.is_a? Integer
|
8
|
-
@retries ||= options.fetch(:max, 2).to_i
|
9
|
-
@sleep = options.fetch(:interval, 0).to_f
|
10
|
-
@errmatch = options.fetch(:exceptions) { [Errno::ETIMEDOUT, 'Timeout::Error', Faraday::Error::TimeoutError] }
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(env)
|
14
|
-
retries = @retries
|
15
|
-
begin
|
16
|
-
@app.call(env)
|
17
|
-
rescue *@errmatch
|
18
|
-
if retries > 0
|
19
|
-
retries -= 1
|
20
|
-
sleep @sleep if @sleep > 0
|
21
|
-
retry
|
22
|
-
end
|
23
|
-
raise
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|