pursuit 0.4.2 → 0.4.3
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/.rubocop.yml +21 -6
- data/.ruby-version +1 -1
- data/.travis.yml +2 -1
- data/Gemfile.lock +95 -70
- data/lib/pursuit/constants.rb +1 -1
- data/lib/pursuit/search.rb +5 -3
- data/lib/pursuit/search_options.rb +1 -1
- data/pursuit.gemspec +16 -10
- data/spec/internal/app/models/product.rb +1 -3
- data/spec/{pursuit → lib/pursuit}/dsl_spec.rb +0 -0
- data/spec/{pursuit → lib/pursuit}/search_options_spec.rb +6 -8
- data/spec/{pursuit → lib/pursuit}/search_spec.rb +2 -4
- data/spec/{pursuit → lib/pursuit}/search_term_parser_spec.rb +9 -7
- data/spec/lib/pursuit_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -2
- data/travis/gemfiles/7.0.gemfile +8 -0
- metadata +79 -33
- data/spec/pursuit/constants_spec.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 293a43dc6ac02a82e39312daaa94e7d222264493d8d0df1e48d1c1a767711a7a
|
|
4
|
+
data.tar.gz: e47009b06f1df8e7d81e60d46f08ed67eadf304a273379ce89bee262a416e398
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 215ad485b981a56628931332434a340ba353397fb70fa40067ee39cccf38405b28ecec2a114e87aca7e1de3160fd05aa6bc1d3af7724897d613ae469d6c05bf2
|
|
7
|
+
data.tar.gz: dbd090187418d64ba7c91ce1ed836197fea536ee5896b3fe430ff7e70b740e4ef6117512d98e368ce244ffae4ffd501705bf9b3408892f8335fc4e14490a2a5b
|
data/.rubocop.yml
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-rake
|
|
3
|
+
- rubocop-rspec
|
|
4
|
+
|
|
1
5
|
AllCops:
|
|
2
6
|
Exclude:
|
|
3
7
|
- 'bin/**/*'
|
|
8
|
+
NewCops: enable
|
|
9
|
+
TargetRubyVersion: 2.6.0
|
|
10
|
+
|
|
11
|
+
Layout/LineLength:
|
|
12
|
+
Max: 120
|
|
4
13
|
|
|
5
14
|
Metrics/AbcSize:
|
|
6
15
|
Max: 30
|
|
7
16
|
|
|
8
|
-
Metrics/LineLength:
|
|
9
|
-
Max: 120
|
|
10
|
-
|
|
11
17
|
Metrics/BlockLength:
|
|
12
|
-
|
|
18
|
+
Max: 50
|
|
13
19
|
|
|
14
20
|
Metrics/ClassLength:
|
|
15
|
-
|
|
21
|
+
Max: 500
|
|
16
22
|
|
|
17
23
|
Metrics/MethodLength:
|
|
18
|
-
|
|
24
|
+
Max: 50
|
|
25
|
+
|
|
26
|
+
RSpec/ExampleLength:
|
|
27
|
+
Max: 20
|
|
28
|
+
|
|
29
|
+
RSpec/MultipleMemoizedHelpers:
|
|
30
|
+
Max: 20
|
|
31
|
+
|
|
32
|
+
RSpec/NestedGroups:
|
|
33
|
+
Max: 5
|
|
19
34
|
|
|
20
35
|
Style/Documentation:
|
|
21
36
|
Enabled: false
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.2.0
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pursuit (0.4.
|
|
4
|
+
pursuit (0.4.3)
|
|
5
5
|
activerecord (>= 5.2.0, < 7.1.0)
|
|
6
6
|
activesupport (>= 5.2.0, < 7.1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actionpack (7.0.1)
|
|
12
|
-
actionview (= 7.0.1)
|
|
13
|
-
activesupport (= 7.0.1)
|
|
11
|
+
actionpack (7.0.4.1)
|
|
12
|
+
actionview (= 7.0.4.1)
|
|
13
|
+
activesupport (= 7.0.4.1)
|
|
14
14
|
rack (~> 2.0, >= 2.2.0)
|
|
15
15
|
rack-test (>= 0.6.3)
|
|
16
16
|
rails-dom-testing (~> 2.0)
|
|
17
17
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
18
|
-
actionview (7.0.1)
|
|
19
|
-
activesupport (= 7.0.1)
|
|
18
|
+
actionview (7.0.4.1)
|
|
19
|
+
activesupport (= 7.0.4.1)
|
|
20
20
|
builder (~> 3.1)
|
|
21
21
|
erubi (~> 1.4)
|
|
22
22
|
rails-dom-testing (~> 2.0)
|
|
23
23
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
24
|
-
activemodel (7.0.1)
|
|
25
|
-
activesupport (= 7.0.1)
|
|
26
|
-
activerecord (7.0.1)
|
|
27
|
-
activemodel (= 7.0.1)
|
|
28
|
-
activesupport (= 7.0.1)
|
|
29
|
-
activesupport (7.0.1)
|
|
24
|
+
activemodel (7.0.4.1)
|
|
25
|
+
activesupport (= 7.0.4.1)
|
|
26
|
+
activerecord (7.0.4.1)
|
|
27
|
+
activemodel (= 7.0.4.1)
|
|
28
|
+
activesupport (= 7.0.4.1)
|
|
29
|
+
activesupport (7.0.4.1)
|
|
30
30
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
31
31
|
i18n (>= 1.6, < 2)
|
|
32
32
|
minitest (>= 5.1)
|
|
@@ -34,14 +34,14 @@ GEM
|
|
|
34
34
|
ast (2.4.2)
|
|
35
35
|
builder (3.2.4)
|
|
36
36
|
coderay (1.1.3)
|
|
37
|
-
combustion (1.3.
|
|
37
|
+
combustion (1.3.7)
|
|
38
38
|
activesupport (>= 3.0.0)
|
|
39
39
|
railties (>= 3.0.0)
|
|
40
40
|
thor (>= 0.14.6)
|
|
41
|
-
concurrent-ruby (1.1.
|
|
41
|
+
concurrent-ruby (1.1.10)
|
|
42
42
|
crass (1.0.6)
|
|
43
43
|
diff-lcs (1.5.0)
|
|
44
|
-
erubi (1.
|
|
44
|
+
erubi (1.12.0)
|
|
45
45
|
ffi (1.15.5)
|
|
46
46
|
formatador (1.1.0)
|
|
47
47
|
guard (2.18.0)
|
|
@@ -58,110 +58,135 @@ GEM
|
|
|
58
58
|
guard (~> 2.1)
|
|
59
59
|
guard-compat (~> 1.1)
|
|
60
60
|
rspec (>= 2.99.0, < 4.0)
|
|
61
|
-
i18n (1.
|
|
61
|
+
i18n (1.12.0)
|
|
62
62
|
concurrent-ruby (~> 1.0)
|
|
63
|
-
|
|
63
|
+
json (2.6.3)
|
|
64
|
+
listen (3.8.0)
|
|
64
65
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
65
66
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
66
|
-
loofah (2.
|
|
67
|
+
loofah (2.19.1)
|
|
67
68
|
crass (~> 1.0.2)
|
|
68
69
|
nokogiri (>= 1.5.9)
|
|
69
70
|
lumberjack (1.2.8)
|
|
70
71
|
method_source (1.0.0)
|
|
71
|
-
minitest (5.
|
|
72
|
+
minitest (5.17.0)
|
|
72
73
|
nenv (0.3.0)
|
|
73
|
-
nokogiri (1.
|
|
74
|
+
nokogiri (1.14.0-aarch64-linux)
|
|
75
|
+
racc (~> 1.4)
|
|
76
|
+
nokogiri (1.14.0-arm64-darwin)
|
|
77
|
+
racc (~> 1.4)
|
|
78
|
+
nokogiri (1.14.0-x86_64-darwin)
|
|
79
|
+
racc (~> 1.4)
|
|
80
|
+
nokogiri (1.14.0-x86_64-linux)
|
|
74
81
|
racc (~> 1.4)
|
|
75
82
|
notiffany (0.1.3)
|
|
76
83
|
nenv (~> 0.1)
|
|
77
84
|
shellany (~> 0.0)
|
|
78
|
-
parallel (1.
|
|
79
|
-
parser (3.
|
|
85
|
+
parallel (1.22.1)
|
|
86
|
+
parser (3.2.0.0)
|
|
80
87
|
ast (~> 2.4.1)
|
|
81
|
-
pry (0.14.
|
|
88
|
+
pry (0.14.2)
|
|
82
89
|
coderay (~> 1.1)
|
|
83
90
|
method_source (~> 1.0)
|
|
84
|
-
racc (1.6.
|
|
85
|
-
rack (2.2.
|
|
86
|
-
rack-test (
|
|
87
|
-
rack (>= 1.
|
|
91
|
+
racc (1.6.2)
|
|
92
|
+
rack (2.2.6.2)
|
|
93
|
+
rack-test (2.0.2)
|
|
94
|
+
rack (>= 1.3)
|
|
88
95
|
rails-dom-testing (2.0.3)
|
|
89
96
|
activesupport (>= 4.2.0)
|
|
90
97
|
nokogiri (>= 1.6)
|
|
91
|
-
rails-html-sanitizer (1.
|
|
92
|
-
loofah (~> 2.
|
|
93
|
-
railties (7.0.1)
|
|
94
|
-
actionpack (= 7.0.1)
|
|
95
|
-
activesupport (= 7.0.1)
|
|
98
|
+
rails-html-sanitizer (1.5.0)
|
|
99
|
+
loofah (~> 2.19, >= 2.19.1)
|
|
100
|
+
railties (7.0.4.1)
|
|
101
|
+
actionpack (= 7.0.4.1)
|
|
102
|
+
activesupport (= 7.0.4.1)
|
|
96
103
|
method_source
|
|
97
104
|
rake (>= 12.2)
|
|
98
105
|
thor (~> 1.0)
|
|
99
106
|
zeitwerk (~> 2.5)
|
|
100
107
|
rainbow (3.1.1)
|
|
101
108
|
rake (13.0.6)
|
|
102
|
-
rb-fsevent (0.11.
|
|
109
|
+
rb-fsevent (0.11.2)
|
|
103
110
|
rb-inotify (0.10.1)
|
|
104
111
|
ffi (~> 1.0)
|
|
105
|
-
regexp_parser (2.2
|
|
112
|
+
regexp_parser (2.6.2)
|
|
106
113
|
rexml (3.2.5)
|
|
107
|
-
rspec (3.
|
|
108
|
-
rspec-core (~> 3.
|
|
109
|
-
rspec-expectations (~> 3.
|
|
110
|
-
rspec-mocks (~> 3.
|
|
111
|
-
rspec-core (3.
|
|
112
|
-
rspec-support (~> 3.
|
|
113
|
-
rspec-expectations (3.
|
|
114
|
+
rspec (3.12.0)
|
|
115
|
+
rspec-core (~> 3.12.0)
|
|
116
|
+
rspec-expectations (~> 3.12.0)
|
|
117
|
+
rspec-mocks (~> 3.12.0)
|
|
118
|
+
rspec-core (3.12.0)
|
|
119
|
+
rspec-support (~> 3.12.0)
|
|
120
|
+
rspec-expectations (3.12.2)
|
|
114
121
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
115
|
-
rspec-support (~> 3.
|
|
116
|
-
rspec-mocks (3.
|
|
122
|
+
rspec-support (~> 3.12.0)
|
|
123
|
+
rspec-mocks (3.12.3)
|
|
117
124
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
118
|
-
rspec-support (~> 3.
|
|
119
|
-
rspec-rails (
|
|
120
|
-
actionpack (>=
|
|
121
|
-
activesupport (>=
|
|
122
|
-
railties (>=
|
|
123
|
-
rspec-core (~> 3.
|
|
124
|
-
rspec-expectations (~> 3.
|
|
125
|
-
rspec-mocks (~> 3.
|
|
126
|
-
rspec-support (~> 3.
|
|
127
|
-
rspec-support (3.
|
|
128
|
-
rubocop (1.
|
|
125
|
+
rspec-support (~> 3.12.0)
|
|
126
|
+
rspec-rails (6.0.1)
|
|
127
|
+
actionpack (>= 6.1)
|
|
128
|
+
activesupport (>= 6.1)
|
|
129
|
+
railties (>= 6.1)
|
|
130
|
+
rspec-core (~> 3.11)
|
|
131
|
+
rspec-expectations (~> 3.11)
|
|
132
|
+
rspec-mocks (~> 3.11)
|
|
133
|
+
rspec-support (~> 3.11)
|
|
134
|
+
rspec-support (3.12.0)
|
|
135
|
+
rubocop (1.44.0)
|
|
136
|
+
json (~> 2.3)
|
|
129
137
|
parallel (~> 1.10)
|
|
130
|
-
parser (>= 3.
|
|
138
|
+
parser (>= 3.2.0.0)
|
|
131
139
|
rainbow (>= 2.2.2, < 4.0)
|
|
132
140
|
regexp_parser (>= 1.8, < 3.0)
|
|
133
|
-
rexml
|
|
134
|
-
rubocop-ast (>= 1.
|
|
141
|
+
rexml (>= 3.2.5, < 4.0)
|
|
142
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
|
135
143
|
ruby-progressbar (~> 1.7)
|
|
136
|
-
unicode-display_width (>=
|
|
137
|
-
rubocop-ast (1.
|
|
138
|
-
parser (>= 3.
|
|
144
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
145
|
+
rubocop-ast (1.24.1)
|
|
146
|
+
parser (>= 3.1.1.0)
|
|
147
|
+
rubocop-capybara (2.17.0)
|
|
148
|
+
rubocop (~> 1.41)
|
|
149
|
+
rubocop-rake (0.6.0)
|
|
150
|
+
rubocop (~> 1.0)
|
|
151
|
+
rubocop-rspec (2.18.0)
|
|
152
|
+
rubocop (~> 1.33)
|
|
153
|
+
rubocop-capybara
|
|
139
154
|
ruby-progressbar (1.11.0)
|
|
140
155
|
shellany (0.0.1)
|
|
141
|
-
sqlite3 (1.
|
|
156
|
+
sqlite3 (1.6.0-aarch64-linux)
|
|
157
|
+
sqlite3 (1.6.0-arm64-darwin)
|
|
158
|
+
sqlite3 (1.6.0-x86_64-darwin)
|
|
159
|
+
sqlite3 (1.6.0-x86_64-linux)
|
|
142
160
|
thor (1.2.1)
|
|
143
|
-
tzinfo (2.0.
|
|
161
|
+
tzinfo (2.0.5)
|
|
144
162
|
concurrent-ruby (~> 1.0)
|
|
145
|
-
unicode-display_width (2.
|
|
163
|
+
unicode-display_width (2.4.2)
|
|
146
164
|
webrick (1.7.0)
|
|
147
|
-
yard (0.9.
|
|
165
|
+
yard (0.9.28)
|
|
148
166
|
webrick (~> 1.7.0)
|
|
149
|
-
zeitwerk (2.
|
|
167
|
+
zeitwerk (2.6.6)
|
|
150
168
|
|
|
151
169
|
PLATFORMS
|
|
170
|
+
aarch64-linux
|
|
171
|
+
arm64-darwin-22
|
|
152
172
|
x86_64-darwin-21
|
|
173
|
+
x86_64-linux
|
|
153
174
|
|
|
154
175
|
DEPENDENCIES
|
|
155
176
|
bundler (~> 2.0)
|
|
156
177
|
combustion (~> 1.3)
|
|
178
|
+
guard (~> 2.18)
|
|
157
179
|
guard-rspec (~> 4.7)
|
|
180
|
+
pry (~> 0.14)
|
|
158
181
|
pursuit!
|
|
159
182
|
rake (~> 13.0)
|
|
160
|
-
rspec (~> 3.
|
|
161
|
-
rspec-rails (~>
|
|
162
|
-
rubocop (~> 1.
|
|
163
|
-
|
|
183
|
+
rspec (~> 3.12)
|
|
184
|
+
rspec-rails (~> 6.0)
|
|
185
|
+
rubocop (~> 1.44)
|
|
186
|
+
rubocop-rake (~> 0.6)
|
|
187
|
+
rubocop-rspec (~> 2.18)
|
|
188
|
+
sqlite3 (~> 1.6)
|
|
164
189
|
yard (~> 0.9)
|
|
165
190
|
|
|
166
191
|
BUNDLED WITH
|
|
167
|
-
2.
|
|
192
|
+
2.4.5
|
data/lib/pursuit/constants.rb
CHANGED
data/lib/pursuit/search.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Pursuit
|
|
|
41
41
|
return nil if value.blank?
|
|
42
42
|
|
|
43
43
|
sanitized_value = "%#{ActiveRecord::Base.sanitize_sql_like(value)}%"
|
|
44
|
-
options.unkeyed_attributes.reduce(nil) do |chain, (
|
|
44
|
+
options.unkeyed_attributes.reduce(nil) do |chain, (_attribute_name, node_builder)|
|
|
45
45
|
node = node_builder.call.matches(sanitized_value)
|
|
46
46
|
chain ? chain.or(node) : node
|
|
47
47
|
end
|
|
@@ -65,7 +65,7 @@ module Pursuit
|
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
def build_arel_for_node(node, operator, value)
|
|
68
|
+
def build_arel_for_node(node, operator, value) # rubocop:disable Metrics/CyclomaticComplexity
|
|
69
69
|
sanitized_value = ActiveRecord::Base.sanitize_sql_like(value)
|
|
70
70
|
sanitized_value = sanitized_value.to_i if sanitized_value =~ /^[0-9]+$/
|
|
71
71
|
|
|
@@ -120,6 +120,7 @@ module Pursuit
|
|
|
120
120
|
)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
+
# rubocop:disable Metrics/AbcSize
|
|
123
124
|
def build_arel_for_has_reflection_join(reflection)
|
|
124
125
|
reflection_table = reflection.klass.arel_table
|
|
125
126
|
reflection_through = reflection.through_reflection
|
|
@@ -143,8 +144,9 @@ module Pursuit
|
|
|
143
144
|
)
|
|
144
145
|
end
|
|
145
146
|
end
|
|
147
|
+
# rubocop:enable Metrics/AbcSize
|
|
146
148
|
|
|
147
|
-
def build_arel_for_relation_count(nodes, operator, value)
|
|
149
|
+
def build_arel_for_relation_count(nodes, operator, value) # rubocop:disable Metrics/CyclomaticComplexity
|
|
148
150
|
node_builder = proc do |klass|
|
|
149
151
|
count = ActiveRecord::Base.sanitize_sql_like(value).to_i
|
|
150
152
|
klass.new(nodes.project(Arel.star.count), count)
|
data/pursuit.gemspec
CHANGED
|
@@ -16,21 +16,27 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
19
|
spec.require_paths = ['lib']
|
|
21
20
|
|
|
21
|
+
spec.required_ruby_version = '>= 2.6.0'
|
|
22
|
+
|
|
23
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
22
24
|
spec.metadata['yard.run'] = 'yri'
|
|
23
25
|
|
|
24
26
|
spec.add_runtime_dependency 'activerecord', '>= 5.2.0', '< 7.1.0'
|
|
25
27
|
spec.add_runtime_dependency 'activesupport', '>= 5.2.0', '< 7.1.0'
|
|
26
28
|
|
|
27
|
-
spec.add_development_dependency 'bundler',
|
|
28
|
-
spec.add_development_dependency 'combustion',
|
|
29
|
-
spec.add_development_dependency 'guard
|
|
30
|
-
spec.add_development_dependency '
|
|
31
|
-
spec.add_development_dependency '
|
|
32
|
-
spec.add_development_dependency '
|
|
33
|
-
spec.add_development_dependency '
|
|
34
|
-
spec.add_development_dependency '
|
|
35
|
-
spec.add_development_dependency '
|
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
30
|
+
spec.add_development_dependency 'combustion', '~> 1.3'
|
|
31
|
+
spec.add_development_dependency 'guard', '~> 2.18'
|
|
32
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
|
33
|
+
spec.add_development_dependency 'pry', '~> 0.14'
|
|
34
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.12'
|
|
36
|
+
spec.add_development_dependency 'rspec-rails', '~> 6.0'
|
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 1.44'
|
|
38
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
|
|
39
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.18'
|
|
40
|
+
spec.add_development_dependency 'sqlite3', '~> 1.6'
|
|
41
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
|
36
42
|
end
|
|
@@ -14,9 +14,7 @@ class Product < ActiveRecord::Base
|
|
|
14
14
|
o.attribute :description
|
|
15
15
|
o.attribute :rating, unkeyed: false
|
|
16
16
|
o.attribute :title_length, unkeyed: false do
|
|
17
|
-
Arel::Nodes::NamedFunction.new('LENGTH', [
|
|
18
|
-
arel_table[:title]
|
|
19
|
-
])
|
|
17
|
+
Arel::Nodes::NamedFunction.new('LENGTH', [arel_table[:title]])
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
o.attribute :category, :category_id
|
|
File without changes
|
|
@@ -5,9 +5,7 @@ RSpec.describe Pursuit::SearchOptions do
|
|
|
5
5
|
|
|
6
6
|
let(:title_length_node_builder) do
|
|
7
7
|
proc do
|
|
8
|
-
Arel::Nodes::NamedFunction.new('LENGTH', [
|
|
9
|
-
Product.arel_table[:title]
|
|
10
|
-
])
|
|
8
|
+
Arel::Nodes::NamedFunction.new('LENGTH', [Product.arel_table[:title]])
|
|
11
9
|
end
|
|
12
10
|
end
|
|
13
11
|
|
|
@@ -88,7 +86,7 @@ RSpec.describe Pursuit::SearchOptions do
|
|
|
88
86
|
describe '#attribute' do
|
|
89
87
|
subject(:attribute) { search_options.attribute(:description) }
|
|
90
88
|
|
|
91
|
-
it { is_expected.to
|
|
89
|
+
it { is_expected.to be_nil }
|
|
92
90
|
|
|
93
91
|
it 'is expected to add the attribute to #attributes' do
|
|
94
92
|
expect { attribute }.to change(search_options.attributes, :keys).from([]).to(%i[description])
|
|
@@ -96,12 +94,12 @@ RSpec.describe Pursuit::SearchOptions do
|
|
|
96
94
|
|
|
97
95
|
it 'is expected to allow keyed searching by default' do
|
|
98
96
|
attribute
|
|
99
|
-
expect(search_options.attributes[:description].keyed).to
|
|
97
|
+
expect(search_options.attributes[:description].keyed).to be(true)
|
|
100
98
|
end
|
|
101
99
|
|
|
102
100
|
it 'is expected to allow unkeyed searching by default' do
|
|
103
101
|
attribute
|
|
104
|
-
expect(search_options.attributes[:description].unkeyed).to
|
|
102
|
+
expect(search_options.attributes[:description].unkeyed).to be(true)
|
|
105
103
|
end
|
|
106
104
|
|
|
107
105
|
it 'is expected to query the #term_name attribute' do
|
|
@@ -123,7 +121,7 @@ RSpec.describe Pursuit::SearchOptions do
|
|
|
123
121
|
|
|
124
122
|
it 'is expected to disallow keyed searching' do
|
|
125
123
|
attribute
|
|
126
|
-
expect(search_options.attributes[:description].keyed).to
|
|
124
|
+
expect(search_options.attributes[:description].keyed).to be(false)
|
|
127
125
|
end
|
|
128
126
|
end
|
|
129
127
|
|
|
@@ -132,7 +130,7 @@ RSpec.describe Pursuit::SearchOptions do
|
|
|
132
130
|
|
|
133
131
|
it 'is expected to disallow unkeyed searching' do
|
|
134
132
|
attribute
|
|
135
|
-
expect(search_options.attributes[:description].unkeyed).to
|
|
133
|
+
expect(search_options.attributes[:description].unkeyed).to be(false)
|
|
136
134
|
end
|
|
137
135
|
end
|
|
138
136
|
|
|
@@ -12,9 +12,7 @@ RSpec.describe Pursuit::Search do
|
|
|
12
12
|
o.attribute :description
|
|
13
13
|
o.attribute :rating, unkeyed: false
|
|
14
14
|
o.attribute :title_length, unkeyed: false do
|
|
15
|
-
Arel::Nodes::NamedFunction.new('LENGTH', [
|
|
16
|
-
Product.arel_table[:title]
|
|
17
|
-
])
|
|
15
|
+
Arel::Nodes::NamedFunction.new('LENGTH', [Product.arel_table[:title]])
|
|
18
16
|
end
|
|
19
17
|
|
|
20
18
|
o.attribute :cat, :category_id
|
|
@@ -130,7 +128,7 @@ RSpec.describe Pursuit::Search do
|
|
|
130
128
|
end
|
|
131
129
|
end
|
|
132
130
|
|
|
133
|
-
context 'when passed a `not equal to` keyed attribute query' do
|
|
131
|
+
context 'when passed a numeric `not equal to` keyed attribute query' do
|
|
134
132
|
let(:query) { 'rating!=2' }
|
|
135
133
|
|
|
136
134
|
let(:product_a) { Product.create!(title: 'Plain Shirt', rating: 2) }
|
|
@@ -20,13 +20,15 @@ RSpec.describe Pursuit::SearchTermParser do
|
|
|
20
20
|
subject(:keyed_terms) { parser.keyed_terms }
|
|
21
21
|
|
|
22
22
|
it 'is expected to eq the correct keyed terms' do
|
|
23
|
-
expect(keyed_terms).to eq(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
expect(keyed_terms).to eq(
|
|
24
|
+
[
|
|
25
|
+
Pursuit::SearchTermParser::KeyedTerm.new('title', '!=', 'Socks'),
|
|
26
|
+
Pursuit::SearchTermParser::KeyedTerm.new('description', '*=', 'green'),
|
|
27
|
+
Pursuit::SearchTermParser::KeyedTerm.new('stock_status', '==', 'in_stock'),
|
|
28
|
+
Pursuit::SearchTermParser::KeyedTerm.new('rating', '>=', '2'),
|
|
29
|
+
Pursuit::SearchTermParser::KeyedTerm.new('rating', '<', '5')
|
|
30
|
+
]
|
|
31
|
+
)
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -65,7 +65,7 @@ RSpec.configure do |config|
|
|
|
65
65
|
config.disable_monkey_patching!
|
|
66
66
|
|
|
67
67
|
# Retrieve the default formatter from the current environment.
|
|
68
|
-
default_formatter = ENV
|
|
68
|
+
default_formatter = ENV.fetch('RSPEC_DEFAULT_FORMATTER', nil)
|
|
69
69
|
|
|
70
70
|
if default_formatter.is_a?(String) && !default_formatter.empty?
|
|
71
71
|
config.default_formatter = default_formatter
|
|
@@ -92,4 +92,4 @@ RSpec.configure do |config|
|
|
|
92
92
|
Kernel.srand config.seed
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |path| require(path) }
|
|
95
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each { |path| require(path) }
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pursuit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nialto Services
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -78,6 +78,20 @@ dependencies:
|
|
|
78
78
|
- - "~>"
|
|
79
79
|
- !ruby/object:Gem::Version
|
|
80
80
|
version: '1.3'
|
|
81
|
+
- !ruby/object:Gem::Dependency
|
|
82
|
+
name: guard
|
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - "~>"
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '2.18'
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - "~>"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '2.18'
|
|
81
95
|
- !ruby/object:Gem::Dependency
|
|
82
96
|
name: guard-rspec
|
|
83
97
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -92,6 +106,20 @@ dependencies:
|
|
|
92
106
|
- - "~>"
|
|
93
107
|
- !ruby/object:Gem::Version
|
|
94
108
|
version: '4.7'
|
|
109
|
+
- !ruby/object:Gem::Dependency
|
|
110
|
+
name: pry
|
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - "~>"
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0.14'
|
|
116
|
+
type: :development
|
|
117
|
+
prerelease: false
|
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - "~>"
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0.14'
|
|
95
123
|
- !ruby/object:Gem::Dependency
|
|
96
124
|
name: rake
|
|
97
125
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -112,70 +140,98 @@ dependencies:
|
|
|
112
140
|
requirements:
|
|
113
141
|
- - "~>"
|
|
114
142
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: '3.
|
|
143
|
+
version: '3.12'
|
|
116
144
|
type: :development
|
|
117
145
|
prerelease: false
|
|
118
146
|
version_requirements: !ruby/object:Gem::Requirement
|
|
119
147
|
requirements:
|
|
120
148
|
- - "~>"
|
|
121
149
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: '3.
|
|
150
|
+
version: '3.12'
|
|
123
151
|
- !ruby/object:Gem::Dependency
|
|
124
152
|
name: rspec-rails
|
|
125
153
|
requirement: !ruby/object:Gem::Requirement
|
|
126
154
|
requirements:
|
|
127
155
|
- - "~>"
|
|
128
156
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: '
|
|
157
|
+
version: '6.0'
|
|
130
158
|
type: :development
|
|
131
159
|
prerelease: false
|
|
132
160
|
version_requirements: !ruby/object:Gem::Requirement
|
|
133
161
|
requirements:
|
|
134
162
|
- - "~>"
|
|
135
163
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: '
|
|
164
|
+
version: '6.0'
|
|
137
165
|
- !ruby/object:Gem::Dependency
|
|
138
166
|
name: rubocop
|
|
139
167
|
requirement: !ruby/object:Gem::Requirement
|
|
140
168
|
requirements:
|
|
141
169
|
- - "~>"
|
|
142
170
|
- !ruby/object:Gem::Version
|
|
143
|
-
version: '1.
|
|
171
|
+
version: '1.44'
|
|
144
172
|
type: :development
|
|
145
173
|
prerelease: false
|
|
146
174
|
version_requirements: !ruby/object:Gem::Requirement
|
|
147
175
|
requirements:
|
|
148
176
|
- - "~>"
|
|
149
177
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: '1.
|
|
178
|
+
version: '1.44'
|
|
151
179
|
- !ruby/object:Gem::Dependency
|
|
152
|
-
name:
|
|
180
|
+
name: rubocop-rake
|
|
153
181
|
requirement: !ruby/object:Gem::Requirement
|
|
154
182
|
requirements:
|
|
155
183
|
- - "~>"
|
|
156
184
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: '0.
|
|
185
|
+
version: '0.6'
|
|
158
186
|
type: :development
|
|
159
187
|
prerelease: false
|
|
160
188
|
version_requirements: !ruby/object:Gem::Requirement
|
|
161
189
|
requirements:
|
|
162
190
|
- - "~>"
|
|
163
191
|
- !ruby/object:Gem::Version
|
|
164
|
-
version: '0.
|
|
192
|
+
version: '0.6'
|
|
193
|
+
- !ruby/object:Gem::Dependency
|
|
194
|
+
name: rubocop-rspec
|
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
|
196
|
+
requirements:
|
|
197
|
+
- - "~>"
|
|
198
|
+
- !ruby/object:Gem::Version
|
|
199
|
+
version: '2.18'
|
|
200
|
+
type: :development
|
|
201
|
+
prerelease: false
|
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
203
|
+
requirements:
|
|
204
|
+
- - "~>"
|
|
205
|
+
- !ruby/object:Gem::Version
|
|
206
|
+
version: '2.18'
|
|
165
207
|
- !ruby/object:Gem::Dependency
|
|
166
208
|
name: sqlite3
|
|
167
209
|
requirement: !ruby/object:Gem::Requirement
|
|
168
210
|
requirements:
|
|
169
211
|
- - "~>"
|
|
170
212
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '1.
|
|
213
|
+
version: '1.6'
|
|
172
214
|
type: :development
|
|
173
215
|
prerelease: false
|
|
174
216
|
version_requirements: !ruby/object:Gem::Requirement
|
|
175
217
|
requirements:
|
|
176
218
|
- - "~>"
|
|
177
219
|
- !ruby/object:Gem::Version
|
|
178
|
-
version: '1.
|
|
220
|
+
version: '1.6'
|
|
221
|
+
- !ruby/object:Gem::Dependency
|
|
222
|
+
name: yard
|
|
223
|
+
requirement: !ruby/object:Gem::Requirement
|
|
224
|
+
requirements:
|
|
225
|
+
- - "~>"
|
|
226
|
+
- !ruby/object:Gem::Version
|
|
227
|
+
version: '0.9'
|
|
228
|
+
type: :development
|
|
229
|
+
prerelease: false
|
|
230
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
231
|
+
requirements:
|
|
232
|
+
- - "~>"
|
|
233
|
+
- !ruby/object:Gem::Version
|
|
234
|
+
version: '0.9'
|
|
179
235
|
description:
|
|
180
236
|
email:
|
|
181
237
|
- support@nialtoservices.co.uk
|
|
@@ -212,19 +268,21 @@ files:
|
|
|
212
268
|
- spec/internal/config/database.yml
|
|
213
269
|
- spec/internal/db/schema.rb
|
|
214
270
|
- spec/internal/log/.keep
|
|
215
|
-
- spec/pursuit/
|
|
216
|
-
- spec/pursuit/
|
|
217
|
-
- spec/pursuit/
|
|
218
|
-
- spec/pursuit/
|
|
219
|
-
- spec/
|
|
271
|
+
- spec/lib/pursuit/dsl_spec.rb
|
|
272
|
+
- spec/lib/pursuit/search_options_spec.rb
|
|
273
|
+
- spec/lib/pursuit/search_spec.rb
|
|
274
|
+
- spec/lib/pursuit/search_term_parser_spec.rb
|
|
275
|
+
- spec/lib/pursuit_spec.rb
|
|
220
276
|
- spec/spec_helper.rb
|
|
221
277
|
- travis/gemfiles/5.2.gemfile
|
|
222
278
|
- travis/gemfiles/6.0.gemfile
|
|
223
279
|
- travis/gemfiles/6.1.gemfile
|
|
280
|
+
- travis/gemfiles/7.0.gemfile
|
|
224
281
|
homepage: https://github.com/nialtoservices/pursuit
|
|
225
282
|
licenses:
|
|
226
283
|
- MIT
|
|
227
284
|
metadata:
|
|
285
|
+
rubygems_mfa_required: 'true'
|
|
228
286
|
yard.run: yri
|
|
229
287
|
post_install_message:
|
|
230
288
|
rdoc_options: []
|
|
@@ -234,27 +292,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
234
292
|
requirements:
|
|
235
293
|
- - ">="
|
|
236
294
|
- !ruby/object:Gem::Version
|
|
237
|
-
version:
|
|
295
|
+
version: 2.6.0
|
|
238
296
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
297
|
requirements:
|
|
240
298
|
- - ">="
|
|
241
299
|
- !ruby/object:Gem::Version
|
|
242
300
|
version: '0'
|
|
243
301
|
requirements: []
|
|
244
|
-
rubygems_version: 3.
|
|
302
|
+
rubygems_version: 3.4.1
|
|
245
303
|
signing_key:
|
|
246
304
|
specification_version: 4
|
|
247
305
|
summary: Advanced key-based searching for ActiveRecord objects.
|
|
248
|
-
test_files:
|
|
249
|
-
- spec/internal/app/models/product.rb
|
|
250
|
-
- spec/internal/app/models/product_category.rb
|
|
251
|
-
- spec/internal/app/models/product_variation.rb
|
|
252
|
-
- spec/internal/config/database.yml
|
|
253
|
-
- spec/internal/db/schema.rb
|
|
254
|
-
- spec/internal/log/.keep
|
|
255
|
-
- spec/pursuit/constants_spec.rb
|
|
256
|
-
- spec/pursuit/dsl_spec.rb
|
|
257
|
-
- spec/pursuit/search_options_spec.rb
|
|
258
|
-
- spec/pursuit/search_spec.rb
|
|
259
|
-
- spec/pursuit/search_term_parser_spec.rb
|
|
260
|
-
- spec/spec_helper.rb
|
|
306
|
+
test_files: []
|