ruby-redis 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +9 -0
- data/README +90 -0
- data/bin/ruby-redis +12 -0
- data/bin/ruby-redis.compiled.rbc +243 -0
- data/lib/redis/bin.rb +74 -0
- data/lib/redis/bin.rbc +1325 -0
- data/lib/redis/buftok.rbc +2658 -0
- data/lib/redis/config.rb +46 -0
- data/lib/redis/config.rbc +1009 -0
- data/lib/redis/connection.rb +69 -0
- data/lib/redis/connection.rbc +1354 -0
- data/lib/redis/database.rb +109 -0
- data/lib/redis/database.rbc +2275 -0
- data/lib/redis/hashes.rb +72 -0
- data/lib/redis/hashes.rbc +1843 -0
- data/lib/redis/hiredis.rbc +658 -0
- data/lib/redis/keys.rb +165 -0
- data/lib/redis/keys.rbc +3386 -0
- data/lib/redis/lists.rb +227 -0
- data/lib/redis/lists.rbc +5241 -0
- data/lib/redis/logger.rb +81 -0
- data/lib/redis/logger.rbc +2106 -0
- data/lib/redis/protocol.rb +170 -0
- data/lib/redis/protocol.rbc +3735 -0
- data/lib/redis/pubsub.rb +153 -0
- data/lib/redis/pubsub.rbc +3447 -0
- data/lib/redis/reader.rb +164 -0
- data/lib/redis/reader.rbc +2769 -0
- data/lib/redis/send.rbc +1268 -0
- data/lib/redis/sender.rb +49 -0
- data/lib/redis/sender.rbc +1057 -0
- data/lib/redis/server.rb +62 -0
- data/lib/redis/server.rbc +1177 -0
- data/lib/redis/sets.rb +105 -0
- data/lib/redis/sets.rbc +2800 -0
- data/lib/redis/strict.rb +67 -0
- data/lib/redis/strict.rbc +1419 -0
- data/lib/redis/strings.rb +144 -0
- data/lib/redis/strings.rbc +3338 -0
- data/lib/redis/synchrony.rb +58 -0
- data/lib/redis/synchrony.rbc +1397 -0
- data/lib/redis/version.rb +7 -0
- data/lib/redis/version.rbc +180 -0
- data/lib/redis/zsets.rb +281 -0
- data/lib/redis/zsets.rbc +6596 -0
- data/lib/redis.rb +215 -0
- data/lib/redis.rbc +4391 -0
- metadata +117 -0
data/lib/redis/strict.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path '../redis', File.dirname(__FILE__)
|
2
|
+
|
3
|
+
class Redis
|
4
|
+
|
5
|
+
# This is faster and allows for experimentation with duck-typing.
|
6
|
+
module NotStrict
|
7
|
+
|
8
|
+
def redis_t *args
|
9
|
+
end
|
10
|
+
|
11
|
+
def redis_f val, msg = nil
|
12
|
+
if Numeric === val
|
13
|
+
val
|
14
|
+
else
|
15
|
+
val_downcase = val.downcase
|
16
|
+
if val_downcase == '-inf'
|
17
|
+
-1.0/0
|
18
|
+
elsif val_downcase =~ /^[+]?inf$/
|
19
|
+
1.0/0
|
20
|
+
else
|
21
|
+
val.to_f
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def redis_i val, msg = nil
|
27
|
+
val.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
def redis_pos_i val, msg = 'value is negative'
|
31
|
+
val = redis_i val # may call strict
|
32
|
+
raise msg if val < 0
|
33
|
+
val
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# Strict version allows the ruby-redis server to pass redis tests.
|
39
|
+
module Strict
|
40
|
+
include NotStrict
|
41
|
+
|
42
|
+
def redis_t *args
|
43
|
+
val = args.pop
|
44
|
+
msg = 'Operation against a key holding the wrong kind of value'
|
45
|
+
unless Class === args.last
|
46
|
+
msg = val
|
47
|
+
val = args.pop
|
48
|
+
end
|
49
|
+
args.each do |klass|
|
50
|
+
return if klass === val
|
51
|
+
end
|
52
|
+
raise msg
|
53
|
+
end
|
54
|
+
|
55
|
+
def redis_f val, msg = 'value is not a double'
|
56
|
+
raise msg+val.to_s.dump unless Numeric === val or val =~ /^[ +-]?([0-9.e-]*|inf)$/i
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def redis_i val, msg = 'value is not an integer or out of range'
|
61
|
+
raise msg unless Integer === val or val =~ /^[ +-]?[0-9]*$/
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|