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 +4 -4
- data/.travis.yml +2 -0
- data/lib/parliament/utils/helpers.rb +1 -0
- data/lib/parliament/utils/helpers/filter_helper.rb +52 -0
- data/lib/parliament/utils/version.rb +1 -1
- data/parliament-utils.gemspec +2 -1
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b1bc71c1a239694b68c057e362302dadfd7b18a
|
4
|
+
data.tar.gz: f27aa41311b6129bd759fc49dd9472fff871e6d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 819087efb47d3873b5e153c658f8ae1cdb8410caa76bb421f2cd735f2409147e9e3e3ec6ddfa60e765fb9194532e61a0f20e03d3e368d6e7e436dee3930114d2
|
7
|
+
data.tar.gz: 7ebc1412f95ec4c9922df5f6f81109787cfecf896de39cef44c336a6603794738b9442f09300734cb70e67b2108b851e67fa859e4f01e4efee6e5adcdfb18e06
|
data/.travis.yml
CHANGED
@@ -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
|
data/parliament-utils.gemspec
CHANGED
@@ -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.
|
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.
|
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
|
+
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.
|
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.
|
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.
|
332
|
+
rubygems_version: 2.6.8
|
318
333
|
signing_key:
|
319
334
|
specification_version: 4
|
320
335
|
summary: Parliament Utils gem.
|