poms 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78e9433c8f38f2c4de4f013581f8f3572e4ece16
4
- data.tar.gz: 1fa2c45484e1fb6e903aff27231395fb2046e3ad
3
+ metadata.gz: d268f605a793eec5d34d3eda6c400f679a07d2c1
4
+ data.tar.gz: 93aa682457183d55b7f959d124e8bbe1142bc433
5
5
  SHA512:
6
- metadata.gz: 76759dbdaf559477a2638397850cc9ae04993413bf0bbbebf9d3c0308846471bf024d3d0418f82e35b551849ae64d35e2cd326e4722fb0c0dc28a4c7438aced6
7
- data.tar.gz: 89a19e664c92c401063d09e03b9b7904dc3eaf9b8c5880bcf611b31eb3c81218806a8e09e062ba5006c26333aff4c6e9707e9f23dda1c7ef89dcf16f282b6e70
6
+ metadata.gz: 76f56dc3d7d826dee54d4edec5a93079b201ff257d1e9443633b67c437009d8c91291b42353fc6342430c0b4f36b8eeccc14d4135b100c9038e38fa1b0914754
7
+ data.tar.gz: 8fb05d5b1161e897a7c6dccdba6e21f608fd54fb9f1db641b444645a0eb9f89b81af292f23b75e233e4b50ff9472a5c274a23cb4068f178c359c500e7db092e3
data/.rubocop.yml CHANGED
@@ -20,6 +20,9 @@ Style/AndOr:
20
20
  - 'lib/poms.rb' # here we do rely on how `or` has lower precedence than `||`
21
21
  - 'lib/poms/configuration.rb' # here we do rely on how `or` has lower precedence than `||`
22
22
 
23
+ Style/FrozenStringLiteralComment:
24
+ Enabled: false
25
+
23
26
  ModuleLength:
24
27
  Exclude:
25
28
  - spec/**/*_spec.rb # specs are only in module for easier access to functions
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Poms Release notes
2
2
 
3
+ ## 2.1.2
4
+
5
+ * Extend Poms::Fields.position target specified parent
6
+
3
7
  ## 2.1.1
4
8
 
5
9
  * Add `addressable` to gemspec.
data/lib/poms/fields.rb CHANGED
@@ -65,10 +65,34 @@ module Poms
65
65
  Timestamp.to_datetime(internetvod['publishStop'])
66
66
  end
67
67
 
68
- # Returns the position in the parent context if it is present.
69
- def position(item)
70
- parent = item['memberOf']
71
- parent.first['index'] if parent.present?
68
+ # Returns the index at which it is in the parent. When no
69
+ # :member_of keyword is given, it will return the first found
70
+ # index. Else, when a parent is found with matching member_of
71
+ # midref, it returns that index. Else returns nil.
72
+ # @param item The Poms Hash
73
+ # @param optional :member_of The midref of parent for which we
74
+ # seek the index
75
+ def position(item, member_of: nil)
76
+ parent(item, midref: member_of).try(:[], 'index')
77
+ end
78
+
79
+ # Finds a parent the data is "member of". If :midref is given, it
80
+ # will look for the parent that matches that mid and return nil if
81
+ # not found. Without the :midref it will return the first parent.
82
+ # @param item The Poms Hash
83
+ # @param optional midref The midref of parent we seek.
84
+ def parent(item, midref: nil)
85
+ if midref
86
+ parents(item).find { |parent| parent['midRef'] == midref }
87
+ else
88
+ parents(item).first
89
+ end
90
+ end
91
+
92
+ # Returns the parents that the element is member of. Will always
93
+ # return an array.
94
+ def parents(item)
95
+ Array(item['memberOf'])
72
96
  end
73
97
 
74
98
  # Returns an array of start and end times for the scheduled events for
data/lib/poms/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # The version
2
2
  module Poms
3
- VERSION = '2.1.1'.freeze
3
+ VERSION = '2.1.2'.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.1
4
+ version: 2.1.2
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-06-30 00:00:00.000000000 Z
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport