redis_object 1.3.6 → 1.3.7

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTFmMDJkMzA1MjU1MDk0MDZhNTRlNmI0MGE4YjQ5NmY3MGI4NjU0Mw==
4
+ ZGQ0NGY4MDBkY2I2OTY1MTFjMmRjNTY2NDgzZmNjYTk0OTcwMzUyNg==
5
5
  data.tar.gz: !binary |-
6
- ZmRmMGI2ZTZkYjJjNjI1MTk0MjZmY2Q0ODE3ZTQ1NDYwZTlmMmJjYQ==
6
+ MjgyMDg2MDkzNjY0NDJjOWEyN2RkZDQwNDc3NDYzYWU5OTc4M2Q5Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjUyYjVjZGRhMmJmYzkzZDMwYjlmODc1NjNhMDI2ZmY5Y2UwMmQ2Nzk4OGRl
10
- MGNmNWIxMmM5ZmVlYTJmMjUzNDg4ZDQ3NThhMzFlMGQ2MmIzZjJlMDI2NGIy
11
- ZTYyYWYxZWRlY2M3YjQ3YjUzMjA2MTJjMzQzMzA2MGFkM2FlYjk=
9
+ ZmFlMmVhOTY2Y2MxOThmN2MzNTVmNjc5MzU0NTNjMzE5OWNlZGNiYzQxMzFm
10
+ NjBkZGM1MTEzNzgyMTdhOWY5ODE3ZTBmMjg3NjEyNWZiYjE5NTNiZmUxNWJm
11
+ OWEyYTEwMGEyZDU3OWE0YmQwYThiNTc4MzRjOGI4YjgwMGVkZWY=
12
12
  data.tar.gz: !binary |-
13
- OWEzODIzZjI0MGQwYTI5YTUzYTlmOWFjZmZmMmRlMGNlZDIyNTc5MmU3Nzcx
14
- OThmOWNlOTk3ZjBjZGRlMDBlYjJhMDM5ZmU1YjJlMjJhNjc5YmQxNzgxNjlk
15
- MWI4OWU4ZTQyNGRhOTBkMjMxNDJmZTk1ZTA4OWIwMTNkOTY2MjI=
13
+ NGU4MDUwNDBiMGFhYTA5ODk5NTQ1NGRlOWM4OGUzZWY2YjgzODgyZWIxMTEw
14
+ NDE5Y2ZhMjQxYzIzMDQ5NmQwZjY1N2Y4MjY3Yzg5ZDZhOTgwYmQ0MjFkYzY2
15
+ MjQ5ZGQwYmQ1OTcyNDU4Y2NkNWNjNzIyYmQzNDU2ODcwMTVkMmM=
@@ -278,19 +278,27 @@ module Seabright
278
278
  end
279
279
  end
280
280
 
281
+ NilPattern = 'nilpattern:'
282
+
281
283
  RedisObject::ScriptSources::Matcher = "local itms = redis.call('SMEMBERS',KEYS[1])
282
284
  local out = {}
283
285
  local val
284
286
  local pattern
285
287
  for i, v in ipairs(itms) do
286
288
  val = redis.call('HGET',v..'_h',ARGV[1])
287
- if ARGV[2]:find('^pattern:') then
288
- pattern = ARGV[2]:gsub('^pattern:','')
289
- if val:match(pattern) ~= nil then
290
- table.insert(out,itms[i])
289
+ if val then
290
+ if ARGV[2]:find('^pattern:') then
291
+ pattern = ARGV[2]:gsub('^pattern:','')
292
+ if val:match(pattern) ~= nil then
293
+ table.insert(out,itms[i])
294
+ end
295
+ else
296
+ if val == ARGV[2] then
297
+ table.insert(out,itms[i])
298
+ end
291
299
  end
292
300
  else
293
- if val == ARGV[2] then
301
+ if ARGV[2] == '#{NilPattern}' then
294
302
  table.insert(out,itms[i])
295
303
  end
296
304
  end
@@ -333,7 +341,11 @@ module Seabright
333
341
  end
334
342
  end
335
343
  else
336
- good = false
344
+ if matchers[n][2] == '#{NilPattern}' then
345
+ good = true
346
+ else
347
+ good = false
348
+ end
337
349
  end
338
350
  end
339
351
  if good == true then
@@ -343,7 +355,18 @@ module Seabright
343
355
  return out".gsub(/\t/,'').freeze
344
356
 
345
357
  def match(pkt)
346
- kys = run_script(pkt.keys.count > 1 ? :MultiMatcher : :Matcher,[plname],pkt.flatten.map{|i| i.is_a?(Regexp) ? convert_regex_to_lua(i) : i.to_s })
358
+ mtchr = pkt.keys.count > 1 ? :MultiMatcher : :Matcher
359
+ pkt = pkt.flatten.map do |i|
360
+ case i
361
+ when Regexp
362
+ convert_regex_to_lua(i)
363
+ when NilClass
364
+ NilPattern
365
+ else
366
+ i.to_s
367
+ end
368
+ end
369
+ kys = run_script(mtchr,[plname],pkt)
347
370
  Enumerator.new do |y|
348
371
  kys.each do |k|
349
372
  y << find(k)
@@ -1,5 +1,5 @@
1
1
  module Seabright
2
2
  class RedisObject
3
- VERSION = "1.3.6"
3
+ VERSION = "1.3.7"
4
4
  end
5
5
  end
data/spec/base_spec.rb CHANGED
@@ -45,9 +45,19 @@ describe RedisObject do
45
45
 
46
46
  it "should be found by complex matchers" do
47
47
  obj = ObjectTests::User.find(user_id: "test")
48
- obj.should_not be_nil
48
+ obj.first.should_not be_nil
49
49
  obj = ObjectTests::User.find(user_id: /test/)
50
- obj.should_not be_nil
50
+ obj.first.should_not be_nil
51
+ end
52
+
53
+ it "should be found by nil matchers" do
54
+ obj = ObjectTests::User.find(blah: nil)
55
+ obj.first.should_not be_nil
56
+ end
57
+
58
+ it "should be found by regex matchers that do not exist as keys" do
59
+ obj = ObjectTests::User.find(blah: /test/)
60
+ obj.first.should be_nil
51
61
  end
52
62
 
53
63
  it "can recollect objects" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.7
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-07-17 00:00:00.000000000 Z
11
+ date: 2013-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: utf8_utils