tarantool 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tarantool (0.1.1)
4
+ tarantool (0.2)
5
5
  activemodel (>= 3.1, < 4.0)
6
- iproto (>= 0.1)
6
+ iproto (>= 0.2)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
@@ -23,7 +23,7 @@ GEM
23
23
  eventmachine (>= 1.0.0.beta.1)
24
24
  eventmachine (1.0.0.beta.4)
25
25
  i18n (0.6.0)
26
- iproto (0.1)
26
+ iproto (0.2)
27
27
  linecache19 (0.5.12)
28
28
  ruby_core_source (>= 0.1.4)
29
29
  multi_json (1.0.3)
data/README.md CHANGED
@@ -38,15 +38,14 @@ To use EventMachine pass type: em in options:
38
38
 
39
39
  ```ruby
40
40
  require 'em-synchrony'
41
- DB = Tarantool.new host: 'locahost', port: 33013
42
- space = DB.space 0
41
+ DB = Tarantool.new host: 'locahost', port: 33013, type: :em
43
42
  EM.synchrony do
44
- Fiber.new do
45
- space.insert 'prepor', 'Andrew', 'ceo@prepor.ru'
46
- res = space.select 'prepor'
47
- puts "Name: #{res.tuple[1].to_s}; Email: #{res.tuple[2].to_s}"
48
- space.delete 'prepor'
49
- end.resume
43
+ space = DB.space 0
44
+ space.insert 'prepor', 'Andrew', 'ceo@prepor.ru'
45
+ res = space.select 'prepor'
46
+ puts "Name: #{res.tuple[1].to_s}; Email: #{res.tuple[2].to_s}"
47
+ space.delete 'prepor'
48
+ EM.stop
50
49
  end
51
50
  ```
52
51
 
@@ -5,14 +5,12 @@ Bundler.setup
5
5
  require 'tarantool'
6
6
 
7
7
  require 'em-synchrony'
8
- DB = Tarantool.new host: 'localhost', port: 33013
9
- space = DB.space 0
8
+ DB = Tarantool.new host: 'localhost', port: 33013, type: :em
10
9
  EM.synchrony do
11
- Fiber.new do
12
- space.insert 'prepor', 'Andrew', 'ceo@prepor.ru'
13
- res = space.select 'prepor'
14
- puts "Name: #{res.tuple[1].to_s}; Email: #{res.tuple[2].to_s}"
15
- space.delete 'prepor'
16
- EM.stop
17
- end.resume
10
+ space = DB.space 0
11
+ space.insert 'prepor', 'Andrew', 'ceo@prepor.ru'
12
+ res = space.select 'prepor'
13
+ puts "Name: #{res.tuple[1].to_s}; Email: #{res.tuple[2].to_s}"
14
+ space.delete 'prepor'
15
+ EM.stop
18
16
  end
data/lib/tarantool.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'iproto'
3
3
 
4
4
  class Tarantool
5
- VERSION = '0.2'
5
+ VERSION = '0.2.1'
6
6
 
7
7
  require 'tarantool/space'
8
8
  require 'tarantool/requests'
@@ -47,7 +47,7 @@ class Tarantool
47
47
  end
48
48
 
49
49
  def perform
50
- data = connection.send_packet request_id, make_packet(make_body)
50
+ data = connection.send_request self.class.request_type, make_body
51
51
  make_response data
52
52
  end
53
53
 
@@ -55,17 +55,8 @@ class Tarantool
55
55
 
56
56
  end
57
57
 
58
- def request_id
59
- @request_id ||= connection.next_request_id
60
- end
61
-
62
- def make_packet(body)
63
- [self.class.request_type, body.size, request_id].pack('LLL') +
64
- body
65
- end
66
-
67
58
  def make_response(data)
68
- return_code, = data[0,4].unpack('L')
59
+ return_code, = data[0,4].unpack('L')
69
60
  if return_code == 0
70
61
  Response.new(data[4, data.size], response_params)
71
62
  else
@@ -9,15 +9,13 @@ describe "Tarantool with EM" do
9
9
  describe "insert, select and delete" do
10
10
  it "should insert tuple and return it" do
11
11
  EM.synchrony do
12
- Fiber.new do
13
- space.insert 100, 'привет', return_tuple: true
14
- res = space.select 100
15
- int, string = res.tuple
16
- int.to_i.must_equal 100
17
- string.to_s.must_equal 'привет'
18
- space.delete 100
19
- EM.stop
20
- end.resume
12
+ space.insert 100, 'привет', return_tuple: true
13
+ res = space.select 100
14
+ int, string = res.tuple
15
+ int.to_i.must_equal 100
16
+ string.to_s.must_equal 'привет'
17
+ space.delete 100
18
+ EM.stop
21
19
  end
22
20
  end
23
21
  end
@@ -31,17 +31,6 @@ describe Tarantool::Request do
31
31
  end
32
32
  end
33
33
 
34
- describe "instance" do
35
- let(:request) { Tarantool::Requests::Insert.new space }
36
-
37
- it "should make packet with right request type, body size and next request id + body" do
38
- body = 'hi'
39
- expect = [Tarantool::Requests::REQUEST_TYPES[:insert], body.bytesize, request.request_id].pack('LLL') + body
40
- request.make_packet(body).must_equal expect
41
- end
42
-
43
- end
44
-
45
34
  describe "requests" do
46
35
  include Helpers::Truncate
47
36
  describe "insert and select" do
data/tarantool.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'tarantool'
7
- s.version = '0.2'
8
- s.date = '2012-01-23'
7
+ s.version = '0.2.1'
8
+ s.date = '2012-01-27'
9
9
  s.rubyforge_project = 'tarantool'
10
10
 
11
11
  s.summary = "Tarantool KV-storage client."
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.rdoc_options = ["--charset=UTF-8"]
21
21
  s.extra_rdoc_files = %w[README.md LICENSE]
22
22
 
23
- s.add_dependency('iproto', [">= 0.1"])
23
+ s.add_dependency('iproto', [">= 0.2"])
24
24
  s.add_dependency('activemodel', [">= 3.1", "< 4.0"])
25
25
 
26
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarantool
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-23 00:00:00.000000000Z
12
+ date: 2012-01-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: iproto
16
- requirement: &70163621772280 !ruby/object:Gem::Requirement
16
+ requirement: &70184618798480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0.1'
21
+ version: '0.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70163621772280
24
+ version_requirements: *70184618798480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activemodel
27
- requirement: &70163613525100 !ruby/object:Gem::Requirement
27
+ requirement: &70184618796360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: '4.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *70163613525100
38
+ version_requirements: *70184618796360
39
39
  description: Tarantool KV-storage client.
40
40
  email: ceo@prepor.ru
41
41
  executables: []