From 8f5744c97c26831c82e9283216f32790cb437383 Mon Sep 17 00:00:00 2001 From: Andrew rudenko Date: Fri, 27 Jan 2012 12:47:25 +0400 Subject: [PATCH] iproto updated --- Gemfile.lock | 4 ++-- lib/tarantool.rb | 2 +- lib/tarantool/request.rb | 13 ++----------- spec/tarantool/request_spec.rb | 11 ----------- tarantool.gemspec | 6 +++--- 5 files changed, 8 insertions(+), 28 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3f7c194..d4fd646 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ PATH specs: tarantool (0.2) activemodel (>= 3.1, < 4.0) - iproto (>= 0.1) + iproto (>= 0.2) GEM remote: http://rubygems.org/ @@ -23,7 +23,7 @@ GEM eventmachine (>= 1.0.0.beta.1) eventmachine (1.0.0.beta.4) i18n (0.6.0) - iproto (0.1) + iproto (0.2) linecache19 (0.5.12) ruby_core_source (>= 0.1.4) multi_json (1.0.3) diff --git a/lib/tarantool.rb b/lib/tarantool.rb index a13a801..458aad1 100644 --- a/lib/tarantool.rb +++ b/lib/tarantool.rb @@ -2,7 +2,7 @@ require 'iproto' class Tarantool - VERSION = '0.2' + VERSION = '0.2.1' require 'tarantool/space' require 'tarantool/requests' diff --git a/lib/tarantool/request.rb b/lib/tarantool/request.rb index 1e11bd6..9f52ce8 100644 --- a/lib/tarantool/request.rb +++ b/lib/tarantool/request.rb @@ -47,7 +47,7 @@ def initialize(space, *args) end def perform - data = connection.send_packet request_id, make_packet(make_body) + data = connection.send_request self.class.request_type, make_body make_response data end @@ -55,17 +55,8 @@ def parse_args end - def request_id - @request_id ||= connection.next_request_id - end - - def make_packet(body) - [self.class.request_type, body.size, request_id].pack('LLL') + - body - end - def make_response(data) - return_code, = data[0,4].unpack('L') + return_code, = data[0,4].unpack('L') if return_code == 0 Response.new(data[4, data.size], response_params) else diff --git a/spec/tarantool/request_spec.rb b/spec/tarantool/request_spec.rb index b4bf0a6..f741fe0 100644 --- a/spec/tarantool/request_spec.rb +++ b/spec/tarantool/request_spec.rb @@ -31,17 +31,6 @@ def space end end - describe "instance" do - let(:request) { Tarantool::Requests::Insert.new space } - - it "should make packet with right request type, body size and next request id + body" do - body = 'hi' - expect = [Tarantool::Requests::REQUEST_TYPES[:insert], body.bytesize, request.request_id].pack('LLL') + body - request.make_packet(body).must_equal expect - end - - end - describe "requests" do include Helpers::Truncate describe "insert and select" do diff --git a/tarantool.gemspec b/tarantool.gemspec index cc61eb8..f68de3c 100644 --- a/tarantool.gemspec +++ b/tarantool.gemspec @@ -4,8 +4,8 @@ Gem::Specification.new do |s| s.rubygems_version = '1.3.5' s.name = 'tarantool' - s.version = '0.2' - s.date = '2012-01-23' + s.version = '0.2.1' + s.date = '2012-01-27' s.rubyforge_project = 'tarantool' s.summary = "Tarantool KV-storage client." @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.rdoc_options = ["--charset=UTF-8"] s.extra_rdoc_files = %w[README.md LICENSE] - s.add_dependency('iproto', [">= 0.1"]) + s.add_dependency('iproto', [">= 0.2"]) s.add_dependency('activemodel', [">= 3.1", "< 4.0"])