parliament-grom-decorators 0.16.0 → 0.16.1
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 +4 -4
- data/lib/parliament/grom/decorator.rb +0 -1
- data/lib/parliament/grom/decorator/person.rb +41 -25
- data/lib/parliament/grom/decorator/seat_incumbency.rb +8 -0
- data/lib/parliament/grom/decorator/version.rb +1 -1
- metadata +2 -3
- data/lib/parliament/grom/decorator/house_incumbency.rb +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a18cf6f6ebcd272403e02d375bf359fc43ad6cb
|
|
4
|
+
data.tar.gz: 3bc8624b4104b47b6ce41ecce76343ec41ab09ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8dcb4d03ab7d15d485c08113c6b4888f39cc37ef46ad555c75004c729215dda0611aa5bc5429a401f23dfded828ba9d331fb01f24ec8d339482a99b8c04d139d
|
|
7
|
+
data.tar.gz: 6b507ecb6f981ea0e5fcb2b71e3177911f4ce725fe8753f54752d6bbef81e8cf23ab58983274377f84cab618a1aa484d52a1561395ead87b77fd26f7758c9e16
|
|
@@ -7,7 +7,6 @@ require 'parliament/grom/decorator/european_region'
|
|
|
7
7
|
require 'parliament/grom/decorator/gender'
|
|
8
8
|
require 'parliament/grom/decorator/gender_identity'
|
|
9
9
|
require 'parliament/grom/decorator/house'
|
|
10
|
-
require 'parliament/grom/decorator/house_incumbency'
|
|
11
10
|
require 'parliament/grom/decorator/house_seat'
|
|
12
11
|
require 'parliament/grom/decorator/parliamentary_incumbency'
|
|
13
12
|
require 'parliament/grom/decorator/party'
|
|
@@ -72,13 +72,6 @@ module Parliament
|
|
|
72
72
|
@seat_incumbencies ||= incumbencies.select { |inc| inc.type == 'https://id.parliament.uk/schema/SeatIncumbency' }
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
# Alias memberHasParliamentaryIncumbency with fallback.
|
|
76
|
-
#
|
|
77
|
-
# @return [Array, Array] the house incumbencies of the Grom::Node or an empty array.
|
|
78
|
-
def house_incumbencies
|
|
79
|
-
@house_incumbencies ||= incumbencies.select { |inc| inc.type == 'https://id.parliament.uk/schema/HouseIncumbency' }
|
|
80
|
-
end
|
|
81
|
-
|
|
82
75
|
# Alias seatIncumbencyHasHouseSeat with fallback.
|
|
83
76
|
#
|
|
84
77
|
# @return [Array, Array] the seats of the Grom::Node or an empty array.
|
|
@@ -90,7 +83,7 @@ module Parliament
|
|
|
90
83
|
#
|
|
91
84
|
# @return [Array, Array] the houses of the Grom::Node or an empty array.
|
|
92
85
|
def houses
|
|
93
|
-
@houses ||= [seats.map(&:house),
|
|
86
|
+
@houses ||= [seats.map(&:house), seat_incumbencies.map(&:house)].flatten.uniq.compact
|
|
94
87
|
end
|
|
95
88
|
|
|
96
89
|
# Alias houseSeatHasConstituencyGroup with fallback.
|
|
@@ -162,18 +155,32 @@ module Parliament
|
|
|
162
155
|
@statuses = statuses
|
|
163
156
|
end
|
|
164
157
|
|
|
165
|
-
# Check whether
|
|
158
|
+
# Check whether they have a current seat on the House of Commons.
|
|
166
159
|
#
|
|
167
|
-
# @return [Boolean] a boolean depending on whether or not
|
|
160
|
+
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Commons.
|
|
168
161
|
def current_mp?
|
|
169
|
-
|
|
162
|
+
current_member_by_house?('House of Commons')
|
|
170
163
|
end
|
|
171
164
|
|
|
172
|
-
# Check whether
|
|
165
|
+
# Check whether they are a former member of the House of Commons.
|
|
173
166
|
#
|
|
174
|
-
# @return [Boolean] a boolean depending on whether or not
|
|
167
|
+
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Commons.
|
|
168
|
+
def former_mp?
|
|
169
|
+
former_member_by_house?('House of Commons')
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Check whether they have a current seat on the House of Lords.
|
|
173
|
+
#
|
|
174
|
+
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Lords.
|
|
175
175
|
def current_lord?
|
|
176
|
-
|
|
176
|
+
current_member_by_house?('House of Lords')
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Check whether they are a former member of the House of Lords.
|
|
180
|
+
#
|
|
181
|
+
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Lords.
|
|
182
|
+
def former_lord?
|
|
183
|
+
former_member_by_house?('House of Lords')
|
|
177
184
|
end
|
|
178
185
|
|
|
179
186
|
# Alias D79B0BAC513C4A9A87C9D5AFF1FC632F with fallback.
|
|
@@ -239,21 +246,30 @@ module Parliament
|
|
|
239
246
|
|
|
240
247
|
private
|
|
241
248
|
|
|
249
|
+
def current_member_by_house?(house_name)
|
|
250
|
+
seat_incumbencies.select{ |incumbency| incumbency.house.name == house_name && incumbency.end_date.nil? }.any?
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def former_member_by_house?(house_name)
|
|
254
|
+
seat_incumbencies.select{ |incumbency| incumbency.house.name == house_name && incumbency.end_date }.any?
|
|
255
|
+
end
|
|
256
|
+
|
|
242
257
|
def house_membership_status
|
|
243
258
|
no_current_seat_incumbency = seat_incumbencies.select(&:current?).empty?
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
former_mp = (!seat_incumbencies.empty? && no_current_seat_incumbency)
|
|
259
|
+
former_lord = former_lord?
|
|
260
|
+
former_mp = (seat_incumbencies.any? && no_current_seat_incumbency)
|
|
247
261
|
|
|
248
|
-
build_house_membership_status(no_current_seat_incumbency,
|
|
262
|
+
build_house_membership_status(no_current_seat_incumbency, former_lord, former_mp)
|
|
249
263
|
end
|
|
250
264
|
|
|
251
|
-
def build_house_membership_status(no_current_seat_incumbency,
|
|
252
|
-
statuses
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
statuses << I18n.t('person.
|
|
256
|
-
statuses << I18n.t('person.
|
|
265
|
+
def build_house_membership_status(no_current_seat_incumbency, former_lord, former_mp)
|
|
266
|
+
statuses = []
|
|
267
|
+
current_mp = current_mp?
|
|
268
|
+
current_lord = current_lord?
|
|
269
|
+
statuses << I18n.t('person.current.mp') if current_mp
|
|
270
|
+
statuses << I18n.t('person.current.member_of_the_house_of_lords') if current_lord
|
|
271
|
+
statuses << I18n.t('person.former.member_of_the_house_of_lords') if former_lord? && !current_lord
|
|
272
|
+
statuses << I18n.t('person.former.mp') if former_mp? && !current_mp
|
|
257
273
|
|
|
258
274
|
convert_house_membership_status(statuses)
|
|
259
275
|
end
|
|
@@ -261,7 +277,7 @@ module Parliament
|
|
|
261
277
|
def general_membership_status
|
|
262
278
|
statuses = []
|
|
263
279
|
statuses << I18n.t('person.current.member') unless incumbencies.select(&:current?).empty?
|
|
264
|
-
statuses << I18n.t('person.former.member') if
|
|
280
|
+
statuses << I18n.t('person.former.member') if incumbencies.any? && incumbencies.select(&:current?).empty?
|
|
265
281
|
statuses
|
|
266
282
|
end
|
|
267
283
|
|
|
@@ -66,6 +66,14 @@ module Parliament
|
|
|
66
66
|
def member
|
|
67
67
|
respond_to?(:parliamentaryIncumbencyHasMember) ? parliamentaryIncumbencyHasMember.first : nil
|
|
68
68
|
end
|
|
69
|
+
|
|
70
|
+
def house_of_lords?
|
|
71
|
+
house.name == 'House of Lords'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def house_of_commons?
|
|
75
|
+
house.name == 'House of Commons'
|
|
76
|
+
end
|
|
69
77
|
end
|
|
70
78
|
end
|
|
71
79
|
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.
|
|
4
|
+
version: 0.16.1
|
|
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-
|
|
11
|
+
date: 2017-12-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -188,7 +188,6 @@ files:
|
|
|
188
188
|
- lib/parliament/grom/decorator/helpers.rb
|
|
189
189
|
- lib/parliament/grom/decorator/helpers/date_helper.rb
|
|
190
190
|
- lib/parliament/grom/decorator/house.rb
|
|
191
|
-
- lib/parliament/grom/decorator/house_incumbency.rb
|
|
192
191
|
- lib/parliament/grom/decorator/house_seat.rb
|
|
193
192
|
- lib/parliament/grom/decorator/member_image.rb
|
|
194
193
|
- lib/parliament/grom/decorator/opposition_incumbency.rb
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
module Parliament
|
|
2
|
-
module Grom
|
|
3
|
-
module Decorator
|
|
4
|
-
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/HouseIncumbency
|
|
5
|
-
module HouseIncumbency
|
|
6
|
-
include Helpers::DateHelper
|
|
7
|
-
|
|
8
|
-
# Alias parliamentaryIncumbencyStartDate with fallback.
|
|
9
|
-
#
|
|
10
|
-
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
|
11
|
-
def start_date
|
|
12
|
-
@start_date ||= respond_to?(:parliamentaryIncumbencyStartDate) ? DateTime.parse(parliamentaryIncumbencyStartDate) : nil
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Alias parliamentaryIncumbencyEndDate with fallback.
|
|
16
|
-
#
|
|
17
|
-
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
|
18
|
-
def end_date
|
|
19
|
-
@end_date ||= respond_to?(:parliamentaryIncumbencyEndDate) ? DateTime.parse(parliamentaryIncumbencyEndDate) : nil
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Checks if Grom::Node has an end date.
|
|
23
|
-
#
|
|
24
|
-
# @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
|
|
25
|
-
def current?
|
|
26
|
-
end_date.nil?
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Alias houseIncumbencyHasHouse with fallback.
|
|
30
|
-
#
|
|
31
|
-
# @return [Grom::Node, nil] the house of the Grom::Node or nil.
|
|
32
|
-
def house
|
|
33
|
-
respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Alias parliamentaryIncumbencyHasMember with fallback.
|
|
37
|
-
#
|
|
38
|
-
# @return [Grom::Node, nil] the member connected to the Grom::Node or nil.
|
|
39
|
-
def member
|
|
40
|
-
respond_to?(:parliamentaryIncumbencyHasMember) ? parliamentaryIncumbencyHasMember.first : nil
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Alias parliamentaryIncumbencyHasContactPoint with fallback.
|
|
44
|
-
#
|
|
45
|
-
# @return [Array, Array] the contact points of the Grom::Node or an empty array.
|
|
46
|
-
def contact_points
|
|
47
|
-
respond_to?(:parliamentaryIncumbencyHasContactPoint) ? parliamentaryIncumbencyHasContactPoint : []
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|