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.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +49 -63
  3. data/lib/flickr/api/abstract/params_processor.rb +68 -0
  4. data/lib/flickr/api/abstract.rb +113 -0
  5. data/lib/flickr/api/general.rb +75 -0
  6. data/lib/flickr/api/person.rb +91 -39
  7. data/lib/flickr/api/photo.rb +213 -108
  8. data/lib/flickr/api/set.rb +114 -55
  9. data/lib/flickr/api/upload_ticket.rb +17 -6
  10. data/lib/flickr/api.rb +90 -35
  11. data/lib/flickr/attributes.rb +200 -0
  12. data/lib/flickr/base_converter.rb +29 -0
  13. data/lib/flickr/client/data.rb +47 -0
  14. data/lib/flickr/client/oauth.rb +44 -0
  15. data/lib/flickr/client/upload.rb +55 -0
  16. data/lib/flickr/client.rb +77 -33
  17. data/lib/flickr/configuration.rb +85 -14
  18. data/lib/flickr/error.rb +58 -0
  19. data/lib/flickr/middleware.rb +52 -28
  20. data/lib/flickr/oauth.rb +89 -74
  21. data/lib/flickr/object/attribute_locations/list.rb +25 -0
  22. data/lib/flickr/object/attribute_locations/location.rb +29 -0
  23. data/lib/flickr/object/attribute_locations/permissions.rb +31 -0
  24. data/lib/flickr/object/attribute_locations/person/upload_status.rb +32 -0
  25. data/lib/flickr/object/attribute_locations/person.rb +78 -0
  26. data/lib/flickr/object/attribute_locations/photo/exif.rb +29 -0
  27. data/lib/flickr/object/attribute_locations/photo/note.rb +36 -0
  28. data/lib/flickr/object/attribute_locations/photo/tag.rb +23 -0
  29. data/lib/flickr/object/attribute_locations/photo.rb +164 -0
  30. data/lib/flickr/object/attribute_locations/set.rb +53 -0
  31. data/lib/flickr/object/attribute_locations/upload_ticket.rb +30 -0
  32. data/lib/flickr/object/attribute_locations/visibility.rb +24 -0
  33. data/lib/flickr/object/list/kaminari.rb +30 -0
  34. data/lib/flickr/object/list/normal.rb +27 -0
  35. data/lib/flickr/object/list/will_paginate.rb +31 -0
  36. data/lib/flickr/object/list.rb +87 -0
  37. data/lib/flickr/object/location.rb +35 -0
  38. data/lib/flickr/object/permissions.rb +18 -0
  39. data/lib/flickr/object/person/upload_status.rb +22 -0
  40. data/lib/flickr/object/person.rb +93 -0
  41. data/lib/flickr/object/photo/exif.rb +35 -0
  42. data/lib/flickr/object/photo/note.rb +20 -0
  43. data/lib/flickr/object/photo/size.rb +67 -0
  44. data/lib/flickr/object/photo/tag.rb +23 -0
  45. data/lib/flickr/object/photo.rb +349 -0
  46. data/lib/flickr/object/set.rb +114 -0
  47. data/lib/flickr/object/upload_ticket.rb +31 -0
  48. data/lib/flickr/object/visibility.rb +16 -0
  49. data/lib/flickr/object.rb +118 -27
  50. data/lib/flickr/sanitized_file.rb +70 -0
  51. data/lib/flickr/version.rb +4 -2
  52. data/lib/flickr.rb +69 -15
  53. metadata +89 -103
  54. data/lib/flickr/api/api_methods/flickr.rb +0 -5
  55. data/lib/flickr/api/api_methods/person.rb +0 -14
  56. data/lib/flickr/api/api_methods/photo.rb +0 -26
  57. data/lib/flickr/api/api_methods/set.rb +0 -18
  58. data/lib/flickr/api/api_methods/upload_ticket.rb +0 -5
  59. data/lib/flickr/api/flickr.rb +0 -35
  60. data/lib/flickr/api_caller.rb +0 -98
  61. data/lib/flickr/client/methods_client.rb +0 -22
  62. data/lib/flickr/client/upload_client.rb +0 -62
  63. data/lib/flickr/errors.rb +0 -19
  64. data/lib/flickr/helpers/base_58.rb +0 -15
  65. data/lib/flickr/helpers/boolean.rb +0 -4
  66. data/lib/flickr/helpers/core_ext.rb +0 -5
  67. data/lib/flickr/object/attribute/converter.rb +0 -49
  68. data/lib/flickr/object/attribute/finder.rb +0 -32
  69. data/lib/flickr/object/attribute.rb +0 -45
  70. data/lib/flickr/objects/attribute_values/list.rb +0 -10
  71. data/lib/flickr/objects/attribute_values/location.rb +0 -14
  72. data/lib/flickr/objects/attribute_values/note.rb +0 -11
  73. data/lib/flickr/objects/attribute_values/permissions.rb +0 -12
  74. data/lib/flickr/objects/attribute_values/person/upload_status.rb +0 -16
  75. data/lib/flickr/objects/attribute_values/person.rb +0 -24
  76. data/lib/flickr/objects/attribute_values/photo.rb +0 -84
  77. data/lib/flickr/objects/attribute_values/set.rb +0 -17
  78. data/lib/flickr/objects/attribute_values/tag.rb +0 -9
  79. data/lib/flickr/objects/attribute_values/upload_ticket.rb +0 -9
  80. data/lib/flickr/objects/attribute_values/visibility.rb +0 -10
  81. data/lib/flickr/objects/list.rb +0 -86
  82. data/lib/flickr/objects/location.rb +0 -26
  83. data/lib/flickr/objects/note.rb +0 -14
  84. data/lib/flickr/objects/permissions.rb +0 -14
  85. data/lib/flickr/objects/person/upload_status.rb +0 -14
  86. data/lib/flickr/objects/person.rb +0 -43
  87. data/lib/flickr/objects/photo.rb +0 -113
  88. data/lib/flickr/objects/set.rb +0 -29
  89. data/lib/flickr/objects/tag.rb +0 -17
  90. data/lib/flickr/objects/upload_ticket.rb +0 -18
  91. data/lib/flickr/objects/visibility.rb +0 -12
  92. data/lib/flickr/objects.rb +0 -25
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickr-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
- - Janko Marohnić
7
+ - Janko Marohnić
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-07 00:00:00.000000000 Z
11
+ date: 2013-10-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: faraday
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.7.6
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.7.6
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: faraday_middleware
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0.8'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0.8'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: simple_oauth
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: multi_xml
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,115 +69,115 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '2'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '2'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: vcr
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '2'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '2'
126
111
  - !ruby/object:Gem::Dependency
