ccp 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/ccp.gemspec CHANGED
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
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
- s.add_runtime_dependency "yajl-ruby"
33
- s.add_runtime_dependency "msgpack", "> 0.4"
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
- s.add_development_dependency "tokyocabinet", "~> 1.29.1"
37
- s.add_development_dependency "kyotocabinet-ruby", "~> 1.27.1"
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
- if @db.error.is_a?(KyotoCabinet::Error::XNOREC)
22
- return nil
23
- else
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[k.to_s] = val or
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
@@ -1,3 +1,3 @@
1
1
  module Ccp
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -2,7 +2,8 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  codecs = %w( json msgpack )
5
- exts = %w( tch kch )
5
+ exts = %w( kch )
6
+ exts << "tch" if defined?(TokyoCabinet)
6
7
 
7
8
  codecs.product(exts).each do |codec, ext|
8
9
  klass = Ccp::Kvs[ext]
data/spec/kvs/kvs_spec.rb CHANGED
@@ -2,7 +2,8 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  kvs_args = {}
5
- kvs_args["tch"] = "#{tmp_path}/kvs/foo.tch"
5
+
6
+ kvs_args["tch"] = "#{tmp_path}/kvs/foo.tch" if defined?(TokyoCabinet)
6
7
  kvs_args["kch"] = "#{tmp_path}/kvs/foo.kch"
7
8
 
8
9
  Ccp::Kvs.each do |klass|
@@ -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
  ######################################################################
@@ -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.tch") }.to raise_error(/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( tch kch )
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}"
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
 
4
- describe Ccp::Kvs::Tokyo::Cabinet do
4
+ describe "Ccp::Kvs::Tokyo::Cabinet", :tch do
5
5
  let(:tmp) { tmp_path + "kvs/tokyo/cabinet" }
6
6
  let(:tch) { tmp + "foo.tch" }
7
7
  let(:kvs) { subject }
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
 
4
- describe Ccp::Kvs::Tokyo::Info do
4
+ describe "Ccp::Kvs::Tokyo::Info", :tch do
5
5
  let(:tmp) { tmp_path + "kvs/tokyo/info" }
6
6
  before { FileUtils.rm_rf(tmp) if tmp.directory? }
7
7
 
@@ -2,7 +2,8 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  codecs = %w( json msgpack )
5
- exts = %w( tch kch )
5
+ exts = %w( kch )
6
+ exts << "tch" if defined?(TokyoCabinet)
6
7
 
7
8
  codecs.product(exts).each do |codec, ext|
8
9
  klass = Ccp::Kvs[ext]
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 "#read" do
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" }
@@ -2,7 +2,8 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  codecs = %w( json msgpack )
5
- exts = %w( tch kch )
5
+ exts = %w( kch )
6
+ exts << "tch" if defined?(TokyoCabinet)
6
7
 
7
8
  codecs.product(exts).each do |codec, ext|
8
9
  dir = "foo.#{codec}.#{ext}"
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.0
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-25 00:00:00.000000000 Z
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