parliament-grom-decorators 0.32.1 → 1.0.0.pre.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +1 -2
- data/config/locales/en.yml +0 -15
- data/lib/parliament/grom/decorator/group.rb +0 -18
- data/lib/parliament/grom/decorator/helpers/date_helper.rb +4 -0
- data/lib/parliament/grom/decorator/helpers/utils.rb +37 -0
- data/lib/parliament/grom/decorator/helpers.rb +2 -0
- data/lib/parliament/grom/decorator/laid_thing.rb +4 -1
- data/lib/parliament/grom/decorator/laying.rb +8 -2
- data/lib/parliament/grom/decorator/person.rb +0 -336
- data/lib/parliament/grom/decorator/procedure.rb +0 -13
- data/lib/parliament/grom/decorator/proposed_negative_statutory_instrument_paper.rb +0 -7
- data/lib/parliament/grom/decorator/statutory_instrument_paper.rb +0 -35
- data/lib/parliament/grom/decorator/version.rb +1 -1
- data/lib/parliament/grom/decorator/work_package.rb +3 -33
- data/lib/parliament/grom/decorator/work_packaged_thing.rb +4 -8
- data/parliament-grom-decorators.gemspec +1 -1
- metadata +8 -48
- data/lib/parliament/grom/decorator/answer.rb +0 -37
- data/lib/parliament/grom/decorator/answering_body.rb +0 -22
- data/lib/parliament/grom/decorator/answering_body_allocation.rb +0 -15
- data/lib/parliament/grom/decorator/article_type.rb +0 -17
- data/lib/parliament/grom/decorator/audience.rb +0 -17
- data/lib/parliament/grom/decorator/business_item.rb +0 -44
- data/lib/parliament/grom/decorator/collection.rb +0 -62
- data/lib/parliament/grom/decorator/concept.rb +0 -50
- data/lib/parliament/grom/decorator/constituency_area.rb +0 -29
- data/lib/parliament/grom/decorator/constituency_group.rb +0 -133
- data/lib/parliament/grom/decorator/contact_point.rb +0 -54
- data/lib/parliament/grom/decorator/european_region.rb +0 -29
- data/lib/parliament/grom/decorator/formal_body.rb +0 -100
- data/lib/parliament/grom/decorator/formal_body_chair.rb +0 -15
- data/lib/parliament/grom/decorator/formal_body_membership.rb +0 -45
- data/lib/parliament/grom/decorator/formal_body_type.rb +0 -15
- data/lib/parliament/grom/decorator/gender.rb +0 -15
- data/lib/parliament/grom/decorator/gender_identity.rb +0 -15
- data/lib/parliament/grom/decorator/gov_register_government_organisation.rb +0 -31
- data/lib/parliament/grom/decorator/government_incumbency.rb +0 -38
- data/lib/parliament/grom/decorator/government_position.rb +0 -15
- data/lib/parliament/grom/decorator/house.rb +0 -57
- data/lib/parliament/grom/decorator/house_seat.rb +0 -29
- data/lib/parliament/grom/decorator/incumbency.rb +0 -38
- data/lib/parliament/grom/decorator/laying_body.rb +0 -15
- data/lib/parliament/grom/decorator/member_image.rb +0 -15
- data/lib/parliament/grom/decorator/opposition_incumbency.rb +0 -38
- data/lib/parliament/grom/decorator/opposition_position.rb +0 -15
- data/lib/parliament/grom/decorator/parliamentary_incumbency.rb +0 -59
- data/lib/parliament/grom/decorator/parliaments.rb +0 -52
- data/lib/parliament/grom/decorator/party.rb +0 -52
- data/lib/parliament/grom/decorator/party_membership.rb +0 -38
- data/lib/parliament/grom/decorator/position.rb +0 -22
- data/lib/parliament/grom/decorator/postal_address.rb +0 -26
- data/lib/parliament/grom/decorator/procedure_route.rb +0 -15
- data/lib/parliament/grom/decorator/procedure_step.rb +0 -36
- data/lib/parliament/grom/decorator/question.rb +0 -72
- data/lib/parliament/grom/decorator/seat_incumbency.rb +0 -82
- data/lib/parliament/grom/decorator/treaty.rb +0 -9
- data/lib/parliament/grom/decorator/web_article.rb +0 -71
- data/lib/parliament/grom/decorator/work_packageable_thing.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 519f56b2e41fd46bf0cdb118b963ab5d04a4b7dd
|
4
|
+
data.tar.gz: 3ebe80a10134f7b5dede8bfc063e527f53765047
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4b3ebe7fd09aee13560d6db37532d2d8c007f9741b9512f0173cf415ed70f5791cac72364164c0c5560550488db369fcded571e5f912790804af67160716945
|
7
|
+
data.tar.gz: 5d18e3749ad7132330ebeb99e6a49e454e6f239e09864340d49e9928dd118343f663cac35c1ce9aed07747eaf8f1190ffb7595d97cb82028fe5f7a79936018d6
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|
data/.travis.yml
CHANGED
data/config/locales/en.yml
CHANGED
@@ -22,19 +22,4 @@
|
|
22
22
|
en:
|
23
23
|
to_present: 'to present'
|
24
24
|
to: 'to'
|
25
|
-
person:
|
26
|
-
current:
|
27
|
-
mp: 'Current MP'
|
28
|
-
member_of_the_house_of_lords: 'Member of the House of Lords'
|
29
|
-
member: 'Current Member'
|
30
|
-
former:
|
31
|
-
mp: 'Former MP'
|
32
|
-
member_of_the_house_of_lords: 'Former Member of the House of Lords'
|
33
|
-
member: 'Former Member'
|
34
|
-
committee:
|
35
|
-
member: 'committee member'
|
36
|
-
lay: 'Lay'
|
37
|
-
ex_officio: 'Ex officio'
|
38
|
-
co_opted: 'Co-opted'
|
39
|
-
alternate: 'Alternate'
|
40
25
|
date_unavailable: '[Date unavailable]'
|
@@ -4,12 +4,6 @@ module Parliament
|
|
4
4
|
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Group.
|
5
5
|
module Group
|
6
6
|
include Helpers::DateHelper
|
7
|
-
# Alias groupName with fallback.
|
8
|
-
#
|
9
|
-
# @return [String, String] the name of the Grom::Node or an empty string.
|
10
|
-
def name
|
11
|
-
respond_to?(:groupName) ? groupName : ''
|
12
|
-
end
|
13
7
|
|
14
8
|
# Alias groupStartDate with fallback.
|
15
9
|
#
|
@@ -18,24 +12,12 @@ module Parliament
|
|
18
12
|
@start_date ||= respond_to?(:groupStartDate) ? DateTime.parse(groupStartDate) : nil
|
19
13
|
end
|
20
14
|
|
21
|
-
# Alias member count with fallback.
|
22
|
-
#
|
23
|
-
# @return [Integer, nil] the count of members of the Grom::Node or nil.
|
24
|
-
def member_count
|
25
|
-
respond_to?(:memberCount) ? memberCount.to_i : nil
|
26
|
-
end
|
27
|
-
|
28
15
|
# Alias groupEndDate with fallback.
|
29
16
|
#
|
30
17
|
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
31
18
|
def end_date
|
32
19
|
@end_date ||= respond_to?(:groupEndDate) ? DateTime.parse(groupEndDate) : nil
|
33
20
|
end
|
34
|
-
|
35
|
-
# @return [Boolean] whether the group is also a formal body.
|
36
|
-
def formal_body?
|
37
|
-
type.include?(Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('FormalBody'))
|
38
|
-
end
|
39
21
|
end
|
40
22
|
end
|
41
23
|
end
|
@@ -5,9 +5,13 @@ module Parliament
|
|
5
5
|
# Namespace for date helper methods
|
6
6
|
module DateHelper
|
7
7
|
# Format start_date and end_date into a readable string
|
8
|
+
#
|
8
9
|
# @param [String] date_format a string that represents the format we want to use for the date
|
10
|
+
#
|
9
11
|
# @example Format a node with an end_date with the date format YYYY-MM-DD
|
10
12
|
# "grom_node_instance.date_range('%Y-%m-%d)" #=> "2010-01-01 to 2015-01-01"
|
13
|
+
#
|
14
|
+
# @return [String] formatted date range
|
11
15
|
def date_range(date_format: '%-d %-B %Y')
|
12
16
|
return I18n.t('date_unavailable') if start_date.nil?
|
13
17
|
if end_date
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
module Helpers
|
5
|
+
# Namespace for utility methods
|
6
|
+
module Utils
|
7
|
+
class << self
|
8
|
+
# Checks that a collection responds to first and that the first element is of the given class
|
9
|
+
#
|
10
|
+
# @param [Enumerable] enumerable object which responds to #first
|
11
|
+
# @param [Class] klass the class we expect the first element to be
|
12
|
+
#
|
13
|
+
# @example When the first element is of the expected class
|
14
|
+
# Parliament::Grom::Decorator::Helpers::Utils.type_safe_first(['hello'], String) #=> 'hello'
|
15
|
+
#
|
16
|
+
# @example When the first element is not of the expected class
|
17
|
+
# Parliament::Grom::Decorator::Helpers::Utils.type_safe_first(['hello'], Fixnum) #=> nil
|
18
|
+
#
|
19
|
+
# @example When the enumerable does not respond to first
|
20
|
+
# Parliament::Grom::Decorator::Helpers::Utils.type_safe_first('hello', String) #=> nil
|
21
|
+
#
|
22
|
+
# @return [String] formatted date range
|
23
|
+
def type_safe_first(enumerable, klass)
|
24
|
+
return nil unless enumerable.respond_to?(:first)
|
25
|
+
|
26
|
+
first_element = enumerable.first
|
27
|
+
|
28
|
+
return nil unless first_element.is_a?(klass)
|
29
|
+
|
30
|
+
first_element
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -7,7 +7,10 @@ module Parliament
|
|
7
7
|
#
|
8
8
|
# @return [Grom::Node, nil] a laying Grom::Node or nil.
|
9
9
|
def laying
|
10
|
-
|
10
|
+
return @laying if @laying
|
11
|
+
return nil unless respond_to?(:laidThingHasLaying)
|
12
|
+
|
13
|
+
@laying = Helpers::Utils.type_safe_first(laidThingHasLaying, Parliament::Grom::Decorator::Laying)
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -14,14 +14,20 @@ module Parliament
|
|
14
14
|
#
|
15
15
|
# @return [Grom::Node, nil] the LayingBody of the Grom::Node or nil.
|
16
16
|
def body
|
17
|
-
|
17
|
+
return @body if @body
|
18
|
+
return nil unless respond_to?(:layingHasLayingBody)
|
19
|
+
|
20
|
+
@body = Helpers::Utils.type_safe_first(layingHasLayingBody, Parliament::Grom::Decorator::Group)
|
18
21
|
end
|
19
22
|
|
20
23
|
# Alias layingHasLayingPerson with fallback.
|
21
24
|
#
|
22
25
|
# @return [Grom::Node, nil] the LayingPerson of the Grom::Node or nil.
|
23
26
|
def person
|
24
|
-
|
27
|
+
return @person if @person
|
28
|
+
return nil unless respond_to?(:layingHasLayingPerson)
|
29
|
+
|
30
|
+
@person = Helpers::Utils.type_safe_first(layingHasLayingPerson, Parliament::Grom::Decorator::Person)
|
25
31
|
end
|
26
32
|
end
|
27
33
|
end
|
@@ -1,38 +1,7 @@
|
|
1
1
|
module Parliament
|
2
2
|
module Grom
|
3
3
|
module Decorator
|
4
|
-
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Person.
|
5
4
|
module Person
|
6
|
-
include Helpers::DateHelper
|
7
|
-
|
8
|
-
# Alias personGivenName with fallback.
|
9
|
-
#
|
10
|
-
# @return [String, String] the given name of the Grom::Node or an empty string.
|
11
|
-
def given_name
|
12
|
-
respond_to?(:personGivenName) ? personGivenName : ''
|
13
|
-
end
|
14
|
-
|
15
|
-
# Alias personFamilyName with fallback.
|
16
|
-
#
|
17
|
-
# @return [String, String] the family name of the Grom::Node or an empty string.
|
18
|
-
def family_name
|
19
|
-
respond_to?(:personFamilyName) ? personFamilyName : ''
|
20
|
-
end
|
21
|
-
|
22
|
-
# Alias personOtherNames with fallback.
|
23
|
-
#
|
24
|
-
# @return [String, String] the other names of the Grom::Node or an empty string.
|
25
|
-
def other_name
|
26
|
-
respond_to?(:personOtherNames) ? personOtherNames : ''
|
27
|
-
end
|
28
|
-
|
29
|
-
# Alias personDateOfBirth with fallback.
|
30
|
-
#
|
31
|
-
# @return [DateTime, nil] the date of birth of the Grom::Node or nil.
|
32
|
-
def date_of_birth
|
33
|
-
@date_of_birth ||= respond_to?(:personDateOfBirth) ? DateTime.parse(personDateOfBirth) : nil
|
34
|
-
end
|
35
|
-
|
36
5
|
# Builds a full name using personGivenName and personFamilyName.
|
37
6
|
#
|
38
7
|
# @return [String, String] the full name of the Grom::Node or an empty string.
|
@@ -46,317 +15,12 @@ module Parliament
|
|
46
15
|
@full_name = full_name.join(' ')
|
47
16
|
end
|
48
17
|
|
49
|
-
# Alias personHasPersonImage with fallback.
|
50
|
-
#
|
51
|
-
# @return [String, String] the image location of the Grom::Node or a placeholder string.
|
52
|
-
def image_id(show_placeholder: true)
|
53
|
-
if respond_to?(:memberHasMemberImage)
|
54
|
-
memberHasMemberImage.first.graph_id
|
55
|
-
else
|
56
|
-
show_placeholder ? 'placeholder' : nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Alias personPimsId with fallback.
|
61
|
-
#
|
62
|
-
# @return [Array, Array] the pims_id of the Grom::Node or nil.
|
63
|
-
def pims_id
|
64
|
-
respond_to?(:personPimsId) ? personPimsId : nil
|
65
|
-
end
|
66
|
-
|
67
|
-
# Alias memberMnisId with fallback.
|
68
|
-
#
|
69
|
-
# @return [Array, Array] the mnis_id of the Grom::Node or nil.
|
70
|
-
def mnis_id
|
71
|
-
respond_to?(:memberMnisId) ? memberMnisId : nil
|
72
|
-
end
|
73
|
-
|
74
|
-
# Alias memberHasParliamentaryIncumbency with fallback.
|
75
|
-
#
|
76
|
-
# @return [Array, Array] all the incumbencies of the Grom::Node or an empty array.
|
77
|
-
def incumbencies
|
78
|
-
respond_to?(:memberHasParliamentaryIncumbency) ? memberHasParliamentaryIncumbency : []
|
79
|
-
end
|
80
|
-
|
81
|
-
# Alias memberHasParliamentaryIncumbency with fallback.
|
82
|
-
#
|
83
|
-
# @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
|
84
|
-
def seat_incumbencies
|
85
|
-
@seat_incumbencies ||= incumbencies.select { |inc| inc.type.include?(Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('SeatIncumbency')) }
|
86
|
-
end
|
87
|
-
|
88
|
-
# @return [Grom::Node] the seat incumbency as a Grom::Node or nil
|
89
|
-
def current_seat_incumbency
|
90
|
-
@current_seat_incumbency ||= seat_incumbencies.select(&:current?)&.first
|
91
|
-
end
|
92
|
-
|
93
|
-
# @return [Grom::Node] the most recent seat incumbency as a Grom::Node or nil
|
94
|
-
def most_recent_seat_incumbency
|
95
|
-
@most_recent_seat_incumbency ||= seat_incumbencies.sort_by!(&:start_date).reverse.first
|
96
|
-
end
|
97
|
-
|
98
|
-
# Alias seatIncumbencyHasHouseSeat with fallback.
|
99
|
-
#
|
100
|
-
# @return [Array, Array] the seats of the Grom::Node or an empty array.
|
101
|
-
def seats
|
102
|
-
@seats ||= seat_incumbencies.map(&:seat).flatten.uniq.compact
|
103
|
-
end
|
104
|
-
|
105
|
-
# Alias houseSeatHasHouse with fallback.
|
106
|
-
# @return [Array, Array] the houses of the Grom::Node or an empty array.
|
107
|
-
def houses
|
108
|
-
@houses ||= [seats.map(&:house), seat_incumbencies.map(&:house)].flatten.uniq.compact
|
109
|
-
end
|
110
|
-
|
111
|
-
# Alias houseSeatHasConstituencyGroup with fallback.
|
112
|
-
#
|
113
|
-
# @return [Array, Array] the constituencies of the Grom::Node or an empty array.
|
114
|
-
def constituencies
|
115
|
-
@constituencies ||= seats.map(&:constituency).flatten.uniq.compact
|
116
|
-
end
|
117
|
-
|
118
|
-
# Alias partyMemberHasPartyMembership with fallback.
|
119
|
-
#
|
120
|
-
# @return [Array, Array] the party memberships of the Grom::Node or an empty array.
|
121
|
-
def party_memberships
|
122
|
-
respond_to?(:partyMemberHasPartyMembership) ? partyMemberHasPartyMembership : []
|
123
|
-
end
|
124
|
-
|
125
|
-
# Alias partyMembershipHasParty with fallback.
|
126
|
-
#
|
127
|
-
# @return [Array, Array] the parties of the Grom::Node or an empty array.
|
128
|
-
def parties
|
129
|
-
@parties ||= party_memberships.map(&:party).flatten.uniq.compact
|
130
|
-
end
|
131
|
-
|
132
|
-
# Alias partyMembershipHasParty with fallback.
|
133
|
-
#
|
134
|
-
# @return [Grom::Node] the current party of the Grom::Node or nil.
|
135
|
-
def current_party
|
136
|
-
@current_party ||= party_memberships.select(&:current?).select(&:party)&.first&.party
|
137
|
-
end
|
138
|
-
|
139
|
-
# Alias partyMembershipHasParty with fallback.
|
140
|
-
#
|
141
|
-
# @return [Grom::Node] the current party membership of the Grom::Node or nil.
|
142
|
-
def current_party_membership
|
143
|
-
@current_party_membership ||= party_memberships.select(&:current?).select(&:party)&.first
|
144
|
-
end
|
145
|
-
|
146
|
-
# Alias personHasContactPoint with fallback.
|
147
|
-
#
|
148
|
-
# @return [Array, Array] the contact points of the Grom::Node or an empty array.
|
149
|
-
def contact_points
|
150
|
-
respond_to?(:personHasContactPoint) ? personHasContactPoint : []
|
151
|
-
end
|
152
|
-
|
153
|
-
# Alias personHasGenderIdentity with fallback.
|
154
|
-
#
|
155
|
-
# @return [Array, Array] the gender identities of the Grom::Node or an empty array.
|
156
|
-
def gender_identities
|
157
|
-
respond_to?(:personHasGenderIdentity) ? personHasGenderIdentity : []
|
158
|
-
end
|
159
|
-
|
160
|
-
# Alias genderIdentityHasGender with fallback.
|
161
|
-
#
|
162
|
-
# @return [Array, Array] the gender of the Grom::Node or nil.
|
163
|
-
def gender
|
164
|
-
gender_identities.empty? ? nil : gender_identities.first.gender
|
165
|
-
end
|
166
|
-
|
167
|
-
# Gets the gender pronoun of the Grom::Node.
|
168
|
-
#
|
169
|
-
# @return [String, String] the gender pronoun of the Grom::Node.
|
170
|
-
def gender_pronoun
|
171
|
-
if gender
|
172
|
-
return 'She' if gender.name == 'Female'
|
173
|
-
return 'He' if gender.name == 'Male'
|
174
|
-
end
|
175
|
-
'They'
|
176
|
-
end
|
177
|
-
|
178
|
-
# Checks the statuses of the Grom::Node.
|
179
|
-
#
|
180
|
-
# @return [Hash, Hash] the statuses of the Grom::Node or an empty hash.
|
181
|
-
def statuses
|
182
|
-
return @statuses unless @statuses.nil?
|
183
|
-
|
184
|
-
statuses = {}
|
185
|
-
statuses[:house_membership_status] = house_membership_status
|
186
|
-
statuses[:general_membership_status] = general_membership_status
|
187
|
-
|
188
|
-
@statuses = statuses
|
189
|
-
end
|
190
|
-
|
191
|
-
# Check whether they have a current seat on the House of Commons.
|
192
|
-
#
|
193
|
-
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Commons.
|
194
|
-
def current_mp?
|
195
|
-
current_member_by_house?('House of Commons')
|
196
|
-
end
|
197
|
-
|
198
|
-
# Check whether they are a former member of the House of Commons.
|
199
|
-
#
|
200
|
-
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Commons.
|
201
|
-
def former_mp?
|
202
|
-
former_member_by_house?('House of Commons')
|
203
|
-
end
|
204
|
-
|
205
|
-
# Check whether they have a current seat on the House of Lords.
|
206
|
-
#
|
207
|
-
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Lords.
|
208
|
-
def current_lord?
|
209
|
-
current_member_by_house?('House of Lords')
|
210
|
-
end
|
211
|
-
|
212
|
-
# Check whether member is an ex_officio?.
|
213
|
-
#
|
214
|
-
# @return [Boolean] a boolean depending on whether or not member is an ex_officio?
|
215
|
-
def ex_officio?
|
216
|
-
respond_to?(:memberHasExOfficioMembership)
|
217
|
-
end
|
218
|
-
|
219
|
-
# Check whether member is an alternate?.
|
220
|
-
#
|
221
|
-
# @return [Boolean] a boolean depending on whether or not member is an alternate?
|
222
|
-
def alternate?
|
223
|
-
respond_to?(:memberHasAlternateMembership)
|
224
|
-
end
|
225
|
-
|
226
|
-
# Check whether person is a lay member?.
|
227
|
-
#
|
228
|
-
# @return [Boolean] a boolean depending on whether or person is a lay member or not
|
229
|
-
def lay_member?
|
230
|
-
respond_to?(:formalBodyLayPersonMnisId)
|
231
|
-
end
|
232
|
-
|
233
|
-
def committee_membership_type
|
234
|
-
committee_membership_type = []
|
235
|
-
committee_membership_type << I18n.t('person.committee.lay') if lay_member?
|
236
|
-
committee_membership_type << I18n.t('person.committee.ex_officio') if ex_officio?
|
237
|
-
committee_membership_type << I18n.t('person.committee.alternate') if alternate?
|
238
|
-
committee_membership_type << I18n.t('person.committee.member')
|
239
|
-
committee_membership_type
|
240
|
-
end
|
241
|
-
|
242
|
-
# Check whether they are a former member of the House of Lords.
|
243
|
-
#
|
244
|
-
# @return [Boolean] a boolean depending on whether or not they have a current seat incumbency in the House of Lords.
|
245
|
-
def former_lord?
|
246
|
-
former_member_by_house?('House of Lords')
|
247
|
-
end
|
248
|
-
|
249
|
-
# Check whether they are a Member or a Lord from their latest seat incumbency.
|
250
|
-
# Current incumbencies are higher priority when determining a person_type
|
251
|
-
# Therefore check first for former, then current
|
252
|
-
# @return [String] 'member' if they are a member, 'lord' if they are a lord.
|
253
|
-
def person_type
|
254
|
-
person_type = 'member' if former_mp?
|
255
|
-
person_type = 'lord' if former_lord?
|
256
|
-
person_type = 'member' if current_mp?
|
257
|
-
person_type = 'lord' if current_lord?
|
258
|
-
person_type
|
259
|
-
end
|
260
|
-
|
261
|
-
# Alias D79B0BAC513C4A9A87C9D5AFF1FC632F with fallback.
|
262
|
-
#
|
263
|
-
# @return [String, String] the full title of the Grom::Node or an empty string.
|
264
|
-
def full_title
|
265
|
-
respond_to?(:D79B0BAC513C4A9A87C9D5AFF1FC632F) ? self.D79B0BAC513C4A9A87C9D5AFF1FC632F : ''
|
266
|
-
end
|
267
|
-
|
268
18
|
# Alias F31CBD81AD8343898B49DC65743F0BDF with fallback.
|
269
19
|
#
|
270
20
|
# @return [String, String] the display name of the Grom::Node or the full name.
|
271
21
|
def display_name
|
272
22
|
respond_to?(:F31CBD81AD8343898B49DC65743F0BDF) ? self.F31CBD81AD8343898B49DC65743F0BDF : full_name
|
273
23
|
end
|
274
|
-
|
275
|
-
# Alias A5EE13ABE03C4D3A8F1A274F57097B6C with fallback.
|
276
|
-
#
|
277
|
-
# @return [String, String] the sort name of the Grom::Node or an empty string.
|
278
|
-
def sort_name
|
279
|
-
respond_to?(:A5EE13ABE03C4D3A8F1A274F57097B6C) ? self.A5EE13ABE03C4D3A8F1A274F57097B6C : ''
|
280
|
-
end
|
281
|
-
|
282
|
-
# Alias personHasFormalBodyMembership with fallback.
|
283
|
-
#
|
284
|
-
# @return [Array, Array] all the formal body memberships of the Grom::Node or an empty array.
|
285
|
-
def formal_body_memberships
|
286
|
-
respond_to?(:personHasFormalBodyMembership) ? personHasFormalBodyMembership : []
|
287
|
-
end
|
288
|
-
|
289
|
-
# Alias governmentIncumbency with fallback.
|
290
|
-
#
|
291
|
-
# @return [Array, Array] all the government incumbencies of the Grom::Node or an empty array.
|
292
|
-
def government_incumbencies
|
293
|
-
respond_to?(:governmentPersonHasGovernmentIncumbency) ? governmentPersonHasGovernmentIncumbency : []
|
294
|
-
end
|
295
|
-
|
296
|
-
# Alias personHasPersonalWebLink with fallback.
|
297
|
-
#
|
298
|
-
# @return [Array, Array] all the personal weblinks of the Grom::Node or an empty Array.
|
299
|
-
def personal_weblinks
|
300
|
-
[*get_weblinks_by_predicate(:personHasPersonalWebLink)]
|
301
|
-
end
|
302
|
-
|
303
|
-
# Alias personHasTwitterWebLink with fallback.
|
304
|
-
#
|
305
|
-
# @return [Array, Array] all the Twitter weblinks of the Grom::Node or an empty array.
|
306
|
-
def twitter_weblinks
|
307
|
-
[*get_weblinks_by_predicate(:personHasTwitterWebLink)]
|
308
|
-
end
|
309
|
-
|
310
|
-
# Alias personHasFacebookWebLink with fallback.
|
311
|
-
#
|
312
|
-
# @return [Array, Array] all the Facebook weblinks of the Grom::Node or an empty array.
|
313
|
-
def facebook_weblinks
|
314
|
-
[*get_weblinks_by_predicate(:personHasFacebookWebLink)]
|
315
|
-
end
|
316
|
-
|
317
|
-
# Check whether a person has any weblinks
|
318
|
-
def weblinks?
|
319
|
-
(personal_weblinks + twitter_weblinks + facebook_weblinks).any?
|
320
|
-
end
|
321
|
-
|
322
|
-
private
|
323
|
-
|
324
|
-
def current_member_by_house?(house_name)
|
325
|
-
seat_incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date.nil? }.any?
|
326
|
-
end
|
327
|
-
|
328
|
-
def former_member_by_house?(house_name)
|
329
|
-
seat_incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date }.any?
|
330
|
-
end
|
331
|
-
|
332
|
-
def house_membership_status
|
333
|
-
statuses = []
|
334
|
-
current_mp = current_mp?
|
335
|
-
current_lord = current_lord?
|
336
|
-
statuses << I18n.t('person.current.mp') if current_mp
|
337
|
-
statuses << I18n.t('person.current.member_of_the_house_of_lords') if current_lord
|
338
|
-
statuses << I18n.t('person.former.member_of_the_house_of_lords') if former_lord? && !current_lord
|
339
|
-
statuses << I18n.t('person.former.mp') if former_mp? && !current_mp
|
340
|
-
|
341
|
-
convert_house_membership_status(statuses)
|
342
|
-
end
|
343
|
-
|
344
|
-
def general_membership_status
|
345
|
-
statuses = []
|
346
|
-
statuses << I18n.t('person.current.member') unless incumbencies.select(&:current?).empty?
|
347
|
-
statuses << I18n.t('person.former.member') if incumbencies.any? && incumbencies.select(&:current?).empty?
|
348
|
-
statuses
|
349
|
-
end
|
350
|
-
|
351
|
-
def convert_house_membership_status(statuses)
|
352
|
-
statuses.each_with_index do |status, index|
|
353
|
-
status[0] = status[0].downcase if index != 0
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
def get_weblinks_by_predicate(weblink_predicate)
|
358
|
-
(respond_to?(weblink_predicate) && (current_mp? || current_lord?) ? send(weblink_predicate) : nil)
|
359
|
-
end
|
360
24
|
end
|
361
25
|
end
|
362
26
|
end
|
@@ -3,19 +3,6 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Procedure
|
5
5
|
module Procedure
|
6
|
-
# Alias procedureName with fallback.
|
7
|
-
#
|
8
|
-
# @return [String, String] the name of the Grom::Node or an empty string.
|
9
|
-
def name
|
10
|
-
respond_to?(:procedureName) ? procedureName : ''
|
11
|
-
end
|
12
|
-
|
13
|
-
# Alias procedureHasWorkPackage with fallback.
|
14
|
-
#
|
15
|
-
# @return [Array, Array] an array of WorkPackage Grom::Nodes or an empty array.
|
16
|
-
def work_packages
|
17
|
-
respond_to?(:procedureHasWorkPackage) ? procedureHasWorkPackage : []
|
18
|
-
end
|
19
6
|
end
|
20
7
|
end
|
21
8
|
end
|
@@ -3,13 +3,6 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/ProposedNegativeStatutoryInstrumentPaper
|
5
5
|
module ProposedNegativeStatutoryInstrumentPaper
|
6
|
-
# Alias proposedNegativeStatutoryInstrumentPaperName with fallback.
|
7
|
-
#
|
8
|
-
# @return [String, String] the name of the Grom::Node or an empty string.
|
9
|
-
def name
|
10
|
-
respond_to?(:proposedNegativeStatutoryInstrumentPaperName) ? proposedNegativeStatutoryInstrumentPaperName : ''
|
11
|
-
end
|
12
|
-
|
13
6
|
# Alias proposedNegativeStatutoryInstrumentPaperPrecedesStatutoryInstrumentPaper with fallback.
|
14
7
|
#
|
15
8
|
# @return [Array, Array] an array of StatutoryInstrumentPaper Grom::Nodes or an empty array.
|
@@ -3,34 +3,6 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/StatutoryInstrumentPaper
|
5
5
|
module StatutoryInstrumentPaper
|
6
|
-
# Alias statutoryInstrumentPaperName with fallback.
|
7
|
-
#
|
8
|
-
# @return [String, String] the name of the Grom::Node or an empty string.
|
9
|
-
def name
|
10
|
-
respond_to?(:statutoryInstrumentPaperName) ? statutoryInstrumentPaperName : ''
|
11
|
-
end
|
12
|
-
|
13
|
-
# Alias statutoryInstrumentPaperPrefix with fallback.
|
14
|
-
#
|
15
|
-
# @return [String, String] the prefix of the Grom::Node or an empty string.
|
16
|
-
def prefix
|
17
|
-
respond_to?(:statutoryInstrumentPaperPrefix) ? statutoryInstrumentPaperPrefix : ''
|
18
|
-
end
|
19
|
-
|
20
|
-
# Alias statutoryInstrumentPaperYear with fallback.
|
21
|
-
#
|
22
|
-
# @return [String, String] the year of the Grom::Node or an empty string.
|
23
|
-
def year
|
24
|
-
respond_to?(:statutoryInstrumentPaperYear) ? statutoryInstrumentPaperYear : ''
|
25
|
-
end
|
26
|
-
|
27
|
-
# Alias statutoryInstrumentPaperNumber with fallback.
|
28
|
-
#
|
29
|
-
# @return [String, String] the number of the Grom::Node or an empty string.
|
30
|
-
def number
|
31
|
-
respond_to?(:statutoryInstrumentPaperNumber) ? statutoryInstrumentPaperNumber : ''
|
32
|
-
end
|
33
|
-
|
34
6
|
# Alias statutoryInstrumentPaperMadeDate with fallback.
|
35
7
|
#
|
36
8
|
# @return [Date, nil] the coming into force date of the Grom::Node or nil.
|
@@ -38,13 +10,6 @@ module Parliament
|
|
38
10
|
respond_to?(:statutoryInstrumentPaperMadeDate) ? DateTime.parse(statutoryInstrumentPaperMadeDate) : nil
|
39
11
|
end
|
40
12
|
|
41
|
-
# Alias statutoryInstrumentPaperComingIntoForceNote with fallback.
|
42
|
-
#
|
43
|
-
# @return [String, String] the coming into force date of the Grom::Node or an empty string.
|
44
|
-
def coming_into_force_note
|
45
|
-
respond_to?(:statutoryInstrumentPaperComingIntoForceNote) ? statutoryInstrumentPaperComingIntoForceNote : ''
|
46
|
-
end
|
47
|
-
|
48
13
|
# Alias Date with fallback.
|
49
14
|
#
|
50
15
|
# @return [Date, nil] the coming into force date of the Grom::Node or nil.
|
@@ -3,45 +3,15 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/WorkPackage
|
5
5
|
module WorkPackage
|
6
|
-
include Helpers::DateHelper
|
7
6
|
# Alias workPackageHasProcedure with fallback.
|
8
7
|
# NB: Currently, work packages only have one procedure
|
9
8
|
#
|
10
9
|
# @return [Grom::Node, nil] a Procedure Grom::Node or nil.
|
11
10
|
def procedure
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# Alias workPackageHasWorkPackageableThing with fallback.
|
16
|
-
# NB: Currently, work packages only have one work packageable thing
|
17
|
-
#
|
18
|
-
# @return [Grom::Node, nil] a Procedure Grom::Node or nil.
|
19
|
-
def work_packageable_thing
|
20
|
-
respond_to?(:workPackageHasWorkPackageableThing) ? workPackageHasWorkPackageableThing.first : nil
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [String, nil] the name of the Grom::Node or an empty string.
|
24
|
-
def work_packageable_thing_name
|
25
|
-
work_packageable_thing&.name
|
26
|
-
end
|
11
|
+
return @procedure if @procedure
|
12
|
+
return nil unless respond_to?(:workPackageHasProcedure)
|
27
13
|
|
28
|
-
|
29
|
-
#
|
30
|
-
# @return [Array, Array] an array of BusinessItem Grom::Nodes or an empty array.
|
31
|
-
def business_items
|
32
|
-
respond_to?(:workPackageHasBusinessItem) ? workPackageHasBusinessItem : []
|
33
|
-
end
|
34
|
-
|
35
|
-
# @return [Grom::Node, nil] a Laying Grom::Node or nil.
|
36
|
-
def laying
|
37
|
-
respond_to?(:workPackageHasProcedure) ? workPackageHasProcedure.first : nil
|
38
|
-
end
|
39
|
-
|
40
|
-
# Alias oldestBusinessItemDate with fallback.
|
41
|
-
#
|
42
|
-
# @return [Date, nil] a date or nil.
|
43
|
-
def oldest_business_item_date
|
44
|
-
respond_to?(:oldestBusinessItemDate) ? DateTime.parse(oldestBusinessItemDate) : nil
|
14
|
+
@procedure = Helpers::Utils.type_safe_first(workPackageHasProcedure, Parliament::Grom::Decorator::Procedure)
|
45
15
|
end
|
46
16
|
end
|
47
17
|
end
|