parliament-utils 0.3.2 → 0.4.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 +4 -4
- data/.DS_Store +0 -0
- data/config/.DS_Store +0 -0
- data/lib/parliament/utils/helpers/houses_helper.rb +3 -3
- data/lib/parliament/utils/helpers/request_helper.rb +28 -0
- data/lib/parliament/utils/helpers/v_card_helper.rb +4 -4
- data/lib/parliament/utils/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 795764a9bbba4f5338d6062d7b30899743128074
|
4
|
+
data.tar.gz: '09539ae176e8968d3bcbe22d7ea2098157f6b4c6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d417b23d8c431e696573625dec1f65a7d849dfb47465aadb0cb7d399d498b3bf5efeb623fc4a407238783d9cc396f68b4170dfb29d7300e382afd4389fe04c61
|
7
|
+
data.tar.gz: 05a2a5b4a30b2c46ab802f799ade84f8407dd624efb3bd152f4d75fef8c0a74b00348360417b96e2aaabdb3e340abc2762c3162aec3d3482a44bb1a00347de4e
|
data/.DS_Store
ADDED
Binary file
|
data/config/.DS_Store
ADDED
Binary file
|
@@ -4,7 +4,7 @@ module Parliament
|
|
4
4
|
module HousesHelper
|
5
5
|
# Checks if house is the House of Commons and sets @commons_id and @lords_id if not already set.
|
6
6
|
#
|
7
|
-
# @param [Grom::Node] house a Grom::Node with type
|
7
|
+
# @param [Grom::Node] house a Grom::Node with type https://id.parliament.uk/schema/House.
|
8
8
|
# @return [Boolean] boolean depending on whether the house has the same id as the House of Commons.
|
9
9
|
def self.commons?(house)
|
10
10
|
set_ids
|
@@ -14,7 +14,7 @@ module Parliament
|
|
14
14
|
|
15
15
|
# Checks if house is the House of Lords and sets @commons_id and @lords_id if not already set.
|
16
16
|
#
|
17
|
-
# @param [Grom::Node] house a Grom::Node with type
|
17
|
+
# @param [Grom::Node] house a Grom::Node with type https://id.parliament.uk/schema/House.
|
18
18
|
# @return [Boolean] boolean depending on whether the house has the same id as the House of Lords.
|
19
19
|
def self.lords?(house)
|
20
20
|
!commons?(house)
|
@@ -69,7 +69,7 @@ module Parliament
|
|
69
69
|
|
70
70
|
def self.set_ids
|
71
71
|
return if @commons_id && @lords_id
|
72
|
-
houses = Parliament::Utils::Helpers::ParliamentHelper.parliament_request.house_index.get.filter('
|
72
|
+
houses = Parliament::Utils::Helpers::ParliamentHelper.parliament_request.house_index.get.filter('https://id.parliament.uk/schema/House').sort_by(:name)
|
73
73
|
|
74
74
|
@commons_id = houses.first.graph_id
|
75
75
|
@lords_id = houses.last.graph_id
|
@@ -3,6 +3,9 @@ module Parliament
|
|
3
3
|
module Utils
|
4
4
|
module Helpers
|
5
5
|
module RequestHelper
|
6
|
+
# The base namespace used for filtering parliamentary data within sparql queries
|
7
|
+
NAMESPACE_URI = 'https://id.parliament.uk'.freeze
|
8
|
+
|
6
9
|
# Takes a Parliament::Request and calls the #get method.
|
7
10
|
# Then maps the #value method on the resulting response.
|
8
11
|
#
|
@@ -24,6 +27,31 @@ module Parliament
|
|
24
27
|
response = request.get
|
25
28
|
response.filter(*filters)
|
26
29
|
end
|
30
|
+
|
31
|
+
# Returns the base namespace used for filtering parliamentary data within sparql queries
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
def self.namespace_uri
|
35
|
+
NAMESPACE_URI
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns uri with specific path added for filtering parliamentary data within sparql queries
|
39
|
+
#
|
40
|
+
# @param [String] Path string to append to the base uri
|
41
|
+
#
|
42
|
+
# @return [String] uri with specific path added for filtering parliamentary data within sparql queries
|
43
|
+
def self.namespace_uri_path(path)
|
44
|
+
self.namespace_uri + path
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns uri with schema path and specific type added for filtering parliamentary data within sparql queries
|
48
|
+
#
|
49
|
+
# @param [String] Type string to append to the schema uri
|
50
|
+
#
|
51
|
+
# @return [String] uri with schema path and specific type added for filtering parliamentary data within sparql queries
|
52
|
+
def self.namespace_uri_schema_path(type)
|
53
|
+
self.namespace_uri_path("/schema/#{type}")
|
54
|
+
end
|
27
55
|
end
|
28
56
|
end
|
29
57
|
end
|
@@ -5,7 +5,7 @@ module Parliament
|
|
5
5
|
module VCardHelper
|
6
6
|
# Generates a vcard for the given contact point.
|
7
7
|
#
|
8
|
-
# @param [Grom::Node] contact_point a Grom::Node with type:
|
8
|
+
# @param [Grom::Node] contact_point a Grom::Node with type: https://id.parliament.uk/schema/ContactPoint.
|
9
9
|
# @return [Vcard::Vcard] a vcard with person, postal address and contact details set.
|
10
10
|
def create_vcard(contact_point)
|
11
11
|
Vcard::Vcard::Maker.make2 do |maker|
|
@@ -19,7 +19,7 @@ module Parliament
|
|
19
19
|
|
20
20
|
# Sets the contact details of a vcard.
|
21
21
|
#
|
22
|
-
# @param [Grom::Node] contact_point a Grom::Node with type:
|
22
|
+
# @param [Grom::Node] contact_point a Grom::Node with type: https://id.parliament.uk/schema/ContactPoint.
|
23
23
|
# @param [Vcard::Vcard::Maker] maker a Vcard builder.
|
24
24
|
# @return [Vcard::Vcard::Maker] a Vcard maker with contact details set.
|
25
25
|
def contacts_set(contact_point, maker)
|
@@ -30,7 +30,7 @@ module Parliament
|
|
30
30
|
|
31
31
|
# Sets the postal address of a vcard.
|
32
32
|
#
|
33
|
-
# @param [Grom::Node] contact_point a Grom::Node with type:
|
33
|
+
# @param [Grom::Node] contact_point a Grom::Node with type: https://id.parliament.uk/schema/ContactPoint.
|
34
34
|
# @param [Vcard::Vcard::Maker] maker a Vcard builder.
|
35
35
|
# @return [Vcard::Vcard::Maker, Boolean] a Vcard maker with postal address set or false if the contact point has no postal addresses.
|
36
36
|
def postal_address_set(contact_point, maker)
|
@@ -43,7 +43,7 @@ module Parliament
|
|
43
43
|
|
44
44
|
# Sets the person details of a vcard.
|
45
45
|
#
|
46
|
-
# @param [Grom::Node] contact_point a Grom::Node with type:
|
46
|
+
# @param [Grom::Node] contact_point a Grom::Node with type: https://id.parliament.uk/schema/ContactPoint.
|
47
47
|
# @param [Object] name a Vcard::Name.
|
48
48
|
# @return [Vcard::Vcard::Maker, Boolean] a Vcard maker with person details set or false if the contact point is not associated with a person.
|
49
49
|
def person_set(contact_point, name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parliament-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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: 2017-10-
|
11
|
+
date: 2017-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parliament-ruby
|
@@ -241,6 +241,7 @@ executables: []
|
|
241
241
|
extensions: []
|
242
242
|
extra_rdoc_files: []
|
243
243
|
files:
|
244
|
+
- ".DS_Store"
|
244
245
|
- ".gitignore"
|
245
246
|
- ".hound.yml"
|
246
247
|
- ".rspec"
|
@@ -256,6 +257,7 @@ files:
|
|
256
257
|
- Rakefile
|
257
258
|
- bin/console
|
258
259
|
- bin/setup
|
260
|
+
- config/.DS_Store
|
259
261
|
- config/locales/en.yml
|
260
262
|
- config/puma.rb
|
261
263
|
- lib/parliament/utils.rb
|