parliament-grom-decorators 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -9
- data/.ruby-version +1 -0
- data/lib/parliament/grom/decorator.rb +59 -16
- data/lib/parliament/grom/decorator/constituency_group.rb +3 -7
- data/lib/parliament/grom/decorator/european_region.rb +0 -1
- data/lib/parliament/grom/decorator/formal_body.rb +0 -1
- data/lib/parliament/grom/decorator/formal_body_chair.rb +0 -1
- data/lib/parliament/grom/decorator/formal_body_membership.rb +0 -1
- data/lib/parliament/grom/decorator/formal_body_type.rb +11 -12
- data/lib/parliament/grom/decorator/gov_register_government_organisation.rb +0 -1
- data/lib/parliament/grom/decorator/government_incumbency.rb +0 -1
- data/lib/parliament/grom/decorator/government_position.rb +0 -1
- data/lib/parliament/grom/decorator/group.rb +0 -1
- data/lib/parliament/grom/decorator/house.rb +14 -0
- data/lib/parliament/grom/decorator/incumbency.rb +0 -1
- data/lib/parliament/grom/decorator/person.rb +2 -11
- data/lib/parliament/grom/decorator/position.rb +0 -1
- data/lib/parliament/grom/decorator/postal_address.rb +1 -3
- data/lib/parliament/grom/decorator/seat_incumbency.rb +4 -2
- data/lib/parliament/grom/decorator/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a8e463ea0df6d029f956dae0d477d9a4bf1214d
|
4
|
+
data.tar.gz: ab2d044459ce303cbd4eb547ae591d27a9199426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80198d68a8885b28c59f174417b696c2f8605cc810bbf4ee2fcc3020b6f7b34b908438d5924be1483260ebded8281412537a4b3bbf1fa9af2924bbb2636f60b1
|
7
|
+
data.tar.gz: a406c5faba73f67de95ee2f554ecd7a61d33fca15d381f84f3a5a0128ceb6406f8fc0558dddf6ebe7216b2a3ada923a25f548858716a132ce9c60605123f0e34
|
data/.rubocop.yml
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
Metrics/LineLength:
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/EachWithObject:
|
5
|
+
Enabled: false
|
5
6
|
|
6
|
-
|
7
|
+
Layout/SpaceBeforeFirstArg:
|
7
8
|
Enabled: false
|
8
9
|
|
9
10
|
Style/BracesAroundHashParameters:
|
10
11
|
Enabled: false
|
11
12
|
|
12
|
-
|
13
|
+
Layout/IndentHash:
|
13
14
|
EnforcedStyle: consistent
|
14
15
|
|
15
|
-
|
16
|
+
Layout/AlignHash:
|
16
17
|
Severity: fatal
|
17
18
|
Enabled: true
|
18
19
|
EnforcedHashRocketStyle: table
|
19
20
|
EnforcedColonStyle: table
|
20
21
|
|
21
|
-
|
22
|
+
Layout/AlignParameters:
|
22
23
|
EnforcedStyle: with_fixed_indentation
|
23
24
|
|
24
25
|
Style/StringLiterals:
|
@@ -32,13 +33,13 @@ Style/CollectionMethods:
|
|
32
33
|
detect: 'find'
|
33
34
|
find_all: 'select'
|
34
35
|
|
35
|
-
|
36
|
+
Layout/DotPosition:
|
36
37
|
EnforcedStyle: leading
|
37
38
|
|
38
39
|
Style/DoubleNegation:
|
39
40
|
Enabled: false
|
40
41
|
|
41
|
-
|
42
|
+
Layout/SpaceAroundOperators:
|
42
43
|
# When true, allows most uses of extra spacing if the intent is to align
|
43
44
|
# with an operator on the previous or next line, not counting empty lines
|
44
45
|
# or comment lines.
|
@@ -47,6 +48,9 @@ Style/SpaceAroundOperators:
|
|
47
48
|
Style/FrozenStringLiteralComment:
|
48
49
|
Enabled: false
|
49
50
|
|
51
|
+
Style/DateTime:
|
52
|
+
Enabled: false
|
53
|
+
|
50
54
|
AllCops:
|
51
55
|
Exclude:
|
52
56
|
- '*.gemspec'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
@@ -42,28 +42,71 @@ module Parliament
|
|
42
42
|
#
|
43
43
|
# @since 0.1.0
|
44
44
|
module Decorator
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
MAPPING = {
|
46
|
+
'ConstituencyArea' => ConstituencyArea,
|
47
|
+
'ConstituencyGroup' => ConstituencyGroup,
|
48
|
+
'ContactPoint' => ContactPoint,
|
49
|
+
'EuropeanRegion' => EuropeanRegion,
|
50
|
+
'Gender' => Gender,
|
51
|
+
'GenderIdentity' => GenderIdentity,
|
52
|
+
'House' => House,
|
53
|
+
'HouseSeat' => HouseSeat,
|
54
|
+
'MemberImage' => MemberImage,
|
55
|
+
'ParliamentPeriod' => ParliamentPeriod,
|
56
|
+
'ParliamentaryIncumbency' => ParliamentaryIncumbency,
|
57
|
+
'Party' => Party,
|
58
|
+
'PartyMembership' => PartyMembership,
|
59
|
+
'Person' => Person,
|
60
|
+
'PostalAddress' => PostalAddress,
|
61
|
+
'SeatIncumbency' => SeatIncumbency,
|
62
|
+
'FormalBodyMembership' => FormalBodyMembership,
|
63
|
+
'FormalBody' => FormalBody,
|
64
|
+
'FormalBodyType' => FormalBodyType,
|
65
|
+
'GovernmentIncumbency' => GovernmentIncumbency,
|
66
|
+
'GovernmentPosition' => GovernmentPosition,
|
67
|
+
'OppositionIncumbency' => OppositionIncumbency,
|
68
|
+
'OppositionPosition' => OppositionPosition,
|
69
|
+
'WebArticle' => WebArticle,
|
70
|
+
'Audience' => Audience,
|
71
|
+
'ArticleType' => ArticleType,
|
72
|
+
'Collection' => Collection,
|
73
|
+
'Concept' => Concept,
|
74
|
+
'Incumbency' => Incumbency,
|
75
|
+
'Group' => Group,
|
76
|
+
'GovRegisterGovernmentOrganisation' => GovRegisterGovernmentOrganisation,
|
77
|
+
'Position' => Position,
|
78
|
+
'FormalBodyChair' => FormalBodyChair
|
79
|
+
}.freeze
|
80
|
+
|
81
|
+
class << self
|
82
|
+
# Gets the root directory of the gem
|
83
|
+
def gem_path
|
84
|
+
File.expand_path '../../..', __dir__
|
85
|
+
end
|
49
86
|
|
50
|
-
|
51
|
-
|
52
|
-
|
87
|
+
def load!
|
88
|
+
# Loads the translation file into the I18n gem
|
89
|
+
I18n.load_path += Dir[File.join(gem_path, 'config', 'locales', '*.yml')]
|
90
|
+
I18n.backend.load_translations
|
91
|
+
end
|
53
92
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
93
|
+
# Decorates objects with alias methods extended from its decorator module.
|
94
|
+
#
|
95
|
+
# @param [Grom::Node] object the object to be decorated.
|
96
|
+
def decorate(object)
|
97
|
+
return object unless object.respond_to?(:type)
|
59
98
|
|
60
|
-
|
99
|
+
Array(object.type).each do |type|
|
100
|
+
decorator = MAPPING[::Grom::Helper.get_id(type)] # Get the decorator for a type, or nil
|
61
101
|
|
62
|
-
|
102
|
+
object.extend(decorator) unless decorator.nil?
|
103
|
+
end
|
63
104
|
|
64
|
-
|
65
|
-
|
105
|
+
object
|
106
|
+
end
|
66
107
|
end
|
67
108
|
end
|
68
109
|
end
|
69
110
|
end
|
111
|
+
|
112
|
+
Parliament::Grom::Decorator.load!
|
@@ -117,14 +117,10 @@ module Parliament
|
|
117
117
|
return @party_name unless @party_name.nil?
|
118
118
|
current_incumbency = seat_incumbencies.select(&:current?).first
|
119
119
|
|
120
|
-
|
121
|
-
current_membership = current_incumbency.member.party_memberships.select(&:current?).first
|
122
|
-
@party_name = current_membership.nil? ? nil : current_membership.party.name
|
123
|
-
else
|
124
|
-
@party_name = nil
|
125
|
-
end
|
120
|
+
return @party_name = nil unless current_incumbency
|
126
121
|
|
127
|
-
|
122
|
+
current_membership = current_incumbency.member.party_memberships.select(&:current?).first
|
123
|
+
@party_name = current_membership.nil? ? nil : current_membership.party.name
|
128
124
|
end
|
129
125
|
|
130
126
|
# @return [Array, Array] the regions of the Grom::Node or an empty array.
|
@@ -2,7 +2,6 @@ module Parliament
|
|
2
2
|
module Grom
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: http://data.ordnancesurvey.co.uk/ontology/admingeo/EuropeanRegion.
|
5
|
-
# rubocop:disable ModuleLength
|
6
5
|
module EuropeanRegion
|
7
6
|
# Alias prefLabel with fallback.
|
8
7
|
#
|
@@ -1,16 +1,15 @@
|
|
1
1
|
module Parliament
|
2
2
|
module Grom
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/FormalBodyChair.
|
5
|
+
module FormalBodyType
|
6
|
+
# Checks if Grom::Node has a formal body type name.
|
7
|
+
#
|
8
|
+
# @return [String, String] a string depending on whether or not the Grom::Node has a formal body type name.
|
9
|
+
def name
|
10
|
+
respond_to?(:formalbodyTypeName) ? formalbodyTypeName : ''
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
15
14
|
end
|
16
15
|
end
|
@@ -2,7 +2,6 @@ module Parliament
|
|
2
2
|
module Grom
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/GovRegisterGovernmentOrganisation.
|
5
|
-
# rubocop:disable ModuleLength
|
6
5
|
module GovRegisterGovernmentOrganisation
|
7
6
|
include Helpers::DateHelper
|
8
7
|
|
@@ -37,6 +37,20 @@ module Parliament
|
|
37
37
|
def house_incumbencies
|
38
38
|
respond_to?(:houseHasHouseIncumbency) ? houseHasHouseIncumbency : []
|
39
39
|
end
|
40
|
+
|
41
|
+
# Is this the lords?
|
42
|
+
#
|
43
|
+
# @return Boolean is the house the lords?
|
44
|
+
def lords?
|
45
|
+
name == 'House of Lords'
|
46
|
+
end
|
47
|
+
|
48
|
+
# Is this the commons?
|
49
|
+
#
|
50
|
+
# @return Boolean is the house the commons?
|
51
|
+
def commons?
|
52
|
+
name == 'House of Commons'
|
53
|
+
end
|
40
54
|
end
|
41
55
|
end
|
42
56
|
end
|
@@ -2,7 +2,6 @@ module Parliament
|
|
2
2
|
module Grom
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Person.
|
5
|
-
# rubocop:disable ModuleLength
|
6
5
|
module Person
|
7
6
|
include Helpers::DateHelper
|
8
7
|
|
@@ -304,22 +303,14 @@ module Parliament
|
|
304
303
|
private
|
305
304
|
|
306
305
|
def current_member_by_house?(house_name)
|
307
|
-
seat_incumbencies.select{ |incumbency| incumbency.house.name == house_name && incumbency.end_date.nil? }.any?
|
306
|
+
seat_incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date.nil? }.any?
|
308
307
|
end
|
309
308
|
|
310
309
|
def former_member_by_house?(house_name)
|
311
|
-
seat_incumbencies.select{ |incumbency| incumbency.house.name == house_name && incumbency.end_date }.any?
|
310
|
+
seat_incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date }.any?
|
312
311
|
end
|
313
312
|
|
314
313
|
def house_membership_status
|
315
|
-
no_current_seat_incumbency = seat_incumbencies.select(&:current?).empty?
|
316
|
-
former_lord = former_lord?
|
317
|
-
former_mp = (seat_incumbencies.any? && no_current_seat_incumbency)
|
318
|
-
|
319
|
-
build_house_membership_status(no_current_seat_incumbency, former_lord, former_mp)
|
320
|
-
end
|
321
|
-
|
322
|
-
def build_house_membership_status(no_current_seat_incumbency, former_lord, former_mp)
|
323
314
|
statuses = []
|
324
315
|
current_mp = current_mp?
|
325
316
|
current_lord = current_lord?
|
@@ -15,9 +15,7 @@ module Parliament
|
|
15
15
|
def address_array
|
16
16
|
address_array = []
|
17
17
|
(1..5).each do |i|
|
18
|
-
if respond_to?("addressLine#{i}".to_sym)
|
19
|
-
address_array << instance_variable_get("@addressLine#{i}".to_sym)
|
20
|
-
end
|
18
|
+
address_array << instance_variable_get("@addressLine#{i}".to_sym) if respond_to?("addressLine#{i}".to_sym)
|
21
19
|
end
|
22
20
|
address_array << postCode if respond_to?(:postCode)
|
23
21
|
address_array
|
@@ -67,12 +67,14 @@ module Parliament
|
|
67
67
|
respond_to?(:parliamentaryIncumbencyHasMember) ? parliamentaryIncumbencyHasMember.first : nil
|
68
68
|
end
|
69
69
|
|
70
|
+
# @depreciatedn Use {#lords?} on a House object instead. I.e. `seat_incumbency.house.lords?`
|
70
71
|
def house_of_lords?
|
71
|
-
house.
|
72
|
+
house.lords?
|
72
73
|
end
|
73
74
|
|
75
|
+
# @depreciatedn Use {#commons?} on a House object instead. I.e. `seat_incumbency.house.commons?`
|
74
76
|
def house_of_commons?
|
75
|
-
house.
|
77
|
+
house.commons?
|
76
78
|
end
|
77
79
|
end
|
78
80
|
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.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rebecca Appleyard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- ".hound.yml"
|
162
162
|
- ".rspec"
|
163
163
|
- ".rubocop.yml"
|
164
|
+
- ".ruby-version"
|
164
165
|
- ".travis.yml"
|
165
166
|
- CODE_OF_CONDUCT.md
|
166
167
|
- Gemfile
|