hoodoo 1.8.3 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjcxZjFkMGM3YThmNjZiN2ZiZjdiYTY4ZDVmM2MxYjFiYmNkMTJlMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjcxMWU3NjQ0YmZkYTE4YjY3MWMyOWM5NjMwNWI1YTU2ODc4MGQ4Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjVmNDgwNmQyMTQzZjY2ODg1YTkwYzFlZjMwYzE1NmJkMzdlMzM2MGYwNDAw
|
10
|
+
Y2M4Nzk0MTUyNmFmM2E2MjMyZmU3MjE1NWNjNWQwOTMwYmJiNDNmZTI2MWNi
|
11
|
+
YzBiM2JkYjVlOTk4YjBhZWQwZGE4MTcyMWQzYTI4ZDczZmQyZGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzkxN2NhN2QxZDg5ODMxZWEyZTU4MGY3ZGZhNTJiMzQxMTBkNzU3NDBiZjY4
|
14
|
+
OGVlMmJmNGFkNTk1NWQ1NzdiOTNjZWMzMzMzNDI4ZmIzYjQ3YmI0ZWEyYmI1
|
15
|
+
MWJmMjNlNThkNzY3MWQ3YjI3OTA1Njk3ODBjNzdlYWViMTE3N2Y=
|
@@ -113,6 +113,18 @@ module Hoodoo
|
|
113
113
|
}
|
114
114
|
end
|
115
115
|
|
116
|
+
# As #cs_match, but adds wildcards at the front and end of the string
|
117
|
+
# for a case-sensitive-all-wildcard match.
|
118
|
+
#
|
119
|
+
def self.csaw_match( model_field_name = nil )
|
120
|
+
Proc.new { | attr, value |
|
121
|
+
column = model_field_name || attr
|
122
|
+
value = ( value || '' ).to_s
|
123
|
+
|
124
|
+
[ "#{ column } LIKE ? AND #{ column } IS NOT NULL", "%#{ value }%" ]
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
116
128
|
# Case-insensitive match which should be fairly database independent
|
117
129
|
# but will run relatively slowly as a result. If you are using
|
118
130
|
# PostgreSQL, consider using the faster #ci_match_postgres method
|
data/lib/hoodoo/version.rb
CHANGED
@@ -288,6 +288,54 @@ describe Hoodoo::ActiveRecord::Finder::SearchHelper do
|
|
288
288
|
|
289
289
|
#############################################################################
|
290
290
|
|
291
|
+
context '#csaw_match' do
|
292
|
+
it 'generates expected no-input-parameter output' do
|
293
|
+
result = described_class.csaw_match()
|
294
|
+
expect( result.call( 'a', 'B' ) ).to eq( [ 'a LIKE ? AND a IS NOT NULL', '%B%' ] )
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'generates expected one-input-parameter output' do
|
298
|
+
result = described_class.csaw_match( :bar )
|
299
|
+
expect( result.call( 'a', 'B' ) ).to eq( [ 'bar LIKE ? AND bar IS NOT NULL', '%B%' ] )
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'finds expected things' do
|
303
|
+
result = find( described_class.csaw_match.call( 'field', 'hello' ) )
|
304
|
+
expect( result ).to match_array( [ @f2, @f3 ] )
|
305
|
+
|
306
|
+
result = find( described_class.csaw_match.call( 'field', 'HELLO' ) )
|
307
|
+
expect( result ).to match_array( [ @f4 ] )
|
308
|
+
|
309
|
+
result = find( described_class.csaw_match.call( 'field', 'hell' ) )
|
310
|
+
expect( result ).to match_array( [ @f2, @f3 ] )
|
311
|
+
|
312
|
+
result = find( described_class.csaw_match.call( 'field', 'llo' ) )
|
313
|
+
expect( result ).to match_array( [ @f2, @f3 ] )
|
314
|
+
|
315
|
+
result = find( described_class.csaw_match.call( 'field', 'heLLo' ) )
|
316
|
+
expect( result ).to match_array( [ ] )
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'finds expected things negated' do
|
320
|
+
result = find_not( described_class.csaw_match.call( 'field', 'hello' ) )
|
321
|
+
expect( result ).to match_array( [ @f1, @f4, @f5, @f6, @f7, @f8 ] )
|
322
|
+
|
323
|
+
result = find_not( described_class.csaw_match.call( 'field', 'HELLO' ) )
|
324
|
+
expect( result ).to match_array( [ @f1, @f2, @f3, @f5, @f6, @f7, @f8 ] )
|
325
|
+
|
326
|
+
result = find_not( described_class.csaw_match.call( 'field', 'hell' ) )
|
327
|
+
expect( result ).to match_array( [ @f1, @f4, @f5, @f6, @f7, @f8 ] )
|
328
|
+
|
329
|
+
result = find_not( described_class.csaw_match.call( 'field', 'llo' ) )
|
330
|
+
expect( result ).to match_array( [ @f1, @f4, @f5, @f6, @f7, @f8 ] )
|
331
|
+
|
332
|
+
result = find_not( described_class.csaw_match.call( 'field', 'heLLo' ) )
|
333
|
+
expect( result ).to match_array( [ @f1, @f2, @f3, @f4, @f5, @f6, @f7, @f8 ] )
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
#############################################################################
|
338
|
+
|
291
339
|
context '#ci_match_postgres' do
|
292
340
|
it 'generates expected no-input-parameter output' do
|
293
341
|
result = described_class.ci_match_postgres()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loyalty New Zealand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kgio
|