parliament-grom-decorators 0.29.0 → 0.30.0

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: 69068c3ab18f674b86ff50b32a608f8bfc6453b1
4
- data.tar.gz: 322b764827d32d6017cae3ed08002dafc185a3cf
3
+ metadata.gz: 61ac05487ac2d1b3e88ef39f0361119e613c6653
4
+ data.tar.gz: f7b968e9b68959d11f6d536445ea5e2861802c27
5
5
  SHA512:
6
- metadata.gz: c281487dfc8d0c27875214bfbacbd234efaa7a303b2be9b430f6fcf1b812992a3b6711d2d84dcc95eeac398fed3f48b768849f3abfe3b20e2249e7132f014d82
7
- data.tar.gz: 78d073630b3ec21f2cf916da27dff4a1b36c71a3a39c43f7d5cfecff3f45c135f62023ef62e9e19adbaf1ee4a6da8ea91271a76e0b623559304d4dcde889a53e
6
+ metadata.gz: c9d8cd1fe703a8549672297179ddf8c3e24b1225d7a01d6ed0a7d9a2338aaa9bcea59d45fe6867540b8eab0d60fa00bd3be1b48cbe6b00d34c8ca955b5d57e13
7
+ data.tar.gz: e9faf90985cc7c74ea445cfa86f3b3992c7589bb45488e90ea0fcb93235506b0cc45292d3dbb402aa7d00da570697f45541e1e50c5f421ca23c6df708651988e
@@ -1,54 +1,7 @@
1
1
  require 'parliament/grom/decorator/version'
2
2
  require 'parliament/grom/decorator/helpers'
3
- require 'parliament/grom/decorator/answer'
4
- require 'parliament/grom/decorator/answering_body'
5
- require 'parliament/grom/decorator/answering_body_allocation'
6
- require 'parliament/grom/decorator/article_type'
7
- require 'parliament/grom/decorator/audience'
8
- require 'parliament/grom/decorator/business_item'
9
- require 'parliament/grom/decorator/collection'
10
- require 'parliament/grom/decorator/concept'
11
- require 'parliament/grom/decorator/constituency_area'
12
- require 'parliament/grom/decorator/constituency_group'
13
- require 'parliament/grom/decorator/contact_point'
14
- require 'parliament/grom/decorator/european_region'
15
- require 'parliament/grom/decorator/formal_body'
16
- require 'parliament/grom/decorator/formal_body_chair'
17
- require 'parliament/grom/decorator/formal_body_membership'
18
- require 'parliament/grom/decorator/formal_body_type'
19
- require 'parliament/grom/decorator/gender'
20
- require 'parliament/grom/decorator/gender_identity'
21
- require 'parliament/grom/decorator/government_incumbency'
22
- require 'parliament/grom/decorator/government_position'
23
- require 'parliament/grom/decorator/gov_register_government_organisation'
24
- require 'parliament/grom/decorator/group'
25
- require 'parliament/grom/decorator/house'
26
- require 'parliament/grom/decorator/house_seat'
27
- require 'parliament/grom/decorator/incumbency'
28
- require 'parliament/grom/decorator/laid_thing'
29
- require 'parliament/grom/decorator/laying'
30
- require 'parliament/grom/decorator/laying_body'
31
- require 'parliament/grom/decorator/member_image'
32
- require 'parliament/grom/decorator/parliamentary_incumbency'
33
- require 'parliament/grom/decorator/parliaments'
34
- require 'parliament/grom/decorator/party'
35
- require 'parliament/grom/decorator/party_membership'
36
- require 'parliament/grom/decorator/person'
37
- require 'parliament/grom/decorator/position'
38
- require 'parliament/grom/decorator/postal_address'
39
- require 'parliament/grom/decorator/procedure_route'
40
- require 'parliament/grom/decorator/procedure_step'
41
- require 'parliament/grom/decorator/procedure'
42
- require 'parliament/grom/decorator/proposed_negative_statutory_instrument_paper'
43
- require 'parliament/grom/decorator/question'
44
- require 'parliament/grom/decorator/seat_incumbency'
45
- require 'parliament/grom/decorator/statutory_instrument_paper'
46
- require 'parliament/grom/decorator/opposition_incumbency'
47
- require 'parliament/grom/decorator/opposition_position'
48
- require 'parliament/grom/decorator/web_article'
49
- require 'parliament/grom/decorator/work_package'
50
- require 'parliament/grom/decorator/work_packageable_thing'
51
- require 'parliament/grom/decorator/work_packaged_thing'
3
+
4
+ Dir['./lib/parliament/grom/decorator/*.rb'].each { |file| require file }
52
5
 
53
6
  # Namespace for classes and modules that handle connections to, and processing of data from the parliamentary API.
54
7
  # @since 0.1.0
@@ -58,57 +11,13 @@ module Parliament
58
11
  #
59
12
  # @since 0.1.0
60
13
  module Decorator
