snfoil-searcher 0.0.1 → 1.0.0
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/README.md +7 -7
- data/lib/snfoil/searcher/boolean.rb +56 -0
- data/lib/snfoil/searcher/version.rb +1 -1
- data/lib/snfoil/searcher.rb +25 -29
- data/snfoil-searcher.gemspec +10 -8
- metadata +41 -17
- data/.github/workflows/main.yml +0 -46
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -40
- data/Rakefile +0 -12
- data/bin/console +0 -15
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e3c405f37474b23844f1b1f60018951f8faedea212908b7f8a214ae1a184ae
|
4
|
+
data.tar.gz: 7e9a29c23e23fc8d5880ef58533f5c88d4ace9b746ba3ceb1b892252d7f5ea7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74029a85a8525e217e5b7342d5b8e0c1b51ff6fa25f5db8bee77055e96c239d5578ac428925dc301cfcdf2e805bcb61cca109e2415d5686509b8b924f56fcf0e
|
7
|
+
data.tar.gz: 6e1654b95fa7ab9f4c7f329e1cab6fcaeb7ef0e8d8e86d73d42fd73731a209f3abceccef0bbe184fe9cb5f190522bc340961e1550b9bb4359eb3c0c680d609e5
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ gem 'snfoil-searcher'
|
|
16
16
|
|
17
17
|
### Quickstart
|
18
18
|
|
19
|
-
Here is a quick example of how you would use
|
19
|
+
Here is a quick example of how you would use a SnFoil Searcher with Active Record.
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
# lib/searchers/people_searcher
|
@@ -53,7 +53,7 @@ end
|
|
53
53
|
```
|
54
54
|
|
55
55
|
#### Scoping
|
56
|
-
You can provide an
|
56
|
+
You can provide an initial scope to the searcher by passing it to `new`. If you don't pass in an initial scope, the searcher will try to use the model.
|
57
57
|
|
58
58
|
```ruby
|
59
59
|
PeopleSearcher.new(People.where(team_id: 2))
|
@@ -61,7 +61,7 @@ PeopleSearcher.new(People.where(team_id: 2))
|
|
61
61
|
|
62
62
|
#### Model
|
63
63
|
|
64
|
-
Model is
|
64
|
+
Model is an optional parameter you can set on the searcher class. If a model is defined - and there is no default scope provided when initializing the searcher - it will default to using `model.all`
|
65
65
|
|
66
66
|
```ruby
|
67
67
|
class PeopleSearcher
|
@@ -73,7 +73,7 @@ end
|
|
73
73
|
|
74
74
|
#### Filter
|
75
75
|
|
76
|
-
A filter is a step in the search process that takes the current scope and parameters and returns an altered scope. We recommend keeping each filter as simple as possible - it should only have one
|
76
|
+
A filter is a step in the search process that takes the current scope and parameters and returns an altered scope. We recommend keeping each filter as simple as possible - it should only have one responsibility. This way you can easily see every step the searcher takes to get to its outcome as well as defining behaviors that should be tested.
|
77
77
|
|
78
78
|
You can create as many filters as you would like, but it is important to remember that a filter should **always** return a scope.
|
79
79
|
|
@@ -109,7 +109,7 @@ end
|
|
109
109
|
```
|
110
110
|
|
111
111
|
#### Setup
|
112
|
-
Setup is just a filter that runs first - before any other filters. It does not allow for conditionals. We recommend using this block to setup any requirements, tenant scoping, or stuff that
|
112
|
+
Setup is just a filter that runs first - before any other filters. It does not allow for conditionals. We recommend using this block to setup any requirements, tenant scoping, or stuff that just needs to happen first.
|
113
113
|
|
114
114
|
```ruby
|
115
115
|
class PeopleSearcher
|
@@ -127,7 +127,7 @@ end
|
|
127
127
|
|
128
128
|
#### Casting Booleans
|
129
129
|
|
130
|
-
To help with
|
130
|
+
To help with casting boolean params - especially those coming from http params - we've added explicit boolean casting for params. There are parsed and cast in place before any filter. Just pass in an array of the params you would like to have cast.
|
131
131
|
|
132
132
|
```ruby
|
133
133
|
|
@@ -195,4 +195,4 @@ The gem is available as open source under the terms of the [Apache 2 License](ht
|
|
195
195
|
|
196
196
|
## Code of Conduct
|
197
197
|
|
198
|
-
Everyone interacting in the Snfoil::Policy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/limited-effort/snfoil-searcher/blob/main/CODE_OF_CONDUCT.md).
|
198
|
+
Everyone interacting in the Snfoil::Policy project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/limited-effort/snfoil-searcher/blob/main/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Original code taken from https://github.com/rails/rails/blob/6-1-stable/activemodel/lib/active_model/type/boolean.rb
|
4
|
+
|
5
|
+
# Copyright (c) 2005-2021 David Heinemeier Hansson
|
6
|
+
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
# a copy of this software and associated documentation files (the
|
9
|
+
# "Software"), to deal in the Software without restriction, including
|
10
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
# the following conditions:
|
14
|
+
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
26
|
+
require 'set'
|
27
|
+
|
28
|
+
module SnFoil
|
29
|
+
module Searcher
|
30
|
+
# A class that behaves like a boolean type, including rules for coercion of user input.
|
31
|
+
#
|
32
|
+
# === Coercion
|
33
|
+
# - "false", "f" , "0", +0+ or any other value in +FALSE_VALUES+ will be coerced to +false+
|
34
|
+
# - Empty strings are coerced to +nil+
|
35
|
+
# - All other values will be coerced to +true+
|
36
|
+
class Boolean
|
37
|
+
# rubocop:disable Lint/BooleanSymbol
|
38
|
+
FALSE_VALUES = [
|
39
|
+
false, 0,
|
40
|
+
'0', :'0',
|
41
|
+
'f', :f,
|
42
|
+
'F', :F,
|
43
|
+
'false', :false,
|
44
|
+
'FALSE', :FALSE,
|
45
|
+
'off', :off,
|
46
|
+
'OFF', :OFF,
|
47
|
+
'', nil
|
48
|
+
].to_set.freeze
|
49
|
+
# rubocop:enable Lint/BooleanSymbol
|
50
|
+
|
51
|
+
def cast(value)
|
52
|
+
!FALSE_VALUES.include?(value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/snfoil/searcher.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2021 Matthew Howes
|
3
|
+
# Copyright 2021 Matthew Howes, Cliff Campbell
|
4
4
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'active_support/concern'
|
18
|
+
require_relative 'searcher/boolean'
|
18
19
|
|
19
20
|
module SnFoil
|
20
21
|
#
|
@@ -30,39 +31,42 @@ module SnFoil
|
|
30
31
|
extend ActiveSupport::Concern
|
31
32
|
|
32
33
|
class_methods do
|
33
|
-
attr_reader :
|
34
|
+
attr_reader :snfoil_model, :snfoil_setup, :snfoil_filters, :snfoil_booleans
|
34
35
|
|
35
36
|
def model(klass = nil)
|
36
|
-
raise SnFoil::Searcher::Error, "model already defined for #{self.class.name}" if @
|
37
|
+
raise SnFoil::Searcher::Error, "model already defined for #{self.class.name}" if @snfoil_model
|
37
38
|
|
38
|
-
@
|
39
|
+
@snfoil_model = klass
|
39
40
|
end
|
40
41
|
|
41
42
|
def setup(setup_method = nil, &setup_block)
|
42
|
-
raise SnFoil::Searcher::Error, "setup already defined for #{self.class.name}" if @
|
43
|
+
raise SnFoil::Searcher::Error, "setup already defined for #{self.class.name}" if @snfoil_setup
|
43
44
|
|
44
|
-
@
|
45
|
+
@snfoil_setup = setup_method || setup_block
|
45
46
|
end
|
46
47
|
|
47
48
|
def filter(method = nil, **options, &block)
|
48
49
|
raise SnFoil::Searcher::ArgumentError, 'filter requires either a method name or a block' if method.nil? && block.nil?
|
49
50
|
|
50
|
-
(@
|
51
|
-
method: method,
|
52
|
-
block: block,
|
53
|
-
if: options[:if],
|
54
|
-
unless: options[:unless]
|
55
|
-
}
|
51
|
+
(@snfoil_filters ||= []) << { method: method, block: block, if: options[:if], unless: options[:unless] }
|
56
52
|
end
|
57
53
|
|
58
54
|
def booleans(*fields)
|
59
|
-
@
|
60
|
-
@
|
55
|
+
@snfoil_booleans ||= []
|
56
|
+
@snfoil_booleans |= fields.map(&:to_sym)
|
57
|
+
end
|
58
|
+
|
59
|
+
def inherited(subclass)
|
60
|
+
super
|
61
|
+
|
62
|
+
instance_variables.grep(/@snfoil_.+/).each do |i|
|
63
|
+
subclass.instance_variable_set(i, instance_variable_get(i).dup)
|
64
|
+
end
|
61
65
|
end
|
62
66
|
end
|
63
67
|
|
64
68
|
def model
|
65
|
-
self.class.
|
69
|
+
self.class.snfoil_model
|
66
70
|
end
|
67
71
|
|
68
72
|
attr_reader :scope
|
@@ -83,15 +87,15 @@ module SnFoil
|
|
83
87
|
def filter; end
|
84
88
|
|
85
89
|
def setup
|
86
|
-
self.class.
|
90
|
+
self.class.snfoil_setup
|
87
91
|
end
|
88
92
|
|
89
93
|
def filters
|
90
|
-
self.class.
|
94
|
+
self.class.snfoil_filters || []
|
91
95
|
end
|
92
96
|
|
93
97
|
def booleans
|
94
|
-
self.class.
|
98
|
+
self.class.snfoil_booleans || []
|
95
99
|
end
|
96
100
|
|
97
101
|
private
|
@@ -128,22 +132,14 @@ module SnFoil
|
|
128
132
|
end
|
129
133
|
|
130
134
|
def transform_params_booleans(params)
|
131
|
-
params.
|
135
|
+
params.to_h do |key, value|
|
132
136
|
value = if booleans.include?(key.to_sym)
|
133
|
-
|
137
|
+
SnFoil::Searcher::Boolean.new.cast(value)
|
134
138
|
else
|
135
139
|
value
|
136
140
|
end
|
137
141
|
[key, value]
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def value_to_boolean(value)
|
142
|
-
value = false if value == '' || value.nil?
|
143
|
-
|
144
|
-
falses = [false, 0, '0', :'0', 'f', :f, 'F', :F, 'false', :false, 'FALSE', :FALSE, 'off', :off, 'OFF', :OFF].to_set.freeze # rubocop:disable Lint/BooleanSymbol
|
145
|
-
|
146
|
-
!falses.include?(value)
|
142
|
+
end
|
147
143
|
end
|
148
144
|
end
|
149
145
|
end
|
data/snfoil-searcher.gemspec
CHANGED
@@ -5,24 +5,24 @@ require_relative 'lib/snfoil/searcher/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'snfoil-searcher'
|
7
7
|
spec.version = SnFoil::Searcher::VERSION
|
8
|
-
spec.authors = ['Matthew Howes']
|
9
|
-
spec.email = ['howeszy@gmail.com']
|
8
|
+
spec.authors = ['Matthew Howes', 'Cliff Campbell']
|
9
|
+
spec.email = ['howeszy@gmail.com', 'cliffcampbell@hey.com']
|
10
10
|
|
11
11
|
spec.summary = 'A Simple Searcher Framework'
|
12
|
-
spec.description = '
|
12
|
+
spec.description = 'Complex searching functionality as small easily testable sections.'
|
13
13
|
spec.homepage = 'https://github.com/limited-effort/snfoil-searcher'
|
14
14
|
spec.license = 'Apache-2.0'
|
15
|
-
spec.required_ruby_version = '>= 2.
|
15
|
+
spec.required_ruby_version = '>= 2.7'
|
16
16
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
18
|
spec.metadata['source_code_uri'] = spec.homepage
|
19
19
|
spec.metadata['changelog_uri'] = 'https://github.com/limited-effort/snfoil-searcher/blob/main/CHANGELOG.md'
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
|
24
|
-
|
25
|
-
end
|
24
|
+
ignore_list = %r{\A(?:test/|spec/|bin/|features/|Rakefile|\.\w)}
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) { `git ls-files -z`.split("\x0").reject { |f| f.match(ignore_list) } }
|
26
26
|
|
27
27
|
spec.bindir = 'exe'
|
28
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
@@ -30,11 +30,13 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency 'activesupport', '>= 5.2.6'
|
32
32
|
|
33
|
+
spec.add_development_dependency 'bundle-audit', '~> 0.1.0'
|
33
34
|
spec.add_development_dependency 'dry-struct', '~> 1.0'
|
35
|
+
spec.add_development_dependency 'fasterer', '~> 0.10.0'
|
34
36
|
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
35
37
|
spec.add_development_dependency 'rake', '~> 13.0'
|
36
38
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
37
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
39
|
+
spec.add_development_dependency 'rubocop', '~> 1.29'
|
38
40
|
spec.add_development_dependency 'rubocop-performance', '~> 1.11'
|
39
41
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.5'
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snfoil-searcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Howes
|
8
|
-
|
8
|
+
- Cliff Campbell
|
9
|
+
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activesupport
|
@@ -24,6 +25,20 @@ dependencies:
|
|
24
25
|
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: 5.2.6
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundle-audit
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.1.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.1.0
|
27
42
|
- !ruby/object:Gem::Dependency
|
28
43
|
name: dry-struct
|
29
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +53,20 @@ dependencies:
|
|
38
53
|
- - "~>"
|
39
54
|
- !ruby/object:Gem::Version
|
40
55
|
version: '1.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: fasterer
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.10.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.10.0
|
41
70
|
- !ruby/object:Gem::Dependency
|
42
71
|
name: pry-byebug
|
43
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +115,14 @@ dependencies:
|
|
86
115
|
requirements:
|
87
116
|
- - "~>"
|
88
117
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
118
|
+
version: '1.29'
|
90
119
|
type: :development
|
91
120
|
prerelease: false
|
92
121
|
version_requirements: !ruby/object:Gem::Requirement
|
93
122
|
requirements:
|
94
123
|
- - "~>"
|
95
124
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
125
|
+
version: '1.29'
|
97
126
|
- !ruby/object:Gem::Dependency
|
98
127
|
name: rubocop-performance
|
99
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,27 +151,21 @@ dependencies:
|
|
122
151
|
- - "~>"
|
123
152
|
- !ruby/object:Gem::Version
|
124
153
|
version: '2.5'
|
125
|
-
description:
|
126
|
-
small easily testable sections.
|
154
|
+
description: Complex searching functionality as small easily testable sections.
|
127
155
|
email:
|
128
156
|
- howeszy@gmail.com
|
157
|
+
- cliffcampbell@hey.com
|
129
158
|
executables: []
|
130
159
|
extensions: []
|
131
160
|
extra_rdoc_files: []
|
132
161
|
files:
|
133
|
-
- ".github/workflows/main.yml"
|
134
|
-
- ".gitignore"
|
135
|
-
- ".rspec"
|
136
|
-
- ".rubocop.yml"
|
137
162
|
- CHANGELOG.md
|
138
163
|
- CODE_OF_CONDUCT.md
|
139
164
|
- Gemfile
|
140
165
|
- LICENSE.txt
|
141
166
|
- README.md
|
142
|
-
- Rakefile
|
143
|
-
- bin/console
|
144
|
-
- bin/setup
|
145
167
|
- lib/snfoil/searcher.rb
|
168
|
+
- lib/snfoil/searcher/boolean.rb
|
146
169
|
- lib/snfoil/searcher/version.rb
|
147
170
|
- snfoil-searcher.gemspec
|
148
171
|
homepage: https://github.com/limited-effort/snfoil-searcher
|
@@ -152,7 +175,8 @@ metadata:
|
|
152
175
|
homepage_uri: https://github.com/limited-effort/snfoil-searcher
|
153
176
|
source_code_uri: https://github.com/limited-effort/snfoil-searcher
|
154
177
|
changelog_uri: https://github.com/limited-effort/snfoil-searcher/blob/main/CHANGELOG.md
|
155
|
-
|
178
|
+
rubygems_mfa_required: 'true'
|
179
|
+
post_install_message:
|
156
180
|
rdoc_options: []
|
157
181
|
require_paths:
|
158
182
|
- lib
|
@@ -160,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
184
|
requirements:
|
161
185
|
- - ">="
|
162
186
|
- !ruby/object:Gem::Version
|
163
|
-
version: 2.
|
187
|
+
version: '2.7'
|
164
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
189
|
requirements:
|
166
190
|
- - ">="
|
@@ -168,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
192
|
version: '0'
|
169
193
|
requirements: []
|
170
194
|
rubygems_version: 3.1.6
|
171
|
-
signing_key:
|
195
|
+
signing_key:
|
172
196
|
specification_version: 4
|
173
197
|
summary: A Simple Searcher Framework
|
174
198
|
test_files: []
|
data/.github/workflows/main.yml
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
name: build
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches: [ main ]
|
5
|
-
pull_request:
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
test:
|
9
|
-
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
|
12
|
-
strategy:
|
13
|
-
matrix:
|
14
|
-
ruby-version: [2.7, 2.6, 2.5]
|
15
|
-
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v2
|
18
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
19
|
-
uses: ruby/setup-ruby@v1.81.0
|
20
|
-
with:
|
21
|
-
ruby-version: ${{ matrix.ruby-version }}
|
22
|
-
bundler-cache: true
|
23
|
-
- name: Install dependencies
|
24
|
-
run: bundle install
|
25
|
-
- name: Run tests
|
26
|
-
run: bundle exec rspec
|
27
|
-
lint:
|
28
|
-
|
29
|
-
runs-on: ubuntu-latest
|
30
|
-
|
31
|
-
strategy:
|
32
|
-
matrix:
|
33
|
-
ruby-version: [2.7, 2.6, 2.5, '3.0']
|
34
|
-
|
35
|
-
steps:
|
36
|
-
- uses: actions/checkout@v2
|
37
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
38
|
-
uses: ruby/setup-ruby@v1.81.0
|
39
|
-
with:
|
40
|
-
ruby-version: ${{ matrix.ruby-version }}
|
41
|
-
bundler-cache: true
|
42
|
-
- name: Install dependencies
|
43
|
-
run: bundle install
|
44
|
-
- name: Run rubocop
|
45
|
-
run: bundle exec rubocop
|
46
|
-
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-performance
|
3
|
-
- rubocop-rspec
|
4
|
-
|
5
|
-
AllCops:
|
6
|
-
NewCops: enable
|
7
|
-
SuggestExtensions: false
|
8
|
-
TargetRubyVersion: 2.5.0
|
9
|
-
|
10
|
-
# ================ LAYOUT ==============
|
11
|
-
Layout/LineLength:
|
12
|
-
Max: 150
|
13
|
-
|
14
|
-
# ================ LINT ================
|
15
|
-
Lint/AmbiguousBlockAssociation:
|
16
|
-
Exclude:
|
17
|
-
- spec/**/*_spec.rb
|
18
|
-
|
19
|
-
Lint/EmptyClass:
|
20
|
-
Exclude:
|
21
|
-
- spec/**/*_spec.rb
|
22
|
-
|
23
|
-
# ================ Metics ================
|
24
|
-
Metrics/BlockLength:
|
25
|
-
Exclude:
|
26
|
-
- spec/**/*_spec.rb
|
27
|
-
- snfoil-searcher.gemspec
|
28
|
-
|
29
|
-
# ================ RSPEC ================
|
30
|
-
RSpec/FilePath:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
RSpec/MultipleExpectations:
|
34
|
-
Max: 5
|
35
|
-
|
36
|
-
RSpec/MultipleMemoizedHelpers:
|
37
|
-
Enabled: false
|
38
|
-
|
39
|
-
RSpec/NestedGroups:
|
40
|
-
Max: 5
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'snfoil/policy'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require 'irb'
|
15
|
-
IRB.start(__FILE__)
|