ruby-redis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/LICENSE +9 -0
  2. data/README +90 -0
  3. data/bin/ruby-redis +12 -0
  4. data/bin/ruby-redis.compiled.rbc +243 -0
  5. data/lib/redis/bin.rb +74 -0
  6. data/lib/redis/bin.rbc +1325 -0
  7. data/lib/redis/buftok.rbc +2658 -0
  8. data/lib/redis/config.rb +46 -0
  9. data/lib/redis/config.rbc +1009 -0
  10. data/lib/redis/connection.rb +69 -0
  11. data/lib/redis/connection.rbc +1354 -0
  12. data/lib/redis/database.rb +109 -0
  13. data/lib/redis/database.rbc +2275 -0
  14. data/lib/redis/hashes.rb +72 -0
  15. data/lib/redis/hashes.rbc +1843 -0
  16. data/lib/redis/hiredis.rbc +658 -0
  17. data/lib/redis/keys.rb +165 -0
  18. data/lib/redis/keys.rbc +3386 -0
  19. data/lib/redis/lists.rb +227 -0
  20. data/lib/redis/lists.rbc +5241 -0
  21. data/lib/redis/logger.rb +81 -0
  22. data/lib/redis/logger.rbc +2106 -0
  23. data/lib/redis/protocol.rb +170 -0
  24. data/lib/redis/protocol.rbc +3735 -0
  25. data/lib/redis/pubsub.rb +153 -0
  26. data/lib/redis/pubsub.rbc +3447 -0
  27. data/lib/redis/reader.rb +164 -0
  28. data/lib/redis/reader.rbc +2769 -0
  29. data/lib/redis/send.rbc +1268 -0
  30. data/lib/redis/sender.rb +49 -0
  31. data/lib/redis/sender.rbc +1057 -0
  32. data/lib/redis/server.rb +62 -0
  33. data/lib/redis/server.rbc +1177 -0
  34. data/lib/redis/sets.rb +105 -0
  35. data/lib/redis/sets.rbc +2800 -0
  36. data/lib/redis/strict.rb +67 -0
  37. data/lib/redis/strict.rbc +1419 -0
  38. data/lib/redis/strings.rb +144 -0
  39. data/lib/redis/strings.rbc +3338 -0
  40. data/lib/redis/synchrony.rb +58 -0
  41. data/lib/redis/synchrony.rbc +1397 -0
  42. data/lib/redis/version.rb +7 -0
  43. data/lib/redis/version.rbc +180 -0
  44. data/lib/redis/zsets.rb +281 -0
  45. data/lib/redis/zsets.rbc +6596 -0
  46. data/lib/redis.rb +215 -0
  47. data/lib/redis.rbc +4391 -0
  48. metadata +117 -0
@@ -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