redis_object 1.4.7 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjZmYjVhYmM1NDZmZTY1MTgyZWE3NDE3ZmYxZTFkOTAyNjM1OGJkYg==
5
- data.tar.gz: !binary |-
6
- YmViNzk2OTIyMTFjNWJhM2Q5MDc5MzZmOTNjMWYxNWNlYmVkMDlhYw==
2
+ SHA1:
3
+ metadata.gz: 309bfbe4b9a0f3b7cd21f4489158961a6eb71544
4
+ data.tar.gz: dea0e37b8a70a54279e4d933326a39fefa4fb71b
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NmI0NTBiOWEyMjliMzIyMTUxOTM0NDFmOWRkMmIwOTRlYWE2ZTEzYWFhNmRh
10
- NzA5MmQ2NTcwYjc2YWE2MzhiMDM5MTlkYjQyNTU1ZGRlMzA3MDk5NGVkYTY5
11
- Nzg0YTQ4NTZiZGExOTU1NjNkYTIwZDFlMWVlNDc5Y2FjOTQwNzk=
12
- data.tar.gz: !binary |-
13
- YjkwMDRmN2E2OTcwMjQ0NmM4ZjlmM2RlNmMxM2NiNTczMzRmMjA4ZjE4YzYy
14
- ODNkYWEzZDQ1NWY1MjFkZTFiMmI0OTM1MDcxYzVkYjYyNjdkNDQ0YWUxMjNm
15
- M2E5OTAwOTUyYmZjOTg0YzZkYWU0MjA0NjQ4ZDJjNGM1OWVjN2U=
6
+ metadata.gz: f636bd5f287ec4a923442bd8ffed7d8dd135a5e7adc54b5d629738bb7103f84f991d863af237fd404b9184bbc4c35fbc4e9f548e09e5899bb822648a11bc16a9
7
+ data.tar.gz: 7c515b5507ea353a13ad484c5c19649a066cb6943b1790e1235599cfcfbbd7e5a054fce7a56608b8d4c76cbd233ca579e3909c3fca243193f76c8e254dc63db4
@@ -273,15 +273,214 @@ module Seabright
273
273
  find k
274
274
  end
275
275
 
276
- def match(pkt)
277
- Enumerator.new do |y|
278
- each do |i|
279
- if pkt.all? {|hk,va| i.get(hk)==va }
280
- y << i
276
+ NilPattern = 'nilpattern:'
277
+
278
+ RedisObject::ScriptSources::ColMatcher = "
279
+ local out = {}
280
+ local val
281
+ local pattern
282
+ for i, v in ipairs(KEYS) do
283
+ val = redis.call('HGET',v,ARGV[1])
284
+ if val then
285
+ if ARGV[2]:find('^pattern:') then
286
+ pattern = ARGV[2]:gsub('^pattern:','')
287
+ if val:match(pattern) then
288
+ table.insert(out,KEYS[i])
289
+ end
290
+ elseif ARGV[2]:find('^ipattern:') then
291
+ pattern = ARGV[2]:gsub('^ipattern:',''):lower()
292
+ if val:lower():match(pattern) then
293
+ table.insert(out,KEYS[i])
294
+ end
295
+ else
296
+ if val == ARGV[2] then
297
+ table.insert(out,KEYS[i])
298
+ end
299
+ end
300
+ else
301
+ if ARGV[2] == '#{NilPattern}' then
302
+ table.insert(out,KEYS[i])
303
+ end
304
+ end
305
+ end
306
+ return out".gsub(/\t/,'').freeze
307
+
308
+ RedisObject::ScriptSources::ColMultiMatcher = "
309
+ local out = {}
310
+ local matchers = {}
311
+ local matcher = {}
312
+ local mod
313
+ for i=1,#ARGV do
314
+ mod = i % 2
315
+ if mod == 1 then
316
+ matcher[1] = ARGV[i]
317
+ else
318
+ matcher[2] = ARGV[i]
319
+ table.insert(matchers,matcher)
320
+ matcher = {}
321
+ end
322
+ end
323
+ local val
324
+ local good
325
+ local pattern
326
+ for i, v in ipairs(KEYS) do
327
+ good = true
328
+ for n=1,#matchers do
329
+ val = redis.call('HGET',v,matchers[n][1])
330
+ if val then
331
+ if matchers[n][2]:find('^pattern:') then
332
+ pattern = matchers[n][2]:gsub('^pattern:','')
333
+ if val:match(pattern) then
334
+ good = good
335
+ else
336
+ good = false
337
+ break
338
+ end
339
+ elseif matchers[n][2]:find('^ipattern:') then
340
+ pattern = matchers[n][2]:gsub('^ipattern:',''):lower()
341
+ if val:lower():match(pattern) then
342
+ good = good
343
+ else
344
+ good = false
345
+ break
346
+ end
347
+ else
348
+ if val ~= matchers[n][2] then
349
+ good = false
350
+ break
351
+ end
352
+ end
353
+ else
354
+ if matchers[n][2] == '#{NilPattern}' then
355
+ good = good
356
+ else
357
+ good = false
358
+ break
359
+ end
281
360
  end
