parliament-grom-decorators 0.24.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 237cd75404e1e9b7414813fe6703c7eb29bd6b59
4
- data.tar.gz: a77c9965d2f48d55481127151059e9342745978e
3
+ metadata.gz: '0054219819c9cf5ba0fef958aca46148cba22a49'
4
+ data.tar.gz: 7d5e3321395c970117c3c1bafcb31568cee2feed
5
5
  SHA512:
6
- metadata.gz: ec47ca9e7f5b3efe00ffffcbf73ec0a309b5d469865d459b618a77049a286e227089ff3df11a19cecc0dcb2462f5b2a1778f31e014b170cc63691e32d157d7cb
7
- data.tar.gz: bfccc5e33a802105b3e7d49736896baf5822dcb525877b3cfabb3f2dcc134c9060cc00d9d660aba9c5eefa659a67d2c408f49a4a39e0d45a4f51290723f94faf
6
+ metadata.gz: 9b458832d8f93df5eb2a0a1c7488c20ebc5f1bdf4928b9fce540b30dd68a05eaebe74d30f6999d04fd9f8962d526914da8c5ffc4cdfc0d6e3780afb335cd59f1
7
+ data.tar.gz: 494be78cd713accfe9eb06e3f353620457f248f925edaa4ebc2df1ab3c2c8c243b5c02cf59e1fad01ce2a48899c4f84f675b2a6cba76fc25c8938e1663de0b43
@@ -19,6 +19,18 @@ module Parliament
19
19
  respond_to?(:formalBodyHasFormalBodyChair)
20
20
  end
21
21
 
22
+ # Alias is_chair with fallback.
23
+ #
24
+ # @return [Array, Array] an array of Position Grom::Nodes representing the chair or an empty array.
25
+ def chairs
26
+ respond_to?(:formalBodyHasFormalBodyChair) ? formalBodyHasFormalBodyChair : []
27
+ end
28
+
29
+ # @return [Array, Array] array of Person Grom::Node(s) representing the current incumbent(s) of chair position(s).
30
+ def chair_people
31
+ chairs.first&.incumbencies&.first&.people || []
32
+ end
33
+
22
34
  # Alias formalBodyStartDate with fallback.
23
35
  #
24
36
  # @return [DateTime, nil] the start date of the Grom::Node or nil.
@@ -56,10 +68,32 @@ module Parliament
56
68
 
57
69
  # Checks if Grom::Node has contact points.
58
70
  #
59
- # @return [Array, Array] an arry containing the contact_point(s), or an empty array.
71
+ # @return [Array, Array] an array containing the contact_point(s), or an empty array.
60
72
  def contact_points
61
73
  @contact_points ||= respond_to?(:formalBodyHasContactPoint) ? Array(formalBodyHasContactPoint) : []
62
74
  end
75
+
76
+ # Checks if Grom::Node has a house.
77
+ #
78
+ # @return [Array, Array] an array of House Grom::Nodes, or an empty array.
79
+ def houses
80
+ respond_to?(:formalBodyHasHouse) ? formalBodyHasHouse : []
81
+ end
82
+
83
+ # Checks if the type of Grom::Node is a select committee.
84
+ #
85
+ # @return [Boolean] whether or not the group is a select committee.
86
+ def select_committee?
87
+ type.include?('https://id.parliament.uk/schema/SelectCommittee')
88
+ end
89
+
90
+ # Checks what type of committee a Grom::Node represents.
91
+ # TODO: Build out as the types of possible committee types grows
92
+ #
93
+ # @return [String, String] whether or not the group is a select committee.
94
+ def committee_type
95
+ select_committee? ? 'select' : ''
96
+ end
63
97
  end
64
98
  end
65
99
  end
@@ -4,6 +4,12 @@ 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
7
13
 
8
14
  # Alias groupStartDate with fallback.
9
15
  #
@@ -12,20 +18,6 @@ module Parliament
12
18
  @start_date ||= respond_to?(:groupStartDate) ? DateTime.parse(groupStartDate) : nil
13
19
  end
14
20
 
15
- # Alias formalBodyName with fallback.
16
- #
17
- # @return [String, String] the formal body name of the Grom::Node or an empty string.
18
- def formal_body_name
19
- @formal_body_name ||= respond_to?(:formalBodyName) ? formalBodyName : ''
20
- end
21
-
22
- # Alias formalBodyRemit with fallback.
23
- #
24
- # @return [String, String] the formal body remit of the Grom::Node or an empty string.
25
- def formal_body_remit
26
- @formal_body_remit ||= respond_to?(:formalBodyRemit) ? formalBodyRemit : ''
27
- end
28
-
29
21
  # Alias member count with fallback.
30
22
  #
31
23
  # @return [Integer, nil] the count of members of the Grom::Node or nil.
@@ -33,33 +25,12 @@ module Parliament
33
25
  respond_to?(:count) ? count.to_i : nil
34
26
  end
35
27
 
36
- # Alias is_joint with fallback.
37
- #
38
- # @return [Boolean] a boolean depending on whether or not the Grom::Node is joint.
39
- def joint?
40
- respond_to?(:formalBodyHasLeadHouse)
41
- end
42
-
43
- # Alias is_chair with fallback.
44
- #
45
- # @return [Boolean] a boolean depending on whether or not the Grom::Node is chair.
46
- def has_chair?
47
- respond_to?(:formalBodyHasFormalBodyChair)
48
- end
49
-
50
28
  # Alias groupEndDate with fallback.
51
29
  #
52
30
  # @return [DateTime, nil] the end date of the Grom::Node or nil.
53
31
  def end_date
54
32
  @end_date ||= respond_to?(:groupEndDate) ? DateTime.parse(groupEndDate) : nil
55
33
  end
56
-
57
- # Alias groupName with fallback.
58
- #
59
- # @return [String, String] the name of the Grom::Node or an empty string.
60
- def name
61
- respond_to?(:groupName) ? groupName : ''
62
- end
63
34
  end
64
35
  end
65
36
  end
@@ -303,11 +303,11 @@ module Parliament
303
303
  private
304
304
 
305
305
  def current_member_by_house?(house_name)
306
- seat_incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date.nil? }.any?
306
+ incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date.nil? }.any?
307
307
  end
308
308
 
309
309
  def former_member_by_house?(house_name)
310
- seat_incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date }.any?
310
+ incumbencies.select { |incumbency| incumbency.house.name == house_name && incumbency.end_date }.any?
311
311
  end
312
312
 
313
313
  def house_membership_status
@@ -1,7 +1,7 @@
1
1
  module Parliament
2
2
  module Grom
3
3
  module Decorator
4
- VERSION = '0.24.0'.freeze
4
+ VERSION = '0.25.0'.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.24.0
4
+ version: 0.25.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-04-23 00:00:00.000000000 Z
11
+ date: 2018-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler