poms 2.1.2.1 → 2.1.3

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: 746d25a8022f2668464a0fb396c6b02f3e2d4ab0
4
- data.tar.gz: 4e07b85a5a0950e1da37e8385251f2ec9b4d642c
3
+ metadata.gz: f974c08408f4d51d55403210e099410fd2030fea
4
+ data.tar.gz: a8621cc51d99c4257639d45addec5c55f4170d0f
5
5
  SHA512:
6
- metadata.gz: 719ccd46f6e2e1ed7b408921dc87c2170cf007de1a86195d572a98fbe504ac4ebd176210fbfed31d0d098893a80bac92f6f7fbe7523c419e395967e6e7017bef
7
- data.tar.gz: bbc3fc1df1e5a72938d406d38854fbc75d9faf8f30794626a580e790599fa5f95801dc6e7a3f8f85198355002d085f2936639c4e7fe14fa2c828b90bb536cc9c
6
+ metadata.gz: 4b0f22e2f765d73fcbe1ab67be1003f7b328c21181ebf3006d20a05a5f16049a17e63d75cdd95bc8af09229b2b4f05d16785a916115460c2adcbc790b3528578
7
+ data.tar.gz: 0a6bd52ccd8123d5da464c1406599b7f182e0cb216b75032640c92e5d2c7ec4830ebc7f19c26240ef517d93ec5482339642c38935f368cc7d31514d086e990da
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Poms Release notes
2
2
 
3
+ ## 2.1.3
4
+
5
+ * Order images array by likelyhood of a higher quality image (type: PROMO_LANDSCAPE > PICTURE > STILL).
6
+
3
7
  ## 2.1.2.1
4
8
 
5
9
  * Fix a minor bug on `Poms::Fields.title`. This could be triggered when a result from a Poms query would be empty. `nil` would be sumitted and the provided key would be called on `nil` which caused an error. Now it will simply return `nil` as a title.
data/lib/poms/fields.rb CHANGED
@@ -6,6 +6,8 @@ module Poms
6
6
  module Fields
7
7
  module_function
8
8
 
9
+ IMAGE_TYPE_PRIORITY = %w(PROMO_LANDSCAPE PICTURE).freeze
10
+
9
11
  # Returns the title, main by default
10
12
  def title(item, type = 'MAIN')
11
13
  value_of_type(item, 'titles', type)
@@ -18,7 +20,9 @@ module Poms
18
20
 
19
21
  # Returns the images from the hash
20
22
  def images(item)
21
- item['images']
23
+ item['images'].try(:sort_by) do |i|
24
+ image_order_index(i)
25
+ end
22
26
  end
23
27
 
24
28
  # Extracts the image id from an image hash
@@ -28,7 +32,11 @@ module Poms
28
32
  image['imageUri'].split(':').last
29
33
  end
30
34
 
31
- # Returns the id of the first image of nil if there are none.
35
+ def image_order_index(image)
36
+ IMAGE_TYPE_PRIORITY.index(image['type']) || IMAGE_TYPE_PRIORITY.size
37
+ end
38
+
39
+ # Returns the id of the first image or nil if there are none.
32
40
  def first_image_id(item)
33
41
  return unless images(item)
34
42
  image_id(images(item).first)
data/lib/poms/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # The version
2
2
  module Poms
3
- VERSION = '2.1.2.1'.freeze
3
+ VERSION = '2.1.3'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2.1
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Kruijsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  version: '0'
269
269
  requirements: []
270
270
  rubyforge_project:
271
- rubygems_version: 2.6.4
271
+ rubygems_version: 2.5.1
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: Interface to POMS CouchDB API