nest 3.1.2 → 3.2.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b4051899b40f130c9023399b34fe3b3047a0170c07e6dfc073eafa57374fa2a
4
- data.tar.gz: 26a22e4a124299b661d4f4027cc2428c0b6168eaa136504d8ccaea8e052da2e9
3
+ metadata.gz: 9685663900764bf070c2df77c922d49a941445cd44470ce4338c14888c03060f
4
+ data.tar.gz: 9043b9e906251c7c46dd8a8d7f7b3284e003e74a645601f4c63a7f36a011563c
5
5
  SHA512:
6
- metadata.gz: cd3a7b2c6fdd0e38aed0df1c80a989f3c2806341eecacfe50dc84b662daabcbca9f5d161780ce3f3bb5524adf8dba88986859941aabf2bc134dcf3b1dba20846
7
- data.tar.gz: a9eae2a74da50282559d4c76f5ea93fc87d83a3b0f84ebccd93c8b3f528da8276f562ba1c2abbbc62348fa97e13f1ef9a8f7b35e11dfba6aaf0e7e9bade2c324
6
+ metadata.gz: fd29444065af0d03560decee48b09657f2bc46ca7fa09991de602203e2057708d6fdf70bdea382a1cf4a5a1a6813223d722f25fd1599eb643fc745237afd82b3
7
+ data.tar.gz: 138cc5962e6fe7d8d4d38319c960104dc0a56a1408f47c4c4dafb362dd062959faa770150400202986f44ea965c1278f8e0137a89cb4f8a585c50050ec97f160
@@ -1,3 +1,7 @@
1
+ ## 3.2.0
2
+
3
+ - Add call!, queue and commit commands.
4
+
1
5
  ## 3.1.2
2
6
 
3
7
  - Define to_json
data/README.md CHANGED
@@ -85,6 +85,44 @@ dealing with events:
85
85
  => ["Redis Meetup"]
86
86
  ```
87
87
 
88
+ API
89
+ ---
90
+
91
+ `call`: Receives a Redis command and its arguments, and returns the
92
+ reply from the Redis server. If the reply from Redis is an error,
93
+ an instance of `RuntimeError` is returned.
94
+
95
+ `call!`: Similar to `call`, but instead of returning
96
+ an instance of `RuntimeError` when the command fails, the error is
97
+ raised.
98
+
99
+ `queue`: Receives the same kind of arguments as `call`, but enqueues
100
+ the command in a transaction.
101
+
102
+ `commit`: Commits the transaction and returns the reply from Redis.
103
+
104
+ Any call to a missing method will result in `Nest` converting the
105
+ method name to a Redis command and applying the arguments in an
106
+ invocation to `call`.
107
+
108
+ For example:
109
+
110
+ ```ruby
111
+ ns = Nest.new("foo")
112
+ ns.append("hello,")
113
+ ns.append(" world")
114
+ ns.get
115
+ ```
116
+
117
+ Is equivalent to:
118
+
119
+ ```ruby
120
+ ns = Nest.new("foo")
121
+ ns.call("APPEND", "hello,")
122
+ ns.call("APPEND", " world")
123
+ ns.call("GET")
124
+ ```
125
+
88
126
  Supplying your existing Redis instance
89
127
  --------------------------------------
90
128
 
@@ -33,7 +33,7 @@ class Nest
33
33
  def redis
34
34
  @rc
35
35
  end
36
-
36
+
37
37
  def hash
38
38
  @ns.hash
39
39
  end
@@ -57,6 +57,18 @@ class Nest
57
57
  @rc.call(command, to_s, *args)
58
58
  end
59
59
 
60
+ def call!(command, *args)
61
+ @rc.call!(command, to_s, *args)
62
+ end
63
+
64
+ def queue(command, *args)
65
+ @rc.queue(command, to_s, *args)
66
+ end
67
+
68
+ def commit
69
+ @rc.commit
70
+ end
71
+
60
72
  def inspect
61
73
  @ns.inspect
62
74
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "nest"
3
- s.version = "3.1.2"
3
+ s.version = "3.2.0"
4
4
  s.summary = "Object-oriented keys for Redis."
5
5
  s.description = "It is a design pattern in key-value databases to use the key to simulate structure, and Nest can take care of that."
6
6
  s.license = "MIT"
@@ -60,6 +60,28 @@ scope do
60
60
 
61
61
  assert @redis.object_id == n1["bar"].redis.object_id
62
62
  end
63
+
64
+ test "execute multiple redis commands in transaction" do
65
+ n1 = Nest.new("foo", @redis)
66
+
67
+ n1.queue("APPEND", "foo")
68
+ n1.queue("APPEND", "bar")
69
+ n1.commit
70
+
71
+ assert_equal "foobar", n1.get
72
+ end
73
+
74
+ test "raise error on redis failure when calling with bang" do
75
+ n1 = Nest.new("foo", @redis)
76
+ v1 = "234293482390480948029348230948"
77
+
78
+ n1.call("SET", v1)
79
+
80
+ assert_equal v1, n1.call!("GET")
81
+ assert_raise RuntimeError do
82
+ n1.call!("DECR")
83
+ end
84
+ end
63
85
  end
64
86
 
65
87
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nest
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-31 00:00:00.000000000 Z
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redic
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.0.1
79
+ rubygems_version: 3.0.2
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Object-oriented keys for Redis.