127
- name: rack-test
112
+ name: activesupport
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
- version: '0'
117
+ version: '3'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
- version: '0'
124
+ version: '3'
142
125
  - !ruby/object:Gem::Dependency
143
- name: activesupport
126
+ name: will_paginate
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - '>='
148
130
  - !ruby/object:Gem::Version
149
131
  version: '3'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - '>='
156
137
  - !ruby/object:Gem::Version
157
138
  version: '3'
158
139
  - !ruby/object:Gem::Dependency
159
- name: will_paginate
140
+ name: kaminari
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - '>='
164
144
  - !ruby/object:Gem::Version
165
- version: '3'
145
+ version: '0.14'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - '>='
172
151
  - !ruby/object:Gem::Version
173
- version: '3'
152
+ version: '0.14'
174
153
  - !ruby/object:Gem::Dependency
175
- name: kaminari
154
+ name: capybara
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - '>='
180
158
  - !ruby/object:Gem::Version
181
- version: '0.14'
159
+ version: '2.1'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - '>='
188
165
  - !ruby/object:Gem::Version
189
- version: '0.14'
166
+ version: '2.1'
167
+ - !ruby/object:Gem::Dependency
168
+ name: selenium-webdriver
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 2.35.1
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: 2.35.1
190
181
  description: This gem is an object-oriented wrapper for the Flickr API.
191
182
  email:
192
183
  - janko.marohnic@gmail.com
@@ -196,84 +187,79 @@ extra_rdoc_files: []
196
187
  files:
197
188
  - README.md
198
189
  - LICENSE
199
- - lib/flickr/api/api_methods/flickr.rb
200
- - lib/flickr/api/api_methods/person.rb
201
- - lib/flickr/api/api_methods/photo.rb
202
- - lib/flickr/api/api_methods/set.rb
203
- - lib/flickr/api/api_methods/upload_ticket.rb
204
- - lib/flickr/api/flickr.rb
190
+ - lib/flickr/api/abstract/params_processor.rb
191
+ - lib/flickr/api/abstract.rb
192
+ - lib/flickr/api/general.rb
205
193
  - lib/flickr/api/person.rb
206
194
  - lib/flickr/api/photo.rb
207
195
  - lib/flickr/api/set.rb
208
196
  - lib/flickr/api/upload_ticket.rb
209
197
  - lib/flickr/api.rb
210
- - lib/flickr/api_caller.rb
211
- - lib/flickr/client/methods_client.rb
212
- - lib/flickr/client/upload_client.rb
198
+ - lib/flickr/attributes.rb
199
+ - lib/flickr/base_converter.rb
200
+ - lib/flickr/client/data.rb
201
+ - lib/flickr/client/oauth.rb
202
+ - lib/flickr/client/upload.rb
213
203
  - lib/flickr/client.rb
214
204
  - lib/flickr/configuration.rb
215
- - lib/flickr/errors.rb
216
- - lib/flickr/helpers/base_58.rb
217
- - lib/flickr/helpers/boolean.rb
218
- - lib/flickr/helpers/core_ext.rb
205
+ - lib/flickr/error.rb
219
206
  - lib/flickr/middleware.rb
220
207
  - lib/flickr/oauth.rb
221
- - lib/flickr/object/attribute/converter.rb
222
- - lib/flickr/object/attribute/finder.rb
223
- - lib/flickr/object/attribute.rb
208
+ - lib/flickr/object/attribute_locations/list.rb
209
+ - lib/flickr/object/attribute_locations/location.rb
210
+ - lib/flickr/object/attribute_locations/permissions.rb
211
+ - lib/flickr/object/attribute_locations/person/upload_status.rb
212
+ - lib/flickr/object/attribute_locations/person.rb
213
+ - lib/flickr/object/attribute_locations/photo/exif.rb
214
+ - lib/flickr/object/attribute_locations/photo/note.rb
215
+ - lib/flickr/object/attribute_locations/photo/tag.rb
216
+ - lib/flickr/object/attribute_locations/photo.rb
217
+ - lib/flickr/object/attribute_locations/set.rb
218
+ - lib/flickr/object/attribute_locations/upload_ticket.rb
219
+ - lib/flickr/object/attribute_locations/visibility.rb
220
+ - lib/flickr/object/list/kaminari.rb
221
+ - lib/flickr/object/list/normal.rb
222
+ - lib/flickr/object/list/will_paginate.rb
223
+ - lib/flickr/object/list.rb
224
+ - lib/flickr/object/location.rb
225
+ - lib/flickr/object/permissions.rb
226
+ - lib/flickr/object/person/upload_status.rb
227
+ - lib/flickr/object/person.rb
228
+ - lib/flickr/object/photo/exif.rb
229
+ - lib/flickr/object/photo/note.rb
230
+ - lib/flickr/object/photo/size.rb
231
+ - lib/flickr/object/photo/tag.rb
232
+ - lib/flickr/object/photo.rb
233
+ - lib/flickr/object/set.rb
234
+ - lib/flickr/object/upload_ticket.rb
235
+ - lib/flickr/object/visibility.rb
224
236
  - lib/flickr/object.rb
225
- - lib/flickr/objects/attribute_values/list.rb
226
- - lib/flickr/objects/attribute_values/location.rb
227
- - lib/flickr/objects/attribute_values/note.rb
228
- - lib/flickr/objects/attribute_values/permissions.rb
229
- - lib/flickr/objects/attribute_values/person/upload_status.rb
230
- - lib/flickr/objects/attribute_values/person.rb
231
- - lib/flickr/objects/attribute_values/photo.rb
232
- - lib/flickr/objects/attribute_values/set.rb
233
- - lib/flickr/objects/attribute_values/tag.rb
234
- - lib/flickr/objects/attribute_values/upload_ticket.rb
235
- - lib/flickr/objects/attribute_values/visibility.rb
236
- - lib/flickr/objects/list.rb
237
- - lib/flickr/objects/location.rb
238
- - lib/flickr/objects/note.rb
239
- - lib/flickr/objects/permissions.rb
240
- - lib/flickr/objects/person/upload_status.rb
241
- - lib/flickr/objects/person.rb
242
- - lib/flickr/objects/photo.rb
243
- - lib/flickr/objects/set.rb
244
- - lib/flickr/objects/tag.rb
245
- - lib/flickr/objects/upload_ticket.rb
246
- - lib/flickr/objects/visibility.rb
247
- - lib/flickr/objects.rb
237
+ - lib/flickr/sanitized_file.rb
248
238
  - lib/flickr/version.rb
