parliament-utils 0.5.0 → 0.6.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: ddf7a1e70bcdc34a8eee422e58139b702129923f
4
- data.tar.gz: 35b65d62db6d438f29597088aaeb3920ab5c7f51
3
+ metadata.gz: 3b1bc71c1a239694b68c057e362302dadfd7b18a
4
+ data.tar.gz: f27aa41311b6129bd759fc49dd9472fff871e6d6
5
5
  SHA512:
6
- metadata.gz: 1ff11e1eea29d06a256ecb4722921b965af6e994c5c81b83c0564acc04ca9d6354ed07a63641ff648d7d79bc579f225f4ea5805db299f1cc137c51135ade70fd
7
- data.tar.gz: b92e06674a3c6aad5fa6fe2007ae4c2b4cec5fc7b0575a3ede9603acea3b4feff31bf52f4b633a963753b26036fa9b33910f641daa89623ebfca2b73023c4c7e
6
+ metadata.gz: 819087efb47d3873b5e153c658f8ae1cdb8410caa76bb421f2cd735f2409147e9e3e3ec6ddfa60e765fb9194532e61a0f20e03d3e368d6e7e436dee3930114d2
7
+ data.tar.gz: 7ebc1412f95ec4c9922df5f6f81109787cfecf896de39cef44c336a6603794738b9442f09300734cb70e67b2108b851e67fa859e4f01e4efee6e5adcdfb18e06
data/.travis.yml CHANGED
@@ -3,3 +3,5 @@ language: ruby
3
3
  rvm:
4
4
  - 2.4.0
5
5
  before_install: gem install bundler -v 1.15.1
6
+ env:
7
+ - PARLIAMENT_BASE_URL=https://api.parliament.uk/Staging/fixed-query
@@ -6,6 +6,7 @@ require_relative './helpers/parliament_helper'
6
6
  require_relative './helpers/postcode_helper'
7
7
  require_relative './helpers/request_helper'
8
8
  require_relative './helpers/v_card_helper'
9
+ require_relative './helpers/filter_helper'
9
10
 
10
11
  require 'parliament/grom/decorator'
11
12
 
@@ -0,0 +1,52 @@
1
+ # Namespace for Parliament::Filter helper methods.
2
+ module Parliament
3
+ module Utils
4
+ module Helpers
5
+ module FilterHelper
6
+ # Takes a request object and a variable amount of types for filtering, gets types_to_filter using #filter_types method, and calls RequestHelper.filter_response_data to return filtered NTriple Object
7
+ #
8
+ # @param [Parliament::Request] request a Parliament::Request object
9
+ # @param [String] *types a variable amount of types to filter by
10
+ #
11
+ # @return [Parliament::Response::NTripleResponse] Ntriple response filtered by types
12
+ def self.filter(request, *types)
13
+ types_to_filter = self.filter_types(*types)
14
+ Parliament::Utils::Helpers::RequestHelper.filter_response_data(
15
+ request, *types_to_filter
16
+ )
17
+ end
18
+
19
+ # Takes variable amount of types for filtering, checks if type is 'ordnance', and returns array of types to filter
20
+ #
21
+ # @param [String] *types a variable amount of types to filter by
22
+ #
23
+ # @return [Array] array of types to filter by
24
+ def self.filter_types(*types)
25
+ types_to_filter = []
26
+ types.each do |type|
27
+ type == 'ordnance' ? types_to_filter << 'http://data.ordnancesurvey.co.uk/ontology/admingeo/EuropeanRegion' : types_to_filter << Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path(type)
28
+ end
29
+ types_to_filter
30
+ end
31
+
32
+ # Takes a request, sort type, type to sort and letters to sort by.
33
+ # Calls the #filter method to define type and letters
34
+ # Sorts type by sort type
35
+ # Maps letters using #value
36
+ # Returns type and letters
37
+ # @param [Parliament::Request] request a Parliament::Request object
38
+ # @param [Symbol] sort_type how to sort type
39
+ # @param [String] type the type to filter
40
+ # @param [Grom::Node] letters Grom::Node to filter type by letters
41
+ #
42
+ # @return [Parliament::Response::NTripleResponse] Ntriple response filtered by letters
43
+ def self.filter_sort(request, sort_type, type, letters)
44
+ type, letters = self.filter(request, type, letters)
45
+ type = type.sort_by(sort_type)
46
+ letters = letters.map(&:value)
47
+ return type, letters
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,5 +1,5 @@
1
1
  module Parliament
2
2
  module Utils
3
- VERSION = '0.5.0'.freeze
3
+ VERSION = '0.6.0'.freeze
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'parliament-ruby', '~> 0.7'
24
+ spec.add_dependency 'parliament-ruby', '~> 0.10'
25
25
  spec.add_dependency 'parliament-grom-decorators', '~> 0.10'
26
26
  spec.add_dependency 'parliament-ntriple'
27
27
  spec.add_dependency 'i18n'
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'pugin'
33
33
  spec.add_dependency 'haml'
34
34
 
35
+ spec.add_development_dependency 'parliament-ruby', '~> 0.10'
35
36
  spec.add_development_dependency 'bundler', '~> 1.15'
36
37
  spec.add_development_dependency 'rake', '~> 10.0'
37
38
  spec.add_development_dependency 'rspec', '~> 3.0'
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.5.0
4
+ version: 0.6.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-11-08 00:00:00.000000000 Z
11
+ date: 2017-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parliament-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.7'
19
+ version: '0.10'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.7'
26
+ version: '0.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parliament-grom-decorators
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: parliament-ruby
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.10'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.10'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: bundler
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +290,7 @@ files:
276
290
  - lib/parliament/utils/config/initializers/wrap_parameters.rb
277
291
  - lib/parliament/utils/helpers.rb
278
292
  - lib/parliament/utils/helpers/application_helper.rb
293
+ - lib/parliament/utils/helpers/filter_helper.rb
279
294
  - lib/parliament/utils/helpers/flag_helper.rb
280
295
  - lib/parliament/utils/helpers/format_helper.rb
281
296
  - lib/parliament/utils/helpers/houses_helper.rb
@@ -314,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
329
  version: '0'
315
330
  requirements: []
316
331
  rubyforge_project:
317
- rubygems_version: 2.6.11
332
+ rubygems_version: 2.6.8
318
333
  signing_key:
319
334
  specification_version: 4
320
335
  summary: Parliament Utils gem.