61
- MAPPING = {
62
- 'Answer' => Answer,
63
- 'AnsweringBody' => AnsweringBody,
64
- 'AnsweringBodyAllocation' => AnsweringBodyAllocation,
65
- 'ArticleType' => ArticleType,
66
- 'Audience' => Audience,
67
- 'BusinessItem' => BusinessItem,
68
- 'Collection' => Collection,
69
- 'Concept' => Concept,
70
- 'ConstituencyArea' => ConstituencyArea,
71
- 'ConstituencyGroup' => ConstituencyGroup,
72
- 'ContactPoint' => ContactPoint,
73
- 'EuropeanRegion' => EuropeanRegion,
74
- 'FormalBodyChair' => FormalBodyChair,
75
- 'FormalBodyMembership' => FormalBodyMembership,
76
- 'FormalBodyType' => FormalBodyType,
77
- 'FormalBody' => FormalBody,
78
- 'Gender' => Gender,
79
- 'GenderIdentity' => GenderIdentity,
80
- 'GovernmentIncumbency' => GovernmentIncumbency,
81
- 'GovernmentPosition' => GovernmentPosition,
82
- 'GovRegisterGovernmentOrganisation' => GovRegisterGovernmentOrganisation,
83
- 'Group' => Group,
84
- 'House' => House,
85
- 'HouseSeat' => HouseSeat,
86
- 'Incumbency' => Incumbency,
87
- 'LaidThing' => LaidThing,
88
- 'Laying' => Laying,
89
- 'LayingBody' => LayingBody,
90
- 'MemberImage' => MemberImage,
91
- 'OppositionIncumbency' => OppositionIncumbency,
92
- 'OppositionPosition' => OppositionPosition,
93
- 'ParliamentPeriod' => ParliamentPeriod,
94
- 'ParliamentaryIncumbency' => ParliamentaryIncumbency,
95
- 'Party' => Party,
96
- 'PartyMembership' => PartyMembership,
97
- 'Person' => Person,
98
- 'Position' => Position,
99
- 'Procedure' => Procedure,
100
- 'ProcedureRoute' => ProcedureRoute,
101
- 'ProcedureStep' => ProcedureStep,
102
- 'ProposedNegativeStatutoryInstrumentPaper' => ProposedNegativeStatutoryInstrumentPaper,
103
- 'PostalAddress' => PostalAddress,
104
- 'Question' => Question,
105
- 'SeatIncumbency' => SeatIncumbency,
106
- 'StatutoryInstrumentPaper' => StatutoryInstrumentPaper,
107
- 'WebArticle' => WebArticle,
108
- 'WorkPackage' => WorkPackage,
109
- 'WorkPackageableThing' => WorkPackageableThing,
110
- 'WorkPackagedThing' => WorkPackagedThing
111
- }.freeze
14
+ INTERNAL_MODULES = %i[
15
+ Helpers
16
+ VERSION
17
+ ].freeze
18
+
19
+ MAPPING = {}
20
+ (constants - INTERNAL_MODULES).each { |constant| MAPPING[constant.to_s] = const_get(constant) }
112
21
 
113
22
  class << self
114
23
  # Gets the root directory of the gem
@@ -84,7 +84,7 @@ module Parliament
84
84
  #
85
85
  # @return [Boolean] whether or not the group is a select committee.
86
86
  def select_committee?
87
- type.include?('https://id.parliament.uk/schema/SelectCommittee')
87
+ type.include?(Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('SelectCommittee'))
88
88
  end
89
89
 
90
90
  # Checks what type of committee a Grom::Node represents.
@@ -34,7 +34,7 @@ module Parliament
34
34
 
35
35
  # @return [Boolean] whether the group is also a formal body.
36
36
  def formal_body?
37
- type.include?('https://id.parliament.uk/schema/FormalBody')
37
+ type.include?(Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('FormalBody'))
38
38
  end
39
39
  end
40
40
  end
@@ -8,7 +8,7 @@ module Parliament
8
8
  # @param [String] date_format a string that represents the format we want to use for the date
9
9
  # @example Format a node with an end_date with the date format YYYY-MM-DD
10
10
  # "grom_node_instance.date_range('%Y-%m-%d)" #=> "2010-01-01 to 2015-01-01"
11
- def date_range(date_format: '%-d %B %Y')
11
+ def date_range(date_format: '%-d %-B %Y')
12
12
  return I18n.t('date_unavailable') if start_date.nil?
13
13
  if end_date
14
14
  "#{I18n.l(start_date, format: date_format)} #{I18n.t('to')} #{I18n.l(end_date, format: date_format)}"
@@ -82,7 +82,7 @@ module Parliament
82
82
  #
83
83
  # @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
84
84
  def seat_incumbencies
85
- @seat_incumbencies ||= incumbencies.select { |inc| inc.type.include?('https://id.parliament.uk/schema/SeatIncumbency') }
85
+ @seat_incumbencies ||= incumbencies.select { |inc| inc.type.include?(Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('SeatIncumbency')) }
86
86
  end
87
87
 
88
88
  # @return [Grom::Node] the seat incumbency as a Grom::Node or nil
@@ -1,7 +1,7 @@
1
1
  module Parliament
2
2
  module Grom
3
3
  module Decorator
4
- VERSION = '0.29.0'.freeze
4
+ VERSION = '0.30.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -29,5 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'webmock', '~> 2.3'
30
30
  spec.add_development_dependency 'parliament-ruby'
31
31
  spec.add_development_dependency 'parliament-ntriple', '~> 0.2'
32
+ spec.add_development_dependency 'parliament-utils', '~> 0.8'
32
33
  spec.add_development_dependency 'timecop', '~> 0.8'
33
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parliament-grom-decorators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rebecca Appleyard
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: parliament-utils
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.8'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.8'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: timecop
141
155
  requirement: !ruby/object:Gem::Requirement