ook 0.0.1 → 0.0.2

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -6
  3. data/lib/ook.rb +6 -8
  4. data/ook.gemspec +2 -4
  5. data/test/ook_test.rb +14 -0
  6. metadata +2 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6f958c7bf8f4e80086d023c35343110f5765041
4
- data.tar.gz: ddc6d658b56fc63e8f81a78e6af09a9479f305bd
3
+ metadata.gz: f79c10f4c12e16dd4b20d721a2872257e4295bd7
4
+ data.tar.gz: cb8ed2975d744ee9ea14912c549482fd120b8426
5
5
  SHA512:
6
- metadata.gz: 6dfef27e8180bdcf50de1edf8341b10662b4a6d5ebd49bd42416778118ac2ea3a61903aef1ec7da3c19270486b8ad4da4b866293248918be6dcb4647d72256d9
7
- data.tar.gz: 2dd61beebbd4a498b3b6ac3b9b4a620c159d72b621221c51b5b43bf3f71707cbae2f68596e6f8272cd4839cb8109afc18453da395bfe04d5d0dc37988512e7ec
6
+ metadata.gz: 80ddf19b8d4c50a9a9720f446ff43a564dd491dce01bf1660261734521fab215cc886205176bb131c2c9d905c96edc30bb91d50c10ffbbe5ebced7359ed5688b
7
+ data.tar.gz: 19082a9573714f46382eea16adab10541f9af15d5672991fa095db5eebc52f26a3b05f3bc5c7b9aa69de7877ac62c2fbb17e3e8c8b0701e4b8aabe2d03a71250
data/README.md CHANGED
@@ -13,8 +13,7 @@ Interact with [Redis][redis] keys in an object oriented way.
13
13
  # a Redis client and a key.
14
14
  k = Ook.new(Redic.new, "foo")
15
15
 
16
- # As it depends on [Nido][nido], you can
17
- # append strings to the original namespace:
16
+ # You can append strings to the original namespace:
18
17
  k["bar"]["baz"].to_s #=> "foo:bar:baz"
19
18
 
20
19
  # And if you call Redis commands on it,
@@ -27,9 +26,10 @@ k.call("GET") # GET foo
27
26
  Usage
28
27
  -----
29
28
 
30
- The external API is very similar to that of [Nido][nido], but in
31
- addition you need to suply a Redis client. For a compatible
32
- client, check [Redic][redic].
29
+ You need to suply a Redis client and a key. There are no
30
+ restrictions regarding the type of the Redis client, but it must
31
+ respond to `call` and the signature must be identical to that of
32
+ [Redic][redic].
33
33
 
34
34
  ```ruby
35
35
  ns = Ook.new(Redic.new, "foo")
@@ -47,7 +47,6 @@ And you can use any object as a key, not only strings:
47
47
  ns[:bar][42] #=> "foo:bar:42"
48
48
  ```
49
49
 
50
- [nido]: https://github.com/soveran/nido
51
50
  [redic]: https://github.com/amakawa/redic
52
51
  [redis]: http://redis.io
53
52
 
data/lib/ook.rb CHANGED
@@ -1,29 +1,27 @@
1
- require "nido"
2
-
3
1
  class Ook
4
2
 
5
3
  # The Redis client can be swapped at any point.
6
4
  attr_accessor :redis
7
5
 
8
6
  # Receive a Redis client and a key. There are no restrictions
9
- # regardin the type of the Redis client, but it must respond to
7
+ # regarding the type of the Redis client, but it must respond to
10
8
  # `call` and the signature must be identical to that of Redic.
11
9
  def initialize(redis, key)
12
- @ns = Nido.new(key)
10
+ @ns = key
13
11
  @redis = redis
14
12
  end
15
13
 
16
14
  # The passed key will be appended to the previous namespace.
17
15
  def [](key)
18
- @ns = @ns[key]
19
- self
16
+ self.class.new(redis, sprintf("%s:%s", @ns, key))
20
17
  end
21
18
 
22
- # Return an instance of Nido with the current value.
23
- def to_s
19
+ def inspect
24
20
  @ns
25
21
  end
26
22
 
23
+ alias to_s inspect
24
+
27
25
  # Call commands on the Redis client after inserting the key
28
26
  # in the second position. Return the result of the command.
29
27
  def call(cmd, *args)
@@ -1,15 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ook"
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
  s.summary = "Object Oriented Keys for Redis"
5
- s.description = "Call Redis commands on keys created with Nido"
5
+ s.description = "Call commands on Redis keys"
6
6
  s.authors = ["Michel Martens"]
7
7
  s.email = ["michel@soveran.com"]
8
8
  s.homepage = "http://github.com/soveran/ook"
9
9
 
10
10
  s.files = `git ls-files`.split("\n")
11
11
 
12
- s.add_dependency "nido"
13
-
14
12
  s.add_development_dependency "cutest"
15
13
  end
@@ -21,4 +21,18 @@ scope do
21
21
 
22
22
  assert_equal "foo", k1.call("ECHO")
23
23
  end
24
+
25
+ test "creates new instances" do
26
+ k1 = Ook.new(Redic.new, "foo")
27
+ k2 = k1["bar"]
28
+
29
+ assert_equal "foo", k1.to_s
30
+ assert_equal "foo:bar", k2.to_s
31
+ end
32
+
33
+ test "inspect" do
34
+ k1 = Ook.new(Redic.new, "foo")
35
+
36
+ assert_equal "foo", k1.inspect
37
+ end
24
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: nido
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: cutest
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +24,7 @@ dependencies:
38
24
  - - '>='
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
- description: Call Redis commands on keys created with Nido
27
+ description: Call commands on Redis keys
42
28
  email:
43
29
  - michel@soveran.com
44
30
  executables: []