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
@@ -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
@@ -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
@@ -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
@@ -1,12 +0,0 @@
1
- require_relative "attribute_values/visibility"
2
-
3
- class Flickr
4
- class Visibility < Object
5
-
6
- attribute :public?, Boolean
7
- attribute :friends?, Boolean
8
- attribute :family?, Boolean
9
- attribute :contacts?, Boolean
10
-
11
- end
12
- end
@@ -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