282
361
  end
362
+ if good == true then
363
+ table.insert(out,KEYS[i])
364
+ end
365
+ end
366
+ return out".gsub(/\t/,'').freeze
367
+
368
+ RedisObject::ScriptSources::ColOrMatcher = "
369
+ local out = {}
370
+ local matchers = {}
371
+ local matcher = {}
372
+ local mod
373
+ for i=1,#ARGV do
374
+ mod = i % 2
375
+ if mod == 1 then
376
+ matcher[1] = ARGV[i]
377
+ else
378
+ matcher[2] = ARGV[i]
379
+ table.insert(matchers,matcher)
380
+ matcher = {}
381
+ end
382
+ end
383
+
384
+ local val
385
+ local good
386
+ local pattern
387
+ for i, v in ipairs(KEYS) do
388
+ good = false
389
+ for n=1,#matchers do
390
+ val = redis.call('HGET',v,matchers[n][1])
391
+ if val then
392
+ if matchers[n][2]:find('^pattern:') then
393
+ pattern = matchers[n][2]:gsub('^pattern:','')
394
+ if val:match(pattern) then
395
+ good = true
396
+ break
397
+ else
398
+ good = good
399
+ end
400
+ elseif matchers[n][2]:find('^ipattern:') then
401
+ pattern = matchers[n][2]:gsub('^ipattern:',''):lower()
402
+ if val:lower():match(pattern) then
403
+ good = true
404
+ break
405
+ else
406
+ good = good
407
+ end
408
+ else
409
+ if val == matchers[n][2] then
410
+ good = true
411
+ break
412
+ end
413
+ end
414
+ else
415
+ if matchers[n][2] == '#{NilPattern}' then
416
+ good = good
417
+ break
418
+ else
419
+ good = false
420
+ end
421
+ end
422
+ end
423
+ if good == true then
424
+ table.insert(out,KEYS[i])
425
+ end
426
+ end
427
+ return out".gsub(/\t/,'').freeze
428
+
429
+ def match(pkt, use_or=false)
430
+ if use_or
431
+ mtchr = :ColOrMatcher
432
+ else
433
+ mtchr = pkt.keys.count > 1 ? :ColMultiMatcher : :ColMatcher
434
+ end
435
+ pkt = pkt.flatten.reduce([]) do |i,v|
436
+ x = case v
437
+ when Regexp
438
+ convert_regex_to_lua(v)
439
+ when Array
440
+ raise ArgumentError.new("An array can only be used with the find_or method") unless use_or
441
+ inject_key(i.last, v)
442
+ when NilClass
443
+ NilPattern
444
+ else
445
+ v.to_s
446
+ end
447
+ i << x
448
+ i
449
+ end
450
+ kys = run_script(mtchr,self,pkt.flatten)
451
+ ListEnumerator.new(kys) do |y|
452
+ kys.each do |k|
453
+ y << class_const.find_by_key(k)
454
+ end
283
455
  end
284
456
  end
457
+
458
+ def inject_key(key,list)
459
+ out = []
460
+ list.each do |i|
461
+ if i == list.first
462
+ out << i
463
+ else
464
+ out << key
465
+ out << i
466
+ end
467
+ end
468
+ out
469
+ end
470
+
471
+ def convert_regex_to_lua(reg)
472
+ "#{reg.casefold? ? "i" : ""}pattern:#{reg.source.gsub("\\","")}"
473
+ end
474
+
475
+ # def match(pkt)
476
+ # Enumerator.new do |y|
477
+ # each do |i|
478
+ # if pkt.all? {|hk,va| i.get(hk)==va }
479
+ # y << i
480
+ # end
481
+ # end
482
+ # end
483
+ # end
285
484
 
286
485
  def real_at(key)
287
486
  class_const.find_by_key(key)
@@ -1,5 +1,5 @@
1
1
  module Seabright
2
2
  class RedisObject
3
- VERSION = "1.4.7"
3
+ VERSION = "1.4.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Bragg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-19 00:00:00.000000000 Z
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: utf8_utils
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redis
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.0.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yajl-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.2.13
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.2.13
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: psych
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.3.4
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.4
83
83
  description: ''
@@ -87,10 +87,10 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .coveralls.yml
91
- - .gitignore
92
- - .rspec
93
- - .travis.yml
90
+ - ".coveralls.yml"
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
94
  - Gemfile
95
95
  - Guardfile
96
96
  - README.markdown
@@ -160,17 +160,17 @@ require_paths:
160
160
  - lib
161
161
  required_ruby_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - ! '>='
163
+ - - ">="
164
164
  - !ruby/object:Gem::Version
165
165
  version: 1.9.2
166
166
  required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  requirements:
168
- - - ! '>='
168
+ - - ">="
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
172
  rubyforge_project: redis_object
173
- rubygems_version: 2.1.4
173
+ rubygems_version: 2.0.3
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Maps arbitrary objects to a Redis store with indices and smart retrieval