search_object 1.2.4 → 1.2.5

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
  SHA256:
3
- metadata.gz: ccb9a1eb55684f9df87c9d2c1ca76e20d946fb0c73d5fb52520c9c0b03bd41ab
4
- data.tar.gz: b59ad0f1fd7e0bdbc2469a951ae7a6e36286690464897342cd954b3b4d6e9f54
3
+ metadata.gz: c01187c2852ea65c1c340bc37e62527c9d4133691ded6a9db4ac5dea78441b1d
4
+ data.tar.gz: 177bf4f66eccf02f9195a9aa2b8563f8d1de4465be812157f9eeec1ac90121a6
5
5
  SHA512:
6
- metadata.gz: ed7c3ca5011a75c1f43467b799af8914ff455f785060bb16733158ace7f24adb6f038aea6133c6de1c7fb04f6406c9bde8d1fddd88cc3b9628b9ba5f0347805c
7
- data.tar.gz: 830399e3d6763d727911b5ea1279e7542c0fbb9608fad690d03e490e4329bc03fb201d05b2684f4e4aa0c7ca201e132feebc6e3f376fe413dda2d43b73c91bf3
6
+ metadata.gz: 3cd78261ad83342fec752d1e54714afe7971841ae5afa90270bd90a8a1713cbb2aa06fdbad3489be78127195666015918f9f356ec1f4c9809b201f5631fc0795
7
+ data.tar.gz: 575474f4d79ff650bccb1cb9e9d33cb540d4b85dfc18a23487e1239e6a6833bf4da7dc52193829d2c116a51c9089736720eb6ac5db5868b814558fe15675fc34
data/.rubocop.yml CHANGED
@@ -7,7 +7,7 @@ AllCops:
7
7
  - search_object.gemspec
8
8
 
9
9
  # Disables "Line is too long"
10
- Metrics/LineLength:
10
+ Layout/LineLength:
11
11
  Enabled: false
12
12
 
13
13
  # Disables Module has too many lines
@@ -37,3 +37,18 @@ RSpec/ExampleLength:
37
37
  # Disables "Too many expectations."
38
38
  RSpec/MultipleExpectations:
39
39
  Enabled: false
40
+
41
+ Lint/RaiseException:
42
+ Enabled: true
43
+
44
+ Lint/StructNewOverride:
45
+ Enabled: true
46
+
47
+ Style/HashEachMethods:
48
+ Enabled: true
49
+
50
+ Style/HashTransformKeys:
51
+ Enabled: true
52
+
53
+ Style/HashTransformValues:
54
+ Enabled: true
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3
4
3
  - 2.4
5
4
  - 2.6
5
+ - 2.7
6
+ - 3.0
6
7
  script:
7
8
  - bundle exec rubocop
8
9
  - bundle exec rspec spec
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.2.5
4
+
5
+ * __[feature]__ Added `param?` method to `Search::Base` (@rstankov)
6
+
3
7
  ## Version 1.2.4
4
8
 
5
- * __[feature]__ Added `:with` and block support to enum @hschne
9
+ * __[feature]__ Added `:with` and block support to enum (@hschne)
6
10
 
7
11
  ## Version 1.2.3
8
12
 
@@ -8,7 +8,7 @@ require 'rspec/rails'
8
8
 
9
9
  # Requires supporting ruby files with custom matchers and macros, etc,
10
10
  # in spec/support/ and its subdirectories.
11
- Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
11
+ Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |f| require f }
12
12
 
13
13
  # Checks for pending migrations before tests are run.
14
14
  # If you are not using ActiveRecord, you can remove this line.
@@ -52,6 +52,16 @@ module SearchObject
52
52
  end
53
53
  end
54
54
 
55
+ def param?(*args)
56
+ if args.size == 1
57
+ params.key?(args[0].to_s)
58
+ elsif args.size == 2
59
+ params[args[0].to_s] == args[1]
60
+ else
61
+ raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 1 or 2)"
62
+ end
63
+ end
64
+
55
65
  private
56
66
 
57
67
  def fetch_results
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SearchObject
4
- VERSION = '1.2.4'
4
+ VERSION = '1.2.5'
5
5
  end
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'will_paginate'
30
30
  spec.add_development_dependency 'kaminari'
31
31
  spec.add_development_dependency 'kaminari-activerecord'
32
- spec.add_development_dependency 'rubocop', '0.75.1'
33
- spec.add_development_dependency 'rubocop-rspec', '1.36.0'
32
+ spec.add_development_dependency 'rubocop', '0.81.0'
33
+ spec.add_development_dependency 'rubocop-rspec', '1.38.1'
34
34
  end
@@ -329,5 +329,44 @@ module SearchObject
329
329
  expect(search.params).to eq 'value' => 1
330
330
  end
331
331
  end
332
+
333
+ describe '#param?' do
334
+ context 'one argument' do
335
+ it 'returns true when params is set' do
336
+ search = new_search([], value: 2) do
337
+ option :value
338
+ end
339
+
340
+ expect(search.param?(:value)).to eq true
341
+ end
342
+
343
+ it 'returns false when params isnt set' do
344
+ search = new_search do
345
+ option :value
346
+ end
347
+
348
+ expect(search.param?(:value)).to eq false
349
+ end
350
+ end
351
+
352
+ context 'two arguments' do
353
+ it 'returns true when param matches value' do
354
+ search = new_search([], value: 2) do
355
+ option :value
356
+ end
357
+
358
+ expect(search.param?(:value, 2)).to eq true
359
+ end
360
+
361
+ it 'returns false when param matches value' do
362
+ search = new_search([], value: 2) do
363
+ option :value
364
+ end
365
+
366
+ expect(search.param?(:value, 3)).to eq false
367
+ expect(search.param?(:other, 3)).to eq false
368
+ end
369
+ end
370
+ end
332
371
  end
333
372
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radoslav Stankov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-15 00:00:00.000000000 Z
11
+ date: 2021-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -170,28 +170,28 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 0.75.1
173
+ version: 0.81.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 0.75.1
180
+ version: 0.81.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rubocop-rspec
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - '='
186
186
  - !ruby/object:Gem::Version
187
- version: 1.36.0
187
+ version: 1.38.1
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - '='
193
193
  - !ruby/object:Gem::Version
194
- version: 1.36.0
194
+ version: 1.38.1
195
195
  description: Search object DSL
196
196
  email:
197
197
  - rstankov@gmail.com
@@ -278,7 +278,7 @@ homepage: https://github.com/RStankov/SearchObject
278
278
  licenses:
279
279
  - MIT
280
280
  metadata: {}
281
- post_install_message:
281
+ post_install_message:
282
282
  rdoc_options: []
283
283
  require_paths:
284
284
  - lib
@@ -293,8 +293,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  - !ruby/object:Gem::Version
294
294
  version: '0'
295
295
  requirements: []
296
- rubygems_version: 3.0.3
297
- signing_key:
296
+ rubygems_version: 3.1.4
297
+ signing_key:
298
298
  specification_version: 4
299
299
  summary: Provides DSL for creating search objects
300
300
  test_files: