ccp 0.4.0 → 0.4.1
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/ccp.gemspec +19 -6
- data/lib/ccp/kvs/kyoto/cabinet.rb +4 -6
- data/lib/ccp/version.rb +1 -1
- data/spec/kvs/enum_spec.rb +2 -1
- data/spec/kvs/kvs_spec.rb +2 -1
- data/spec/kvs/kyoto/cabinet_spec.rb +11 -0
- data/spec/kvs/load_spec.rb +3 -2
- data/spec/kvs/tokyo/cabinet_spec.rb +1 -1
- data/spec/kvs/tokyo/info_spec.rb +1 -1
- data/spec/kvs/usecase_spec.rb +2 -1
- data/spec/spec_helper.rb +4 -0
- data/spec/storage/loadable_spec.rb +12 -10
- data/spec/storage/usecase_spec.rb +2 -1
- metadata +18 -2
data/ccp.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "ccp/version"
|
2
|
+
require File.expand_path('../lib/ccp/version', __FILE__)
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "ccp"
|
@@ -29,10 +28,24 @@ Gem::Specification.new do |s|
|
|
29
28
|
s.add_runtime_dependency "must", ">= 0.3.0"
|
30
29
|
s.add_runtime_dependency "dsl_accessor", ">= 0.4.1"
|
31
30
|
s.add_runtime_dependency "json"
|
32
|
-
|
33
|
-
|
31
|
+
|
32
|
+
|
33
|
+
if RUBY_PLATFORM == 'java'
|
34
|
+
s.platform = RUBY_PLATFORM
|
35
|
+
s.add_runtime_dependency "msgpack-jruby", "~> 1.3.2"
|
36
|
+
else
|
37
|
+
s.add_runtime_dependency "yajl-ruby"
|
38
|
+
s.add_runtime_dependency 'msgpack', '> 0.4'
|
39
|
+
s.add_runtime_dependency "tokyocabinet", "~> 1.29.1"
|
40
|
+
end
|
41
|
+
|
42
|
+
### test
|
34
43
|
|
35
44
|
s.add_development_dependency "rspec"
|
36
|
-
|
37
|
-
|
45
|
+
if defined?(JRUBY_VERSION)
|
46
|
+
s.add_runtime_dependency 'kyotocabinet-java'
|
47
|
+
else
|
48
|
+
s.add_development_dependency "tokyocabinet", "~> 1.29.1"
|
49
|
+
s.add_development_dependency "kyotocabinet-ruby", "~> 1.27.1"
|
50
|
+
end
|
38
51
|
end
|
@@ -18,18 +18,16 @@ module Ccp
|
|
18
18
|
if v
|
19
19
|
return decode(v)
|
20
20
|
else
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
kyoto_error!("get(%s): " % k)
|
25
|
-
end
|
21
|
+
# tc, kc is not safe for file deletion or unexpected stuffs
|
22
|
+
# if @db.error.is_a?(KyotoCabinet::Error::XNOREC)
|
23
|
+
return nil
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
27
|
def set(k,v)
|
30
28
|
tryW("set")
|
31
29
|
val = encode(v)
|
32
|
-
@db
|
30
|
+
@db.set(k.to_s, val) or
|
33
31
|
kyoto_error!("set(%s): " % k)
|
34
32
|
end
|
35
33
|
|
data/lib/ccp/version.rb
CHANGED
data/spec/kvs/enum_spec.rb
CHANGED
data/spec/kvs/kvs_spec.rb
CHANGED
@@ -99,6 +99,17 @@ describe Ccp::Kvs::Kyoto::Cabinet do
|
|
99
99
|
before { put(:foo, 1); kvs.W! }
|
100
100
|
specify { kvs.W { kvs.get("foo").should == "1" } }
|
101
101
|
end
|
102
|
+
|
103
|
+
### error: rare case
|
104
|
+
|
105
|
+
pending "TODO: tc,kc is not safe about file deletion" do
|
106
|
+
# ruby: + open(read) -----------------+ kvs.get ---
|
107
|
+
# file: + delete kch ---------------
|
108
|
+
context "(for read with file deletion)" do
|
109
|
+
before { put(:foo, 1); kvs.W!; kch.unlink }
|
110
|
+
specify { kvs.set("xxx", "_").should == false }
|
111
|
+
end
|
112
|
+
end
|
102
113
|
end
|
103
114
|
|
104
115
|
######################################################################
|
data/spec/kvs/load_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Ccp::Kvs do
|
|
12
12
|
|
13
13
|
context "(unknown codec)" do
|
14
14
|
specify do
|
15
|
-
expect{ Ccp::Kvs.load("foo.xxx.
|
15
|
+
expect{ Ccp::Kvs.load("foo.xxx.kch") }.to raise_error(/xxx/)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -26,7 +26,8 @@ describe Ccp::Kvs do
|
|
26
26
|
### Usally case
|
27
27
|
|
28
28
|
codecs = %w( json msgpack )
|
29
|
-
exts = %w(
|
29
|
+
exts = %w( kch )
|
30
|
+
exts << "tch" if defined?(TokyoCabinet)
|
30
31
|
|
31
32
|
codecs.product(exts).each do |codec, ext|
|
32
33
|
file = "foo.#{codec}.#{ext}"
|
data/spec/kvs/tokyo/info_spec.rb
CHANGED
data/spec/kvs/usecase_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,8 @@ require 'rspec'
|
|
4
4
|
require 'ccp'
|
5
5
|
require 'fileutils'
|
6
6
|
|
7
|
+
Ccp::Kvs # force to autoload for tokyocabinet, kyotocabinet
|
8
|
+
|
7
9
|
require File.join(File.dirname(__FILE__), "models")
|
8
10
|
|
9
11
|
|
@@ -17,7 +19,9 @@ RSpec.configure do |config|
|
|
17
19
|
# config.mock_with :rr
|
18
20
|
config.mock_with :rspec
|
19
21
|
|
22
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
20
23
|
config.filter_run :focus => true
|
24
|
+
config.filter_run_excluding :tch unless defined?(TokyoCabinet)
|
21
25
|
config.run_all_when_everything_filtered = true
|
22
26
|
end
|
23
27
|
|
@@ -6,7 +6,7 @@ describe Ccp::Storage do
|
|
6
6
|
Ccp::Storage.should respond_to(:load)
|
7
7
|
end
|
8
8
|
|
9
|
-
describe ".load" do
|
9
|
+
describe ".load", :tch do
|
10
10
|
context "('tmp/foo.json.tch')" do
|
11
11
|
subject { Ccp::Storage.load('tmp/foo.json.tch') }
|
12
12
|
it { should be_kind_of(Ccp::Storage) }
|
@@ -29,13 +29,6 @@ describe Ccp::Storage do
|
|
29
29
|
its(:codec) { should == Ccp::Serializers::Msgpack }
|
30
30
|
end
|
31
31
|
|
32
|
-
context "('tmp/foo.msgpack.kch')" do
|
33
|
-
subject { Ccp::Storage.load('tmp/foo.msgpack.kch') }
|
34
|
-
its(:source) { should == 'tmp/foo.msgpack.kch' }
|
35
|
-
its(:kvs) { should be_kind_of(Ccp::Kvs::Kch) }
|
36
|
-
its(:codec) { should == Ccp::Serializers::Msgpack }
|
37
|
-
end
|
38
|
-
|
39
32
|
context "(pathname)" do
|
40
33
|
subject { Ccp::Storage.load(Pathname('tmp/foo.msgpack.tch')) }
|
41
34
|
its(:source) { should == Pathname('tmp/foo.msgpack.tch') }
|
@@ -44,7 +37,16 @@ describe Ccp::Storage do
|
|
44
37
|
end
|
45
38
|
end
|
46
39
|
|
47
|
-
describe "
|
40
|
+
describe ".load", :kch do
|
41
|
+
context "('tmp/foo.msgpack.kch')" do
|
42
|
+
subject { Ccp::Storage.load('tmp/foo.msgpack.kch') }
|
43
|
+
its(:source) { should == 'tmp/foo.msgpack.kch' }
|
44
|
+
its(:kvs) { should be_kind_of(Ccp::Kvs::Kch) }
|
45
|
+
its(:codec) { should == Ccp::Serializers::Msgpack }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#read", :tch do
|
48
50
|
before { FileUtils.rm_rf(tmp_path) if tmp_path.directory? }
|
49
51
|
|
50
52
|
context "(file)" do
|
@@ -81,7 +83,7 @@ describe Ccp::Storage do
|
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
|
-
describe "#close" do
|
86
|
+
describe "#close", :tch do
|
85
87
|
before { FileUtils.rm_rf(tmp_path) if tmp_path.directory? }
|
86
88
|
|
87
89
|
let(:tch) { tmp_path + "foo.json.tch" }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -123,6 +123,22 @@ dependencies:
|
|
123
123
|
- - ! '>'
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0.4'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: tokyocabinet
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 1.29.1
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.29.1
|
126
142
|
- !ruby/object:Gem::Dependency
|
127
143
|
name: rspec
|
128
144
|
requirement: !ruby/object:Gem::Requirement
|