tarantool 0.2.1 → 0.2.2
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/Gemfile.lock +1 -1
- data/examples/record.rb +7 -0
- data/lib/tarantool.rb +1 -1
- data/lib/tarantool/record.rb +13 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/tarantool/record_spec.rb +13 -0
- data/tarantool.gemspec +2 -2
- metadata +6 -6
data/Gemfile.lock
CHANGED
data/examples/record.rb
CHANGED
@@ -28,6 +28,8 @@ class User < MyTarantool
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
User.tarantool.call
|
32
|
+
|
31
33
|
# Now attribute positions are not important.
|
32
34
|
User.create login: 'prepor', email: 'ceo@prepor.ru', name: 'Andrew'
|
33
35
|
User.create login: 'ruden', name: 'Andrew', email: 'rudenkoco@gmail.com'
|
@@ -48,6 +50,9 @@ end
|
|
48
50
|
# increment field apples_count by one. Its atomic operation vie native Tarantool interface
|
49
51
|
User.find('prepor').increment :apples_count
|
50
52
|
|
53
|
+
# call lua func, which return record's tuples
|
54
|
+
User.call('box.select_range', '0','0', '5')
|
55
|
+
|
51
56
|
# update only dirty attributes
|
52
57
|
user = User.find('prepor')
|
53
58
|
user.name = "Petr"
|
@@ -59,3 +64,5 @@ user.save
|
|
59
64
|
User.find('prepor').info['bio'] # => 'hi!'
|
60
65
|
user.destroy
|
61
66
|
puts "Ok!"
|
67
|
+
|
68
|
+
|
data/lib/tarantool.rb
CHANGED
data/lib/tarantool/record.rb
CHANGED
@@ -13,12 +13,15 @@ class Tarantool
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def each(&blk)
|
16
|
-
|
17
|
-
|
18
|
-
blk.call record.from_server(tuple)
|
16
|
+
to_records(record.space.select(*@tuples, index_no: @index_no, limit: @limit, offset: @offset).tuples).each do |r|
|
17
|
+
blk.call r
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
21
|
+
def call(proc_name, *args)
|
22
|
+
to_records record.space.call(proc_name: proc_name, args: args, return_tuple: true).tuples
|
23
|
+
end
|
24
|
+
|
22
25
|
def limit(limit)
|
23
26
|
@limit = limit
|
24
27
|
self
|
@@ -89,6 +92,12 @@ class Tarantool
|
|
89
92
|
end
|
90
93
|
index_no
|
91
94
|
end
|
95
|
+
|
96
|
+
def to_records(tuples)
|
97
|
+
tuples.map do |tuple|
|
98
|
+
record.from_server(tuple)
|
99
|
+
end
|
100
|
+
end
|
92
101
|
end
|
93
102
|
class Record
|
94
103
|
extend ActiveModel::Naming
|
@@ -164,7 +173,7 @@ class Tarantool
|
|
164
173
|
Select.new(self)
|
165
174
|
end
|
166
175
|
|
167
|
-
%w{where limit offset}.each do |v|
|
176
|
+
%w{where limit offset call first}.each do |v|
|
168
177
|
define_method v do |*args|
|
169
178
|
select.send(v, *args)
|
170
179
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -245,7 +245,20 @@ describe Tarantool::Record do
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe "call" do
|
251
|
+
let(:res) { user.class.select.call('box.select_range', '0','0', '2')}
|
252
|
+
before do
|
253
|
+
user_class.create login: 'prepor', name: 'Andrew', email: 'ceo@prepor.ru'
|
254
|
+
user_class.create login: 'petro', name: 'Petr', email: 'petro@gmail.com'
|
255
|
+
user_class.create login: 'ruden', name: 'Andrew', email: 'rudenkoco@gmail.com'
|
256
|
+
end
|
248
257
|
|
258
|
+
it "should select 2 records and return UserClass instances" do
|
259
|
+
res.size.must_equal 2
|
260
|
+
res.any? { |v| v.is_a? user_class }
|
261
|
+
end
|
249
262
|
end
|
250
263
|
end
|
251
264
|
|
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-
|
7
|
+
s.version = '0.2.2'
|
8
|
+
s.date = '2012-01-30'
|
9
9
|
s.rubyforge_project = 'tarantool'
|
10
10
|
|
11
11
|
s.summary = "Tarantool KV-storage client."
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-30 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: iproto
|
16
|
-
requirement: &
|
16
|
+
requirement: &70164633669320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70164633669320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|
27
|
-
requirement: &
|
27
|
+
requirement: &70164633668620 !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: *
|
38
|
+
version_requirements: *70164633668620
|
39
39
|
description: Tarantool KV-storage client.
|
40
40
|
email: ceo@prepor.ru
|
41
41
|
executables: []
|