parliament-grom-decorators 0.16.1 → 0.16.3

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: 1a18cf6f6ebcd272403e02d375bf359fc43ad6cb
4
- data.tar.gz: 3bc8624b4104b47b6ce41ecce76343ec41ab09ab
3
+ metadata.gz: ea8192e3154588594800bbaeef46e1a1ef244904
4
+ data.tar.gz: 32dc25c2e07bea9ce588142d263cdbabd714f4c7
5
5
  SHA512:
6
- metadata.gz: 8dcb4d03ab7d15d485c08113c6b4888f39cc37ef46ad555c75004c729215dda0611aa5bc5429a401f23dfded828ba9d331fb01f24ec8d339482a99b8c04d139d
7
- data.tar.gz: 6b507ecb6f981ea0e5fcb2b71e3177911f4ce725fe8753f54752d6bbef81e8cf23ab58983274377f84cab618a1aa484d52a1561395ead87b77fd26f7758c9e16
6
+ metadata.gz: ef2c332128f1170b698fbebad46a2a8382b98b27fa32614e034d9e6667e278b97666ccbee2f389dcc4804f5e1079779b85d4851cdb5b4345c32afbc63d4e082c
7
+ data.tar.gz: 58b58e5522920c6779ff0efd89916ee4d41ec9a13145f31cfd099648ba2ac0904407a17d1eb5f5f80df44c9be9fa00ec919b6d5b3175dc338d3b1d696565eeb4
@@ -26,6 +26,7 @@ require 'parliament/grom/decorator/web_article'
26
26
  require 'parliament/grom/decorator/audience'
27
27
  require 'parliament/grom/decorator/article_type'
28
28
  require 'parliament/grom/decorator/collection'
29
+ require 'parliament/grom/decorator/concept'
29
30
 
30
31
  # Namespace for classes and modules that handle connections to, and processing of data from the parliamentary API.
31
32
  # @since 0.1.0
@@ -0,0 +1,50 @@
1
+ module Parliament
2
+ module Grom
3
+ module Decorator
4
+ # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Concept
5
+ module Concept
6
+ # Alias conceptLabel with fallback.
7
+ #
8
+ # @return [String, String] the IDMS title of the Grom::Node or an empty string.
9
+ def name
10
+ respond_to?(:conceptLabel) ? conceptLabel : ''
11
+ end
12
+
13
+ # Alias conceptScopeNote with fallback.
14
+ #
15
+ # @return [String, String] the IDMS description of the Grom::Node or an empty string.
16
+ def description
17
+ respond_to?(:conceptScopeNote) ? conceptScopeNote : ''
18
+ end
19
+
20
+ # Alias conceptDefinition with fallback.
21
+ #
22
+ # @return [String, String] the IDMS description of the Grom::Node or an empty string.
23
+ def definition
24
+ respond_to?(:conceptDefinition) ? conceptDefinition : ''
25
+ end
26
+
27
+ # Alias conceptHasSubjectTaggedThing with fallback.
28
+ #
29
+ # @return [Array, Array] array of WebArticle Grom::Nodes tagged with that concept or an empty array.
30
+ def tagged_articles
31
+ respond_to?(:conceptHasSubjectTaggedThing) ? conceptHasSubjectTaggedThing : []
32
+ end
33
+
34
+ # Alias conceptHasBroaderConcept with fallback.
35
+ #
36
+ # @return [Array, Array] array of parent Concept Grom::Nodes or an empty array.
37
+ def parent_concepts
38
+ respond_to?(:conceptHasBroaderConcept) ? conceptHasBroaderConcept : []
39
+ end
40
+
41
+ # Alias conceptHasNarrowerConcept with fallback.
42
+ #
43
+ # @return [Array, Array] array of child Concept Grom::Nodes or an empty array.
44
+ def child_concepts
45
+ respond_to?(:conceptHasNarrowerConcept) ? conceptHasNarrowerConcept : []
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -58,6 +58,20 @@ module Parliament
58
58
  end
59
59
  end
60
60
 
61
+ # Alias personPimsId with fallback.
62
+ #
63
+ # @return [Array, Array] the pims_id of the Grom::Node or nil.
64
+ def pims_id
65
+ respond_to?(:personPimsId) ? personPimsId : nil
66
+ end
67
+
68
+ # Alias personMnisId with fallback.
69
+ #
70
+ # @return [Array, Array] the mnis_id of the Grom::Node or nil.
71
+ def mnis_id
72
+ respond_to?(:personMnisId) ? personMnisId : nil
73
+ end
74
+
61
75
  # Alias memberHasParliamentaryIncumbency with fallback.
62
76
  #
63
77
  # @return [Array, Array] all the incumbencies of the Grom::Node or an empty array.
@@ -72,6 +86,16 @@ module Parliament
72
86
  @seat_incumbencies ||= incumbencies.select { |inc| inc.type == 'https://id.parliament.uk/schema/SeatIncumbency' }
73
87
  end
74
88
 
89
+ # @return [Grom::Node] the seat incumbency as a Grom::Node or nil
90
+ def current_seat_incumbency
91
+ @current_seat_incumbency ||= seat_incumbencies.select(&:current?)&.first
92
+ end
93
+
94
+ # @return [Grom::Node] the most recent seat incumbency as a Grom::Node or nil
95
+ def most_recent_seat_incumbency
96
+ @most_recent_seat_incumbency ||= seat_incumbencies.sort_by!(&:start_date).reverse.first
97
+ end
98
+
75
99
  # Alias seatIncumbencyHasHouseSeat with fallback.
76
100
  #
77
101
  # @return [Array, Array] the seats of the Grom::Node or an empty array.
@@ -183,6 +207,17 @@ module Parliament
183
207
  former_member_by_house?('House of Lords')
184
208
  end
185
209
 
210
+ # Check whether they are a Member or a Lord from their latest seat incumbency.
211
+ # Current incumbencies are higher priority when determining a person_type, therefore check first for former, then current
212
+ # @return [String] 'member' if they are a member, 'lord' if they are a lord.
213
+ def person_type
214
+ person_type = 'member' if former_mp?
215
+ person_type = 'lord' if former_lord?
216
+ person_type = 'member' if current_mp?
217
+ person_type = 'lord' if current_lord?
218
+ person_type
219
+ end
220
+
186
221
  # Alias D79B0BAC513C4A9A87C9D5AFF1FC632F with fallback.
187
222
  #
188
223
  # @return [String, String] the full title of the Grom::Node or an empty string.
@@ -1,7 +1,7 @@
1
1
  module Parliament
2
2
  module Grom
3
3
  module Decorator
4
- VERSION = '0.16.1'.freeze
4
+ VERSION = '0.16.3'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parliament-grom-decorators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rebecca Appleyard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-19 00:00:00.000000000 Z
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -175,6 +175,7 @@ files:
175
175
  - lib/parliament/grom/decorator/article_type.rb
176
176
  - lib/parliament/grom/decorator/audience.rb
177
177
  - lib/parliament/grom/decorator/collection.rb
178
+ - lib/parliament/grom/decorator/concept.rb
178
179
  - lib/parliament/grom/decorator/constituency_area.rb
179
180
  - lib/parliament/grom/decorator/constituency_group.rb
180
181
  - lib/parliament/grom/decorator/contact_point.rb