query_string_interface 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/query_string_interface.rb +18 -2
- data/lib/query_string_interface/version.rb +1 -1
- metadata +44 -50
data/Gemfile.lock
CHANGED
@@ -6,11 +6,11 @@ module QueryStringInterface
|
|
6
6
|
ARRAY_CONDITIONAL_OPERATORS = [:all, :in, :nin]
|
7
7
|
CONDITIONAL_OPERATORS = ARRAY_CONDITIONAL_OPERATORS + NORMAL_CONDITIONAL_OPERATORS
|
8
8
|
SORTING_OPERATORS = [:asc, :desc]
|
9
|
+
FIELD_FILTERING_OPERATORS = [:only, :except]
|
9
10
|
OR_OPERATOR = :or
|
10
11
|
|
11
12
|
OPERATORS = CONDITIONAL_OPERATORS + SORTING_OPERATORS + [OR_OPERATOR]
|
12
13
|
|
13
|
-
|
14
14
|
ATTRIBUTE_REGEX = /^(.*)\.(#{(OPERATORS).join('|')})$/
|
15
15
|
OPERATOR_REGEX = /^.*\.(#{CONDITIONAL_OPERATORS.join('|')})$/
|
16
16
|
|
@@ -18,7 +18,7 @@ module QueryStringInterface
|
|
18
18
|
PAGINATION_PARAMTERS = [:per_page, :page]
|
19
19
|
FRAMEWORK_PARAMETERS = [:controller, :action, :format]
|
20
20
|
CONTROL_PARAMETERS = [:disable_default_filters]
|
21
|
-
RESERVED_PARAMETERS = FRAMEWORK_PARAMETERS + PAGINATION_PARAMTERS + [ORDER_BY_PARAMETER] + CONTROL_PARAMETERS
|
21
|
+
RESERVED_PARAMETERS = FRAMEWORK_PARAMETERS + PAGINATION_PARAMTERS + [ORDER_BY_PARAMETER] + CONTROL_PARAMETERS + FIELD_FILTERING_OPERATORS
|
22
22
|
|
23
23
|
def default_filtering_options
|
24
24
|
{}
|
@@ -56,9 +56,25 @@ module QueryStringInterface
|
|
56
56
|
QueryStringInterface::SortingFilters.new(options, default_sorting_options, sorting_attributes_to_replace).parse
|
57
57
|
end
|
58
58
|
|
59
|
+
def field_filtering_options(options={})
|
60
|
+
options = options.with_indifferent_access
|
61
|
+
|
62
|
+
if options[:only]
|
63
|
+
{ :only => parse_array(options[:only]) }.with_indifferent_access
|
64
|
+
elsif options[:except]
|
65
|
+
{ :except => parse_array(options[:except]) }.with_indifferent_access
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
59
69
|
def only_filtering(options={})
|
60
70
|
options.with_indifferent_access.except(*RESERVED_PARAMETERS)
|
61
71
|
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def parse_array(value)
|
76
|
+
QueryStringInterface::Parsers::ArrayParser.new.parse(value)
|
77
|
+
end
|
62
78
|
end
|
63
79
|
|
64
80
|
require "query_string_interface/version"
|
metadata
CHANGED
@@ -1,91 +1,85 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: query_string_interface
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.4.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Vicente Mundim
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2168557900 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 3.0.0
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rspec
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *2168557900
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &2168557380 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
34
32
|
version: 2.6.0
|
35
33
|
type: :development
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2168557380
|
36
|
+
description: This gem extracts params given as a hash to structured data, that can
|
37
|
+
be used when creating queries
|
38
|
+
email:
|
39
39
|
- vicente.mundim@gmail.com
|
40
40
|
executables: []
|
41
|
-
|
42
41
|
extensions: []
|
43
|
-
|
44
42
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
|
47
|
-
- lib/query_string_interface.rb
|
43
|
+
files:
|
44
|
+
- lib/query_string_interface/filter.rb
|
45
|
+
- lib/query_string_interface/filter_collection.rb
|
46
|
+
- lib/query_string_interface/helpers.rb
|
48
47
|
- lib/query_string_interface/parsers/array_parser.rb
|
48
|
+
- lib/query_string_interface/parsers/boolean_and_nil_parser.rb
|
49
49
|
- lib/query_string_interface/parsers/date_time_parser.rb
|
50
50
|
- lib/query_string_interface/parsers/number_parser.rb
|
51
|
-
- lib/query_string_interface/parsers/boolean_and_nil_parser.rb
|
52
51
|
- lib/query_string_interface/parsers/regex_parser.rb
|
53
|
-
- lib/query_string_interface/version.rb
|
54
|
-
- lib/query_string_interface/filter_collection.rb
|
55
|
-
- lib/query_string_interface/filter.rb
|
56
|
-
- lib/query_string_interface/helpers.rb
|
57
52
|
- lib/query_string_interface/parsers.rb
|
58
53
|
- lib/query_string_interface/sorting_filters.rb
|
54
|
+
- lib/query_string_interface/version.rb
|
55
|
+
- lib/query_string_interface.rb
|
59
56
|
- MIT_LICENSE
|
60
57
|
- README.md
|
61
58
|
- Gemfile
|
62
59
|
- Gemfile.lock
|
63
|
-
homepage:
|
60
|
+
homepage: ''
|
64
61
|
licenses: []
|
65
|
-
|
66
62
|
post_install_message:
|
67
63
|
rdoc_options: []
|
68
|
-
|
69
|
-
require_paths:
|
64
|
+
require_paths:
|
70
65
|
- lib
|
71
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
67
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version:
|
77
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
73
|
none: false
|
79
|
-
requirements:
|
80
|
-
- -
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version:
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
83
78
|
requirements: []
|
84
|
-
|
85
79
|
rubyforge_project: query_string_interface
|
86
80
|
rubygems_version: 1.8.15
|
87
81
|
signing_key:
|
88
82
|
specification_version: 3
|
89
|
-
summary: Extracts query string params to a structured data, suitable to use for model
|
83
|
+
summary: Extracts query string params to a structured data, suitable to use for model
|
84
|
+
queries
|
90
85
|
test_files: []
|
91
|
-
|