flickr-objects 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 804fe3b3024d5bfa5273c6b6ffbb65fd091e85e8
4
- data.tar.gz: 3f80d880bbb6f2cfacaa0e11e144eb962ffe3f18
3
+ metadata.gz: 442add3120c6a46defe96432d84a7ec496a2e574
4
+ data.tar.gz: 8fddbf4731a2871b8427669bc85a235328f91b67
5
5
  SHA512:
6
- metadata.gz: 2c98b7affe1fe3deba5842e135d2640cdf9404c4f36035e0c26e23ef3626590e9725a6a1e2d01ad4228a2a8853e082efdb83f7fb1fa1a3e4245d6979b384fc59
7
- data.tar.gz: c25d0c5f1570a5299c54ba64e30230c3eb2c6f59b23081fe8bf1889aac6d86260ab4303813c58593cf4ed0b372b11c5f742aa44171cd15ed379734bce4760f70
6
+ metadata.gz: 8e23ac266dc1d3d2cf6155433a24e5a46bc7c7ebdde2f010bad05b41a2e410ccc8bab1fe7ca200facfdb6750e2603b9945c4b0eb3c1bb4d5efd7881b6233262e
7
+ data.tar.gz: 8f72874f1ace3b9ba50b827b0cba0516f8a0cc78429db37838ae1d0208be65e45ad2150c516ae081e6049739b824ddb6ae427a70678c69a97067ca05f6686dbe
data/README.md CHANGED
@@ -6,6 +6,12 @@ This gem is an object-oriented wrapper for the [Flickr API](http://flickr.com/ap
6
6
  - Source code: [https://github.com/janko-m/flickr-objects](https://github.com/janko-m/flickr-objects)
7
7
  - API Documentation: [http://rubydoc.info/github/janko-m/flickr-objects/master/frames](http://rubydoc.info/github/janko-m/flickr-objects/master/frames)
8
8
 
9
+ The gem has been tested on the following Ruby versions:
10
+
11
+ - MRI 1.9.3
12
+ - MRI 2.0
13
+ - MRI 2.1
14
+
9
15
  ## Installation and setup
10
16
 
11
17
  Add it to your `Gemfile`, and run `bundle install`.
@@ -129,7 +129,7 @@ module Flickr
129
129
  @attributes["sizes"] && @attributes["sizes"]["size"].find { |h| h["label"] == size.label }
130
130
  end
131
131
 
132
- sizes.map(&:name)
132
+ SIZES.first(9) | sizes.map(&:name) | ["Original"]
133
133
  },
134
134
  ],
135
135
  largest_size: [
@@ -140,15 +140,29 @@ module Flickr
140
140
  ],
141
141
  source_url: [
142
142
  -> { @attributes["url_#{@size.abbreviation}"] },
143
- -> { @attributes["sizes"]["size"].find { |hash| hash["label"] == @size.label }["source"] }
143
+ -> { @attributes["sizes"]["size"].find { |hash| hash["label"] == @size.label }["source"] },
144
+ -> {
145
+ if @size.between?(Size.new("Square 75"), Size.new("Large 1024"))
146
+ url = "https://farm#{farm}.staticflickr.com/#{server}/#{id}_#{secret}"
147
+ url << "_#{@size.other_abbreviation}" if @size.other_abbreviation =~ /\w/
148
+ url << ".jpg"
149
+ url
150
+ elsif @size == Size.new("Original")
151
+ url = "https://farm#{farm}.staticflickr.com/#{server}/#{id}"
152
+ url << "_#{@attributes.fetch("originalsecret")}"
153
+ url << "_o"
154
+ url << ".#{@attributes.fetch("originalformat")}"
155
+ url
156
+ end
157
+ },
144
158
  ],
145
159
  height: [
146
160
  -> { @attributes["height_#{@size.abbreviation}"] },
147
- -> { @attributes["sizes"]["size"].find { |hash| hash["label"] == @size.label }["height"] }
161
+ -> { @attributes["sizes"]["size"].find { |hash| hash["label"] == @size.label }["height"] },
148
162
  ],
149
163
  width: [
150
164
  -> { @attributes["width_#{@size.abbreviation}"] },
151
- -> { @attributes["sizes"]["size"].find { |hash| hash["label"] == @size.label }["width"] }
165
+ -> { @attributes["sizes"]["size"].find { |hash| hash["label"] == @size.label }["width"] },
152
166
  ],
153
167
  url: [
154
168
  -> { "http://www.flickr.com/photos/#{owner.id}/#{id}" if owner.id && id },
@@ -19,6 +19,10 @@ module Flickr
19
19
  # Used by Flickr for hash key names.
20
20
  #
21
21
  ABBREVIATIONS = %w[sq t q s n m z c l h k o]
22
+ ##
23
+ # Used by Flickr for generating source URLs.
24
+ #
25
+ OTHER_ABBREVIATIONS = %w[s t q m n - z c b]
22
26
 
23
27
  ##
24
28
  # Used by Flickr in response from "flickr.photos.getSizes".
@@ -43,13 +47,30 @@ module Flickr
43
47
  all.include? new(name)
44
48
  end
45
49
 
46
- attr_reader :name, :type, :number, :abbreviation, :label
50
+ attr_reader :name
47
51
 
48
52
  def initialize(name)
49
- @name = name
50
- @type, @number = name.split
51
- @abbreviation = ABBREVIATIONS[NAMES.index(name)]
52
- @label = LABELS[NAMES.index(name)]
53
+ @name = name
54
+ end
55
+
56
+ def type
57
+ name.split[0]
58
+ end
59
+
60
+ def number
61
+ name.split[1]
62
+ end
63
+
64
+ def abbreviation
65
+ ABBREVIATIONS[NAMES.index(name)]
66
+ end
67
+
68
+ def other_abbreviation
69
+ OTHER_ABBREVIATIONS[NAMES.index(name)]
70
+ end
71
+
72
+ def label
73
+ LABELS[NAMES.index(name)]
53
74
  end
54
75
 
55
76
  ##
@@ -332,11 +332,7 @@ module Flickr
332
332
  raise ArgumentError, "\"#{name}\" isn't a valid photo size"
333
333
  end
334
334
 
335
- if available_sizes.include? name
336
- @size = Size.new(name)
337
- else
338
- @size = nil
339
- end
335
+ @size = Size.new(name)
340
336
 
341
337
  self
342
338
  end
@@ -1,5 +1,5 @@
1
1
  module Flickr
2
2
 
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickr-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-28 00:00:00.000000000 Z
11
+ date: 2014-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday