nest 0.0.6 → 0.0.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.
- data/LICENSE +1 -1
- data/README.markdown +1 -1
- data/Rakefile +18 -0
- data/lib/nest.rb +15 -12
- data/nest.gemspec +1 -1
- data/test/nest_test.rb +24 -1
- metadata +3 -6
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -129,7 +129,7 @@ Installation
|
|
129
129
|
License
|
130
130
|
-------
|
131
131
|
|
132
|
-
Copyright (c) 2010 Michel Martens
|
132
|
+
Copyright (c) 2010 Michel Martens & Damian Janowski
|
133
133
|
|
134
134
|
Permission is hereby granted, free of charge, to any person
|
135
135
|
obtaining a copy of this software and associated documentation
|
data/Rakefile
CHANGED
@@ -3,3 +3,21 @@ task :test do
|
|
3
3
|
end
|
4
4
|
|
5
5
|
task :default => :test
|
6
|
+
|
7
|
+
task :commands do
|
8
|
+
require "open-uri"
|
9
|
+
require "par"
|
10
|
+
|
11
|
+
file = File.expand_path("lib/nest.rb", File.dirname(__FILE__))
|
12
|
+
path = "http://dimaion.com/redis/master/keys"
|
13
|
+
|
14
|
+
commands = open(path).read.split("\n")
|
15
|
+
|
16
|
+
source = File.read(file).sub(/ METHODS = .+?\n\n/m) do
|
17
|
+
Par.new(" METHODS = #{commands.map(&:to_sym).inspect}\n\n", p: 2)
|
18
|
+
end
|
19
|
+
|
20
|
+
File.open(file, "w") { |f| f.write source }
|
21
|
+
|
22
|
+
system "git diff --color-words #{file}"
|
23
|
+
end
|
data/lib/nest.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
class Nest < String
|
2
|
-
VERSION = "0.0.
|
2
|
+
VERSION = "0.0.7"
|
3
|
+
|
3
4
|
METHODS = [:append, :blpop, :brpop, :decr, :decrby, :del, :exists,
|
4
5
|
:expire, :expireat, :get, :getset, :hdel, :hexists, :hget, :hgetall,
|
5
|
-
:hincrby, :hkeys, :hlen, :hmget, :hmset, :hset, :
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
6
|
+
:hincrby, :hkeys, :hlen, :hmget, :hmset, :hset, :hsetnx, :hvals,
|
7
|
+
:incr, :incrby, :lindex, :linsert, :llen, :lpop, :lpush, :lpushx,
|
8
|
+
:lrange, :lrem, :lset, :ltrim, :move, :psubscribe, :publish,
|
9
|
+
:punsubscribe, :rename, :renamenx, :rpop, :rpoplpush, :rpush,
|
10
|
+
:rpushx, :sadd, :scard, :sdiff, :sdiffstore, :set, :setex, :setnx,
|
11
|
+
:sinter, :sinterstore, :sismember, :smembers, :smove, :sort,
|
12
|
+
:spop, :srandmember, :srem, :strlen, :subscribe, :substr, :sunion,
|
13
|
+
:sunionstore, :ttl, :type, :unsubscribe, :watch, :zadd, :zcard,
|
14
|
+
:zcount, :zincrby, :zinterstore, :zrange, :zrangebyscore, :zrank,
|
15
|
+
:zrem, :zremrangebyrank, :zremrangebyscore, :zrevrange, :zrevrank,
|
16
|
+
:zscore, :zunionstore]
|
14
17
|
|
15
18
|
def initialize(key, redis = nil)
|
16
19
|
super(key.to_s)
|
@@ -22,8 +25,8 @@ class Nest < String
|
|
22
25
|
end
|
23
26
|
|
24
27
|
METHODS.each do |meth|
|
25
|
-
define_method(meth) do |*args|
|
26
|
-
redis.send(meth, self, *args)
|
28
|
+
define_method(meth) do |*args, &block|
|
29
|
+
redis.send(meth, self, *args, &block)
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
data/nest.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "nest"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.7"
|
4
4
|
s.summary = "Generate nested namespaced keys for key-value databases."
|
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.authors = ["Michel Martens"]
|
data/test/nest_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path("test_helper", File.dirname(__FILE__))
|
2
2
|
|
3
3
|
class TestNest < Test::Unit::TestCase
|
4
4
|
context "creating namespaces" do
|
@@ -64,5 +64,28 @@ class TestNest < Test::Unit::TestCase
|
|
64
64
|
assert_equal nil, n1.get
|
65
65
|
assert_equal "s2", n1["bar"].get
|
66
66
|
end
|
67
|
+
|
68
|
+
should "PubSub" do
|
69
|
+
foo = Nest.new("foo", @redis)
|
70
|
+
listening = false
|
71
|
+
message_received = false
|
72
|
+
|
73
|
+
Thread.new do
|
74
|
+
while !listening; end
|
75
|
+
Nest.new("foo", Redis.new(:db => 15)).publish("")
|
76
|
+
end
|
77
|
+
|
78
|
+
foo.subscribe do |on|
|
79
|
+
on.message do
|
80
|
+
message_received = true
|
81
|
+
|
82
|
+
foo.unsubscribe
|
83
|
+
end
|
84
|
+
|
85
|
+
listening = true
|
86
|
+
end
|
87
|
+
|
88
|
+
assert message_received
|
89
|
+
end
|
67
90
|
end
|
68
91
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 19
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 7
|
9
|
+
version: 0.0.7
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Michel Martens
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-08-05 00:00:00 -03:00
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
@@ -50,7 +49,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
49
|
requirements:
|
51
50
|
- - ">="
|
52
51
|
- !ruby/object:Gem::Version
|
53
|
-
hash: 3
|
54
52
|
segments:
|
55
53
|
- 0
|
56
54
|
version: "0"
|
@@ -59,7 +57,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
57
|
requirements:
|
60
58
|
- - ">="
|
61
59
|
- !ruby/object:Gem::Version
|
62
|
-
hash: 3
|
63
60
|
segments:
|
64
61
|
- 0
|
65
62
|
version: "0"
|