genki-kyototycoon 0.6.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,132 @@
1
+ # -- coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
4
+
5
+ describe KyotoTycoon do
6
+ [:U, :B].each{|colenc|
7
+ context "colenc=#{colenc}" do
8
+ before(:each) do
9
+ @kt.colenc = colenc
10
+ end
11
+
12
+ [:default, :msgpack].each{|serializer|
13
+ context "serializer=#{serializer}" do
14
+ before(:each) do
15
+ @kt.serializer = serializer
16
+ end
17
+
18
+ it 'should provide simple kvs feature' do
19
+ @kt.set('a', 'b')
20
+ @kt.get('a').should == 'b'
21
+ @kt['foo'] = 'bar'
22
+ @kt['foo'].should == 'bar'
23
+ @kt.delete('foo')
24
+ @kt['foo'].should be_nil
25
+
26
+ @kt.add('123', '123')
27
+ @kt['123'].should == '123'
28
+ @kt.replace('123', '456')
29
+ @kt['123'].should == '456'
30
+ @kt.clear
31
+ @kt.report['db_total_count'].to_i.should == 0
32
+ @kt.status['count'].to_i.should == 0
33
+
34
+ @kt['foo'] = 'oldbaz'
35
+ @kt.cas('foo', 'oldbaz', 'newbaz').should be_true
36
+ @kt.cas('foo', 'oldbaz', 'newbaz').should be_false
37
+ @kt.get('foo').should == 'newbaz'
38
+ @kt.clear
39
+
40
+ @kt['foo'] ||= 'aaa'
41
+ @kt['foo'] ||= 'bbb'
42
+ @kt['foo'].should == 'aaa'
43
+ @kt.clear
44
+
45
+ @kt[:a] = 1
46
+ @kt[:b] = 1
47
+ @kt.keys.sort.should == %w!a b!.sort
48
+ @kt.clear
49
+
50
+ @kt[:longvalue] = "-" * 2048
51
+ @kt[:longvalue].should == '-' * 2048
52
+ end
53
+
54
+ it 'should provide bulk' do
55
+ data = {}
56
+ 10.times{|n|
57
+ data[n.to_s] = n.to_s
58
+ }
59
+ @kt.set_bulk(data)
60
+ @kt.get_bulk(data.keys).sort.should == data.sort
61
+ @kt.remove_bulk(data.keys)
62
+ @kt.get_bulk(data.keys).should == {}
63
+ end
64
+
65
+ it 'should can handle strange key/value' do
66
+ # '+' is known ambiguity key on URL encode/decode processing
67
+ %w!a\tb a\nb a\r\nb a*-b a^@b!.each{|outlaw|
68
+ @kt[outlaw] = outlaw
69
+ @kt[outlaw].should == outlaw
70
+ }
71
+ end
72
+
73
+ it 'should provide delete variation' do
74
+ build = lambda {|kt|
75
+ kt.clear
76
+ kt.set_bulk({
77
+ :a => 1,
78
+ :b => 1,
79
+ :c => 1,
80
+ })
81
+ }
82
+ build.call(@kt)
83
+ @kt.delete('a','b')
84
+ @kt.keys.should == ['c']
85
+
86
+ build.call(@kt)
87
+ @kt.delete(['a', 'b'])
88
+ @kt.keys.should == ['c']
89
+ end
90
+
91
+ it 'should increment' do
92
+ @kt.increment('foo').should == 1
93
+ @kt.increment('foo').should == 2
94
+ @kt.increment('foo').should == 3
95
+ @kt.increment('foo', 10).should == 13
96
+ @kt.increment('foo', -10).should == 3
97
+ @kt.decrement('foo', 5).should == -2
98
+ @kt.incr('foo', 5).should == 3
99
+ @kt.decr('foo', 5).should == -2
100
+ end
101
+
102
+ it 'should provide status/report' do
103
+ @kt[:a] = 1
104
+ @kt[:b] = 2
105
+ @kt.report['db_total_count'].to_i.should == 2
106
+ @kt.status['count'].to_i.should == 2
107
+ end
108
+
109
+ it 'should match prefixes' do
110
+ @kt['123'] = 1
111
+ @kt['124'] = 1
112
+ @kt['125'] = 1
113
+ @kt['999'] = 1
114
+ @kt['9999'] = 1
115
+ @kt.match_prefix("12").sort.should == %w!123 124 125!.sort
116
+ @kt.match_prefix("9").sort.should == %w!999 9999!.sort
117
+ @kt.match_prefix("9999").sort.should == %w!9999!
118
+ @kt.match_regex(/^12/).sort.should == %w!123 124 125!.sort
119
+ @kt.match_regex(/^9+$/).sort.should == %w!999 9999!.sort
120
+ end
121
+
122
+ if serializer == :msgpack
123
+ it 'should keep variable type(int) with msgpack' do
124
+ @kt["foo"] = 42
125
+ @kt["foo"].should == 42
126
+ end
127
+ end
128
+ end
129
+ }
130
+ end
131
+ }
132
+ end
@@ -0,0 +1,37 @@
1
+ # -- coding: utf-8
2
+
3
+ =begin
4
+
5
+ !!!!!!!!!!!!!
6
+ !! CAUTION !!
7
+ !!!!!!!!!!!!!
8
+
9
+ This script access http://0.0.0.0:19999/ and destroy all records.
10
+ Be carefully for run, and run `ktserver -port 19999 '%'` before testing.
11
+
12
+ =end
13
+
14
+ unless ENV["COV"].nil?
15
+ require "simplecov"
16
+ SimpleCov.start
17
+ end
18
+
19
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib")
20
+ require "rubygems"
21
+ require "kyototycoon.rb"
22
+ require "kyototycoon/stream.rb"
23
+
24
+ RSpec.configure do |conf|
25
+ conf.before(:all) do
26
+ @kt = KyotoTycoon.new('0.0.0.0', 19999)
27
+ @kt.serializer=:default # or :msgpack
28
+ @kt.logger=nil
29
+ end
30
+
31
+ conf.before(:each) do
32
+ end
33
+
34
+ conf.after(:each) do
35
+ @kt.clear
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genki-kyototycoon
3
+ version: !ruby/object:Gem::Version
4
+ hash: 125
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 0
10
+ - 1
11
+ version: 0.6.0.1
12
+ platform: ruby
13
+ authors:
14
+ - uu59
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-08-10 00:00:00 +09:00
20
+ default_executable: kyototycoon-console
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: msgpack
24
+ prerelease: false
25
+ type: :runtime
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 3
32
+ segments:
33
+ - 0
34
+ version: "0"
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ prerelease: false
39
+ type: :development
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 11
46
+ segments:
47
+ - 2
48
+ - 1
49
+ - 0
50
+ version: 2.1.0
51
+ requirement: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: bundler
54
+ prerelease: false
55
+ type: :development
56
+ version_requirements: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 23
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 0
66
+ version: 1.0.0
67
+ requirement: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: jeweler
70
+ prerelease: false
71
+ type: :development
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 1
78
+ segments:
79
+ - 1
80
+ - 5
81
+ - 1
82
+ version: 1.5.1
83
+ requirement: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: simplecov
86
+ prerelease: false
87
+ type: :development
88
+ version_requirements: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ requirement: *id005
98
+ description: KyotoTycoon client for Ruby
99
+ email: k@uu59.org
100
+ executables:
101
+ - kyototycoon-console
102
+ extensions: []
103
+
104
+ extra_rdoc_files:
105
+ - README.markdown
106
+ files:
107
+ - .gitignore
108
+ - Changes.md
109
+ - Gemfile
110
+ - Gemfile.lock
111
+ - MIT-LICENSE
112
+ - README.markdown
113
+ - Rakefile
114
+ - VERSION
115
+ - benchmark/bulk.rb
116
+ - benchmark/bulk_bigdata.rb
117
+ - benchmark/getset.rb
118
+ - benchmark/getset_while_1sec.rb
119
+ - benchmark/helper.rb
120
+ - bin/kyototycoon-console
121
+ - kyototycoon.gemspec
122
+ - lib/kyototycoon.rb
123
+ - lib/kyototycoon/cursor.rb
124
+ - lib/kyototycoon/serializer.rb
125
+ - lib/kyototycoon/serializer/default.rb
126
+ - lib/kyototycoon/serializer/msgpack.rb
127
+ - lib/kyototycoon/stream.rb
128
+ - lib/kyototycoon/tsvrpc.rb
129
+ - lib/kyototycoon/tsvrpc/skinny.rb
130
+ - spec/connect_spec.rb
131
+ - spec/cursor_spec.rb
132
+ - spec/ktslave.txt
133
+ - spec/options_spec.rb
134
+ - spec/spec_helper.rb
135
+ has_rdoc: true
136
+ homepage: http://github.com/uu59/kyototycoon-ruby
137
+ licenses:
138
+ - MIT
139
+ post_install_message:
140
+ rdoc_options: []
141
+
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ hash: 3
150
+ segments:
151
+ - 0
152
+ version: "0"
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ hash: 3
159
+ segments:
160
+ - 0
161
+ version: "0"
162
+ requirements: []
163
+
164
+ rubyforge_project:
165
+ rubygems_version: 1.6.2
166
+ signing_key:
167
+ specification_version: 3
168
+ summary: KyotoTycoon client for Ruby
169
+ test_files:
170
+ - spec/connect_spec.rb
171
+ - spec/cursor_spec.rb
172
+ - spec/ktslave.txt
173
+ - spec/options_spec.rb
174
+ - spec/spec_helper.rb