249
239
  - lib/flickr-objects.rb
250
240
  - lib/flickr.rb
251
- homepage: http://janko-m.github.com/flickr-objects/
241
+ homepage: http://janko-m.github.com/flickr-objects
252
242
  licenses:
253
243
  - MIT
244
+ metadata: {}
254
245
  post_install_message:
255
246
  rdoc_options: []
256
247
  require_paths:
257
248
  - lib
258
249
  required_ruby_version: !ruby/object:Gem::Requirement
259
- none: false
260
250
  requirements:
261
- - - ! '>='
251
+ - - '>='
262
252
  - !ruby/object:Gem::Version
263
253
  version: 1.9.2
264
254
  required_rubygems_version: !ruby/object:Gem::Requirement
265
- none: false
266
255
  requirements:
267
- - - ! '>='
256
+ - - '>='
268
257
  - !ruby/object:Gem::Version
269
258
  version: '0'
270
- segments:
271
- - 0
272
- hash: -3989441013380527644
273
259
  requirements: []
274
260
  rubyforge_project:
275
- rubygems_version: 1.8.23
261
+ rubygems_version: 2.1.0
276
262
  signing_key:
277
- specification_version: 3
263
+ specification_version: 4
278
264
  summary: This gem is an object-oriented wrapper for the Flickr API.
279
265
  test_files: []
