minidusen 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66b0584b719725f8f625cb93bab425665cb474c609a1a5c229954f7211541d21
4
- data.tar.gz: da214c18bb9ae43e795d224a9561e4a08ae6be2acdc5cfddf0a4e3231aab9bc9
3
+ metadata.gz: 49b6d529fa0d5d7d8b60601710f83bdca392e55f07e94c391262ffde4018a4f3
4
+ data.tar.gz: 9dfc4631c2c134f872a252a45bee844cbbc76589ea99fd121117700980989eb3
5
5
  SHA512:
6
- metadata.gz: ea259513910c5691dc6fd7e332b3aa30479ce7dd4c9080e88ef14b6277fd33516cd4698361a600036aa9f1e587da6fd774f8a8097a7fc108b29b78e9235a481a
7
- data.tar.gz: e827389410f4730a7af91ed7caf71731baa2ddc323ee9e31e65da43bdd55857b15a85d06afd1aa4a1376730f3390d5f9dd03d4d3a296a6411a0996fd819f7719
6
+ metadata.gz: e7093279ac9fad6059bdbedad5a5b82d7f6156a09f507f8e6b33ca7ab728e147e70cb1c4aed4dbf9eb8fb85db824a3aab8a92e4deca329a168a7da7a8d4edc5a
7
+ data.tar.gz: 0d3eea42001a1a95128d4ba3f3d139af9afb1e2cf21d665107fa5b53a1c3fdfc47ffbb441a35ead69da12825ce2eb30d77a514f6a0ff23d7bd04ce704b37b209
@@ -45,6 +45,7 @@ jobs:
45
45
 
46
46
  env:
47
47
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
48
+ BUNDLE_FROZEN: "false"
48
49
 
49
50
  steps:
50
51
  - uses: actions/checkout@v3
@@ -95,6 +96,7 @@ jobs:
95
96
 
96
97
  env:
97
98
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
99
+ BUNDLE_FROZEN: "false"
98
100
 
99
101
  steps:
100
102
  - uses: actions/checkout@v3
data/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
10
10
 
11
11
  ### Compatible changes
12
12
 
13
+ ## 1.0.1 2025-08-20
14
+
15
+ ### Compatible changes
16
+
17
+ - Support filter aliases (#25). Thanks to @botandrose.
18
+
19
+ ## 1.0.0 2025-07-31
20
+
21
+ ### Breaking changes
22
+
23
+ - Add a `phrase` flag to tokens
24
+
13
25
  ## 0.11.2 2024-10-31
14
26
 
15
27
  ### Compatible changes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (1.0.0)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
data/Gemfile.6.1.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (1.0.0)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (1.0.0)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
data/Gemfile.7.0.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (1.0.0)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (1.0.0)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
data/Gemfile.7.1.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (1.0.0)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (0.11.2)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
data/Gemfile.7.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (1.0.0)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (0.11.2)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
data/Gemfile.8.0.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minidusen (0.11.2)
4
+ minidusen (1.0.1)
5
5
  activerecord (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  edge_rider (>= 0.2.5)
data/README.md CHANGED
@@ -220,6 +220,36 @@ ContactFilter.new.filter(Contact, 'email:foo@bar.com').to_sql
220
220
  # => "SELECT * FROM contacts WHERE email='foo@bar.com'"
221
221
  ```
222
222
 
223
+ Filter aliases
224
+ --------------
225
+
226
+ You can define aliases for the same filter by passing multiple field names to a single `filter` call:
227
+
228
+ ```ruby
229
+ class ContactFilter
230
+ include Minidusen::Filter
231
+
232
+ filter :email, :mail, :contact do |scope, email|
233
+ scope.where(email: email)
234
+ end
235
+ end
236
+ ```
237
+
238
+ Now you can search using any of the defined aliases:
239
+
240
+ ```ruby
241
+ ContactFilter.new.filter(Contact, 'email:foo@bar.com').to_sql
242
+ # => "SELECT * FROM contacts WHERE email='foo@bar.com'"
243
+
244
+ ContactFilter.new.filter(Contact, 'mail:foo@bar.com').to_sql
245
+ # => "SELECT * FROM contacts WHERE email='foo@bar.com'"
246
+
247
+ ContactFilter.new.filter(Contact, 'contact:foo@bar.com').to_sql
248
+ # => "SELECT * FROM contacts WHERE email='foo@bar.com'"
249
+ ```
250
+
251
+ This feature is useful when you want to provide multiple intuitive ways for users to search the same field.
252
+
223
253
  ### Caveat
224
254
 
225
255
  If you search for a phrase containing a colon (e.g. `deploy:rollback`), Minidusen will mistake the first part as a – nonexistent – qualifier and return an empty set.
@@ -6,8 +6,10 @@ module Minidusen
6
6
 
7
7
  attr_accessor :minidusen_syntax
8
8
 
9
- def filter(field, &block)
10
- minidusen_syntax.learn_field(field, &block)
9
+ def filter(*fields, &block)
10
+ fields.each do |field|
11
+ minidusen_syntax.learn_field(field, &block)
12
+ end
11
13
  end
12
14
 
13
15
  end
@@ -1,3 +1,3 @@
1
1
  module Minidusen
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -212,6 +212,23 @@ describe Minidusen::Filter do
212
212
  filter_instance.filter(User, 'Abra').to_a.should == [match]
213
213
  end
214
214
 
215
+ it 'supports defining multiple field aliases with a single filter call' do
216
+ filter_class = Class.new do
217
+ include Minidusen::Filter
218
+
219
+ filter :name, :title do |scope, phrases|
220
+ scope.where_like([:name] => phrases)
221
+ end
222
+ end
223
+ filter_instance = filter_class.new
224
+
225
+ match = User.create!(:name => 'John Doe')
226
+ no_match = User.create!(:name => 'Jane Smith')
227
+
228
+ filter_instance.filter(User, 'name:John').to_a.should == [match]
229
+ filter_instance.filter(User, 'title:John').to_a.should == [match]
230
+ end
231
+
215
232
  end
216
233
 
217
234
  describe '#minidusen_syntax' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minidusen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-31 00:00:00.000000000 Z
11
+ date: 2025-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -118,7 +118,7 @@ licenses:
118
118
  - MIT
119
119
  metadata:
120
120
  rubygems_mfa_required: 'true'
121
- post_install_message:
121
+ post_install_message:
122
122
  rdoc_options: []
123
123
  require_paths:
124
124
  - lib
@@ -133,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.4.19
137
- signing_key:
136
+ rubygems_version: 3.5.23
137
+ signing_key:
138
138
  specification_version: 4
139
139
  summary: Low-tech search for ActiveRecord with MySQL or PostgreSQL
140
140
  test_files: []