ccp 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ccp/kvs/core.rb +2 -0
- data/lib/ccp/kvs/tokyo/base.rb +12 -0
- data/lib/ccp/kvs/tokyo/cabinet.rb +5 -0
- data/lib/ccp/version.rb +1 -1
- data/spec/kvs/core_spec.rb +2 -0
- data/spec/kvs/tokyo/cabinet_spec.rb +12 -0
- metadata +4 -4
data/lib/ccp/kvs/core.rb
CHANGED
@@ -6,6 +6,8 @@ module Ccp
|
|
6
6
|
def del(k) ; raise NotImplementedError, "subclass resposibility"; end
|
7
7
|
def keys ; raise NotImplementedError, "subclass resposibility"; end
|
8
8
|
def read! ; keys.inject({}){|h,k| h[k] = get(k); h } ; end
|
9
|
+
def exist?(k); !! get(k) ; end
|
10
|
+
def key?(k) ; exist?(k) ; end
|
9
11
|
|
10
12
|
def open(*) ; end
|
11
13
|
def close ; end
|
data/lib/ccp/kvs/tokyo/base.rb
CHANGED
@@ -25,6 +25,18 @@ module Ccp
|
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
|
+
# Check ecode and then raise. too boring... The library should implement this as atomic operation!
|
29
|
+
def atomic(&block)
|
30
|
+
raise NotImplementedError, "tc keep ecode until new erros occured"
|
31
|
+
|
32
|
+
if tokyo_error?
|
33
|
+
raise "tc already error before atomic: #{@db.ecode}"
|
34
|
+
end
|
35
|
+
v = block.call
|
36
|
+
tokyo_error! if tokyo_error?
|
37
|
+
return v
|
38
|
+
end
|
39
|
+
|
28
40
|
def tokyo_error!(label = nil)
|
29
41
|
raise Ccp::Kvs::Tokyo::Error, "%s%s (%s)" % [label, error_message, @source]
|
30
42
|
end
|
data/lib/ccp/version.rb
CHANGED
data/spec/kvs/core_spec.rb
CHANGED
@@ -275,4 +275,16 @@ describe Ccp::Kvs::Tokyo::Cabinet do
|
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
|
+
######################################################################
|
279
|
+
### exist?
|
280
|
+
|
281
|
+
describe "#exist?" do
|
282
|
+
specify do
|
283
|
+
put(:foo, 1)
|
284
|
+
|
285
|
+
kvs.R!
|
286
|
+
kvs.exist?(:foo).should be
|
287
|
+
kvs.exist?(:bar).should_not be
|
288
|
+
end
|
289
|
+
end
|
278
290
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- maiha
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-09-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activesupport
|