@@ -1,5 +0,0 @@
1
- class Flickr
2
- api_method :test_login, "flickr.test.login"
3
- api_method :test_echo, "flickr.test.echo"
4
- api_method :test_null, "flickr.test.null"
5
- end
@@ -1,14 +0,0 @@
1
- class Flickr
2
- class Person < Object
3
- class_api_method :find_by_email, "flickr.people.findByEmail"
4
- class_api_method :find_by_username, "flickr.people.findByUsername"
5
- class_api_method :get_upload_status, "flickr.people.getUploadStatus"
6
-
7
- instance_api_method :get_info!, "flickr.people.getInfo"
8
- instance_api_method :get_photos, "flickr.people.getPhotos"
9
- instance_api_method :get_photos_of, "flickr.people.getPhotosOf"
10
- instance_api_method :get_public_photos, "flickr.people.getPublicPhotos"
11
- instance_api_method :get_public_photos_from_contacts, "flickr.photos.getContactsPublicPhotos"
12
- instance_api_method :get_sets, "flickr.photosets.getList"
13
- end
14
- end
@@ -1,26 +0,0 @@
1
- class Flickr
2
- class Photo < Object
3
- class_api_method :get_from_contacts, "flickr.photos.getContactsPhotos"
4
- class_api_method :search, "flickr.photos.search"
5
- class_api_method :delete, "flickr.photos.delete"
6
- class_api_method :get_not_in_set, "flickr.photos.getNotInSet"
7
- class_api_method :get_recent, "flickr.photos.getRecent"
8
- class_api_method :get_untagged, "flickr.photos.getUntagged"
9
- class_api_method :get_with_geo_data, "flickr.photos.getWithGeoData"
10
- class_api_method :get_without_geo_data, "flickr.photos.getWithoutGeoData"
11
- class_api_method :get_recently_updated, "flickr.photos.RecentlyUpdated"
12
-
13
- instance_api_method :add_tags, "flickr.photos.addTags"
14
- instance_api_method :delete, "flickr.photos.delete"
15
- instance_api_method :get_info!, "flickr.photos.getInfo"
16
- instance_api_method :get_sizes!, "flickr.photos.getSizes"
17
- instance_api_method :get_favorites, "flickr.photos.getFavorites"
18
- instance_api_method :remove_tag, "flickr.photos.removeTag"
19
- instance_api_method :set_content_type, "flickr.photos.setContentType", aliases: [:content_type=]
20
- instance_api_method :set_tags, "flickr.photos.setTags", aliases: [:tags=]
21
- instance_api_method :set_dates, "flickr.photos.setDates"
22
- instance_api_method :set_meta, "flickr.photos.setMeta"
23
- instance_api_method :set_permissions, "flickr.photos.setPerms"
24
- instance_api_method :set_safety_level, "flickr.photos.setSafetyLevel"
25
- end
26
- end
@@ -1,18 +0,0 @@
1
- class Flickr
2
- class Set < Object
3
- class_api_method :create, "flickr.photosets.create"
4
- class_api_method :delete, "flickr.photosets.delete"
5
- class_api_method :order, "flickr.photosets.orderSets"
6
-
7
- instance_api_method :add_photo, "flickr.photosets.addPhoto"
8
- instance_api_method :delete, "flickr.photosets.delete"
9
- instance_api_method :edit_photos, "flickr.photosets.editPhotos"
10
- instance_api_method :get_info!, "flickr.photosets.getInfo"
11
- instance_api_method :get_photos, "flickr.photosets.getPhotos"
12
- instance_api_method :remove_photos, "flickr.photosets.removePhotos"
13
- instance_api_method :remove_photo, "flickr.photosets.removePhoto"
14
- instance_api_method :edit_meta, "flickr.photosets.editMeta"
15
- instance_api_method :reorder_photos, "flickr.photosets.reorderPhotos"
16
- instance_api_method :set_primary_photo, "flickr.photosets.setPrimaryPhoto", aliases: [:primary_photo=]
17
- end
18
- end
@@ -1,5 +0,0 @@
1
- class Flickr
2
- class UploadTicket < Object
3
- class_api_method :check, "flickr.photos.upload.checkTickets"
4
- end
5
- end
@@ -1,35 +0,0 @@
1
- require_relative "api_methods/flickr"
2
-
3
- class Flickr
4
- api_methods = proc do
5
- def upload(photo, params = {})
6
- response = upload_client.upload(photo, params)
7
- params[:async] == 1 ? response["ticketid"] : response["photoid"]
8
- end
9
-
10
- def replace(photo, id, params = {})
11
- response = upload_client.replace(photo, id, params)
12
- params[:async] == 1 ? response["ticketid"] : response["photoid"]
13
- end
14
-
15
- def check_upload_tickets(tickets, params = {})
16
- Flickr.deprecation_warn "`Flickr.check_upload_tickets` is deprecated. Use `Flickr.upload_tickets.check` instead."
17
- upload_tickets.check(tickets, params)
18
- end
19
-
20
- def test_login(params = {})
21
- client.get f(__method__), params
22
- end
23
-
24
- def test_echo(params = {})
25
- client.get f(__method__), params
26
- end
27
-
28
- def test_null(params = {})
29
- client.get f(__method__), params
30
- end
31
- end
32
-
33
- instance_eval(&api_methods)
34
- class_eval(&api_methods)
35
- end
@@ -1,98 +0,0 @@
1
- class Flickr
2
- module ApiCaller
3
-
4
- def self.included(base)
5
- base.send(:include, ClientMethods) unless base == Flickr
6
- base.send(:include, ApiMethods)
7
- base.send(:include, ParamsFixingMethods)
8
- end
9
-
10
- module ClientMethods
11
- def self.included(base)
12
- base.send(:include, Methods)
13
- base.send(:extend, Methods)
14
- end
15
-
16
- module Methods
17
- attr_reader :client
18
- end
19
- end
20
-
21
- module ApiMethods
22
- def self.included(base)
23
- base.send(:include, InstanceMethods)
24
- base.send(:extend, ClassMethods)
25
- end
26
-
27
- module ClassMethods
28
- def instance_api_method(method, flickr_method, options = {})
29
- [method, *options[:aliases]].each do |method|
30
- Flickr.api_methods[flickr_method] << "#{self.name}##{method}"
31
- end
32
- end
33
-
34
- def class_api_method(method, flickr_method, options = {})
35
- [method, *options[:aliases]].each do |method|
36
- Flickr.api_methods[flickr_method] << "#{self.name}.#{method}"
37
- end
38
- end
39
-
40
- def api_method(*args)
41
- instance_api_method(*args)
42
- class_api_method(*args)
43
- end
44
-
45
- def f(method_name)
46
- resolve_flickr_method("#{self.name}.#{method_name}")
47
- end
48
-
49
- def resolve_flickr_method(full_method_name)
50
- pair = Flickr.api_methods.find { |key, value| value.include?(full_method_name) }
51
- pair.first
52
-
53
- rescue NoMethodError
54
- raise "method #{full_method_name} is not registered"
55
- end
56
- end
57
-
58
- module InstanceMethods
59
- def f(method_name)
60
- self.class.resolve_flickr_method("#{self.class.name}##{method_name}")
61
- end
62
- end
63
- end
64
-
65
- module ParamsFixingMethods
66
- def self.included(base)
67
- base.send(:include, Methods)
68
- base.send(:extend, Methods)
69
- end
70
-
71
- module Methods
72
- def handle_extras(params)
73
- include_sizes(params)
74
- end
75
-
76
- def include_sizes(params)
77
- return params if params[:sizes].nil?
78
-
79
- abbrs = case params[:sizes]
80
- when :all
81
- Photo::SIZES.values
82
- else
83
- params[:sizes].map { |size| Photo::SIZES[size] }
84
- end
85
- urls = abbrs.map { |abbr| "url_#{abbr}" }.join(",")
86
- include_in_extras(params, urls)
87
- end
88
-
89
- def include_in_extras(params, things)
90
- params.dup.tap do |params|
91
- params[:extras] = [params[:extras], things].compact.join(",")
92
- end
93
- end
94
- end
95
- end
96
-
97
- end
98
- end
@@ -1,22 +0,0 @@
1
- class Flickr
2
- class MethodsClient < Client
3
- def initialize(access_token)
4
- super(access_token)
5
- end
6
-
7
- [:get, :post].each do |http_method|
8
- define_method(http_method) do |flickr_method, params = {}|
9
- response = super("rest") do |req|
10
- req.params[:method] = flickr_method
11
- req.params.update(params)
12
- end
13
-
14
- response.body
15
- end
16
- end
17
-
18
- def parser
19
- FaradayMiddleware::ParseJson
20
- end
21
- end
22
- end
@@ -1,62 +0,0 @@
1
- class Flickr
2
- class UploadClient < Client
3
- def initialize(access_token)
4
- super(access_token) do |builder|
5
- builder.use Faraday::Request::Multipart
6
- end
7
- end
8
-
9
- def upload(photo, params = {})
10
- response = post "upload", {photo: get_file(photo)}.merge(params)
11
- response.body
12
- end
13
-
14
- def replace(photo, id, params = {})
15
- response = post "replace", {photo: get_file(photo), photo_id: id}.merge(params)
16
- response.body
17
- end
18
-
19
- def parser
20
- FaradayMiddleware::ParseXml
21
- end
22
-
23
- private
24
-
25
- def get_file(object)
26
- file, content_type, file_path =
27
- if object.is_a?(String)
28
- [File.open(object), determine_content_type(object), object]
29
- elsif object.class.name == "ActionDispatch::Http::UploadedFile"
30
- [object, object.content_type, object.tempfile]
31
- elsif object.respond_to?(:read) and object.respond_to?(:path)
32
- [object, (object.respond_to?(:content_type) && object.content_type) || determine_content_type(object.path), object.path]
33
- elsif object.is_a?(Hash) && defined?(Sinatra)
34
- [object[:tempfile], object[:type], object[:tempfile].path]
35
- else
36
- raise Error, "invalid file format"
37
- end
38
-
39
- Faraday::UploadIO.new(file, content_type, file_path)
40
- end
41
-
42
- def determine_content_type(path)
43
- extension = File.extname(path)
44
- array = CONTENT_TYPES.keys.find { |array| array.include?(extension) }
45
-
46
- if array
47
- CONTENT_TYPES[array]
48
- else
49
- raise Error, "content type for #{extension} is not known"
50
- end
51
- end
52
-
53
- CONTENT_TYPES = {
54
- %w[.jpg .jpeg .jpe .jif .jfif .jfi] => 'image/jpeg',
55
- %w[.gif] => 'image/gif',
56
- %w[.png] => 'image/png',
57
- %w[.svg .svgz] => 'image/svg+xml',
58
- %w[.tiff .tif] => 'image/tiff',
59
- %w[.ico] => 'image/vnd.microsoft.icon',
60
- }
61
- end
62
- end
data/lib/flickr/errors.rb DELETED
@@ -1,19 +0,0 @@
1
- class Flickr
2
- class Error < StandardError
3
- end
4
-
5
- class OAuthError < Error
6
- end
7
-
8
- class ApiError < Error
9
- attr_reader :code
10
-
11
- def initialize(message, code = nil)
12
- super(message)
13
- @code = code.to_i
14
- end
15
- end
16
-
17
- class TimeoutError < Error
18
- end
19
- end