activetokyocabinet 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/active_record/connection_adapters/tokyocabinet_adapter.rb +32 -0
- data/lib/active_record/connection_adapters/tokyotyrant_adapter.rb +37 -1
- data/lib/active_tokyocabinet/sqlparser.tab.rb +232 -216
- data/lib/active_tokyocabinet/sqlparser.y +16 -9
- data/lib/active_tokyocabinet/tdb.rb +4 -0
- data/spec/spec_helper.rb +53 -20
- data/spec/tcspec2ttspec.sh +2 -0
- data/spec/tokyocabinet_spec.rb +481 -0
- data/spec/tokyotyrant_spec.rb +481 -0
- metadata +4 -2
- data/spec/activetokyocabinet_spec.rb +0 -260
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activetokyocabinet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
@@ -37,10 +37,12 @@ files:
|
|
37
37
|
- lib/active_tokyocabinet/tdb.rb
|
38
38
|
- lib/active_tokyocabinet/sqlparser.y
|
39
39
|
- lib/active_tokyocabinet/sqlparser.tab.rb
|
40
|
-
- spec/
|
40
|
+
- spec/tokyotyrant_spec.rb
|
41
41
|
- spec/models/department.rb
|
42
42
|
- spec/models/employee.rb
|
43
43
|
- spec/spec_helper.rb
|
44
|
+
- spec/tokyocabinet_spec.rb
|
45
|
+
- spec/tcspec2ttspec.sh
|
44
46
|
- README
|
45
47
|
has_rdoc: true
|
46
48
|
homepage: http://activetokyocabi.rubyforge.org/
|
@@ -1,260 +0,0 @@
|
|
1
|
-
$wd = File.dirname(File.expand_path(__FILE__))
|
2
|
-
ENV['RUBYLIB'] = "#{$wd}/../lib"
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
include SpecHelper
|
6
|
-
include ActiveTokyoCabinetSpec
|
7
|
-
|
8
|
-
describe 'tokyocabinet:' do
|
9
|
-
before do
|
10
|
-
TokyoCabinetSpec.establish_connection
|
11
|
-
TokyoCabinetSpec.create_tables
|
12
|
-
TokyoCabinetSpec.setup_employee
|
13
|
-
TokyoCabinetSpec.setup_department
|
14
|
-
end
|
15
|
-
|
16
|
-
it "employees length > 0" do
|
17
|
-
employees = Employee.find(:all)
|
18
|
-
employees.length.should == employee_data.length
|
19
|
-
end
|
20
|
-
|
21
|
-
it "employees has a one data (ename = 'SMITH')" do
|
22
|
-
employees = Employee.find(:all, :conditions => ['ename = ?', 'SMITH'])
|
23
|
-
employees.length.should == 1
|
24
|
-
data = employee_data.find {|i| i[EMP_ENAME] == 'SMITH' }
|
25
|
-
validate_employee(data, employees[0])
|
26
|
-
end
|
27
|
-
|
28
|
-
it "employees has a one data (empno = 7521)" do
|
29
|
-
employees = Employee.find(:all, :conditions => ['empno = ?', 7521])
|
30
|
-
employees.length.should == 1
|
31
|
-
data = employee_data.find {|i| i[EMP_EMPNO] == 7521 }
|
32
|
-
validate_employee(data, employees[0])
|
33
|
-
end
|
34
|
-
|
35
|
-
it "employees has no data (ename = 'SMITH' and job = 'SALESMAN')" do
|
36
|
-
employees = Employee.find(:all, :conditions => ['ename = ? and job = ?', 'SMITH', 'SALESMAN'])
|
37
|
-
employees.should be_empty
|
38
|
-
end
|
39
|
-
|
40
|
-
it "employees a one data (ename = 'TURNER' and job = 'SALESMAN')" do
|
41
|
-
employees = Employee.find(:all, :conditions => ['ename = ? and job = ?', 'TURNER', 'SALESMAN'])
|
42
|
-
employees.length.should == 1
|
43
|
-
data = employee_data.find {|i| i[EMP_ENAME] == 'TURNER' and i[EMP_JOB] == 'SALESMAN' }
|
44
|
-
validate_employee(data, employees[0])
|
45
|
-
end
|
46
|
-
|
47
|
-
it "employees a one data ({:ename => 'TURNER', :job => 'SALESMAN'})" do
|
48
|
-
employees = Employee.find(:all, :conditions => {:ename => 'TURNER', :job => 'SALESMAN'})
|
49
|
-
employees.length.should == 1
|
50
|
-
data = employee_data.find {|i| i[EMP_ENAME] == 'TURNER' and i[EMP_JOB] == 'SALESMAN' }
|
51
|
-
validate_employee(data, employees[0])
|
52
|
-
end
|
53
|
-
|
54
|
-
it "employees has any data" do
|
55
|
-
employee_data.each_with_index do |data, i|
|
56
|
-
employee_id = i + 1
|
57
|
-
employee = Employee.find(employee_id)
|
58
|
-
|
59
|
-
employee.should_not be_nil
|
60
|
-
employee.id.should == employee_id
|
61
|
-
validate_employee(data, employee)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "employees has any data (job = 'SALESMAN')" do
|
66
|
-
employees = Employee.find(:all, :conditions => ['job = ?', 'SALESMAN'])
|
67
|
-
|
68
|
-
employees.each do |employee|
|
69
|
-
data = employee_data[employee.id - 1]
|
70
|
-
|
71
|
-
data.should_not be_nil
|
72
|
-
data[EMP_JOB].should == 'SALESMAN'
|
73
|
-
validate_employee(data, employee)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
it "employees has any data (id=1,2,3)" do
|
78
|
-
employees = Employee.find([1, 2, 3])
|
79
|
-
employees.length.should == 3
|
80
|
-
|
81
|
-
employee_data[0..2].each_with_index do |data, i|
|
82
|
-
empno, ename, job, mgr, hiredate, sal, comm, deptno = data
|
83
|
-
employee_id = i + 1
|
84
|
-
employee = employees.find {|i| i.id == employee_id }
|
85
|
-
|
86
|
-
employee.should_not be_nil
|
87
|
-
employee.id.should == employee_id
|
88
|
-
validate_employee(data, employee)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it "employees has any data (order by ename desc limit 3)" do
|
93
|
-
employees = Employee.find(:all, :order => 'ename desc', :limit => 3)
|
94
|
-
employees.length.should == 3
|
95
|
-
|
96
|
-
employee_data.sort_by {|i| i[EMP_ENAME] || '' }.reverse[0..2].each do |data|
|
97
|
-
employee = employees.find {|i| i.id == data.id }
|
98
|
-
employee.should_not be_nil
|
99
|
-
validate_employee(data, employee)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
it "employees has any data (order by ename desc limit 4 offset 5)" do
|
104
|
-
employees = Employee.find(:all, :order => 'ename desc', :limit => 4, :offset => 5)
|
105
|
-
employees.length.should == 4
|
106
|
-
|
107
|
-
employee_data.sort_by {|i| i[EMP_ENAME] || '' }.reverse[5..8].each do |data|
|
108
|
-
employee = employees.find {|i| i.id == data.id }
|
109
|
-
employee.should_not be_nil
|
110
|
-
validate_employee(data, employee)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
it "employees has any data ([])" do
|
115
|
-
employee_data.each_with_index do |data, i|
|
116
|
-
empno, ename, job, mgr, hiredate, sal, comm, deptno = data
|
117
|
-
employee_id = i + 1
|
118
|
-
employee = Employee.find(employee_id)
|
119
|
-
|
120
|
-
employee.should_not be_nil
|
121
|
-
employee[:id].should == employee_id
|
122
|
-
employee[:empno].should == empno.to_s
|
123
|
-
employee[:ename].should == ename.to_s
|
124
|
-
employee[:job].should == job.to_s
|
125
|
-
employee[:mgr].should == mgr.to_s
|
126
|
-
employee[:hiredate].should == hiredate.to_s
|
127
|
-
employee[:sal].should == sal.to_s
|
128
|
-
employee[:comm].should == comm.to_s
|
129
|
-
employee[:deptno].should == deptno.to_s
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# -------------------------------------------------------------------
|
134
|
-
|
135
|
-
it "departments length > 0" do
|
136
|
-
departments = Department.find(:all)
|
137
|
-
departments.length.should == department_data.length
|
138
|
-
end
|
139
|
-
|
140
|
-
it "departments has a one data (dname = 'SALES')" do
|
141
|
-
departments = Department.find(:all, :conditions => ['dname = ?', 'SALES'])
|
142
|
-
departments.length.should == 1
|
143
|
-
data = department_data.find {|i| i[DEPT_DNAME] == 'SALES' }
|
144
|
-
validate_department(data, departments[0])
|
145
|
-
end
|
146
|
-
|
147
|
-
it "departments has a one data (deptno = 20)" do
|
148
|
-
departments = Department.find(:all, :conditions => ['deptno = ?', 20])
|
149
|
-
departments.length.should == 1
|
150
|
-
data = department_data.find {|i| i[DEPT_DEPTNO] == 20 }
|
151
|
-
validate_department(data, departments[0])
|
152
|
-
end
|
153
|
-
|
154
|
-
it "departments has no data (deptno = 20 and loc = 'BOSTON')" do
|
155
|
-
departments = Department.find(:all, :conditions => ['deptno = ? and loc = ?', 20, 'BOSTON'])
|
156
|
-
departments.should be_empty
|
157
|
-
end
|
158
|
-
|
159
|
-
it "departments has a one data (deptno = 40 and loc = 'BOSTON')" do
|
160
|
-
departments = Department.find(:all, :conditions => ['deptno = ? and loc = ?', 40, 'BOSTON'])
|
161
|
-
departments.length.should == 1
|
162
|
-
data = department_data.find {|i| i[DEPT_DEPTNO] == 40 and i[DEPT_LOC] == 'BOSTON' }
|
163
|
-
validate_department(data, departments[0])
|
164
|
-
end
|
165
|
-
|
166
|
-
it "departments has a one data ({:deptno => 40. :loc => 'BOSTON'})" do
|
167
|
-
departments = Department.find(:all, :conditions => {:deptno => 40, :loc => 'BOSTON'})
|
168
|
-
departments.length.should == 1
|
169
|
-
data = department_data.find {|i| i[DEPT_DEPTNO] == 40 and i[DEPT_LOC] == 'BOSTON' }
|
170
|
-
validate_department(data, departments[0])
|
171
|
-
end
|
172
|
-
|
173
|
-
it "departments has any data" do
|
174
|
-
department_data.each_with_index do |data, i|
|
175
|
-
department_id = i + 1
|
176
|
-
department = Department.find(department_id)
|
177
|
-
|
178
|
-
department.should_not be_nil
|
179
|
-
department.id.should == department_id
|
180
|
-
validate_department(data, department)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
it "departments has any data ([])" do
|
185
|
-
department_data.each_with_index do |data, i|
|
186
|
-
deptno, dname, loc = data
|
187
|
-
department_id = i + 1
|
188
|
-
department = Department.find(department_id)
|
189
|
-
|
190
|
-
department.should_not be_nil
|
191
|
-
department[:id].should == department_id
|
192
|
-
department[:deptno].should == deptno.to_s
|
193
|
-
department[:dname].should == dname.to_s
|
194
|
-
department[:loc].should == loc.to_s
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
it "department has any data (loc in ('NEW YORK', 'CHICAGO'))" do
|
199
|
-
departments = Department.find(:all, :conditions => ['loc in (?)', ['NEW YORK', 'CHICAGO']])
|
200
|
-
|
201
|
-
departments.each do |department|
|
202
|
-
data = department_data[department.id - 1]
|
203
|
-
|
204
|
-
data.should_not be_nil
|
205
|
-
validate_department(data, department)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
it "department has any data ({:loc => ['NEW YORK', 'CHICAGO']})" do
|
210
|
-
departments = Department.find(:all, :conditions => {:loc => ['NEW YORK', 'CHICAGO']})
|
211
|
-
|
212
|
-
departments.each do |department|
|
213
|
-
data = department_data[department.id - 1]
|
214
|
-
|
215
|
-
data.should_not be_nil
|
216
|
-
['NEW YORK', 'CHICAGO'].should include(data[DEPT_LOC])
|
217
|
-
validate_department(data, department)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
it "departments has any data (id=1,2,3)" do
|
222
|
-
departments = Department.find([1, 2, 3])
|
223
|
-
departments.length.should == 3
|
224
|
-
|
225
|
-
department_data[0..2].each_with_index do |data, i|
|
226
|
-
deptno, dname, loc = data
|
227
|
-
department_id = i + 1
|
228
|
-
department = departments.find {|i| i.id == department_id }
|
229
|
-
|
230
|
-
department.should_not be_nil
|
231
|
-
validate_department(data, department)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
it "departments has any data (order by deptno numdesc limit 65535 offset 1)" do
|
236
|
-
departments = Department.find(:all, :order => 'deptno numdesc', :limit => 65535, :offset => 1)
|
237
|
-
departments.length.should == department_data.length - 1
|
238
|
-
|
239
|
-
department_data.sort_by {|i| i[DEPT_DEPTNO] || 0 }.reverse[1..-1].each do |data|
|
240
|
-
department = departments.find {|i| i.id == data.id }
|
241
|
-
department.should_not be_nil
|
242
|
-
validate_department(data, department)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
it "departments has any data (order by deptno numasc)" do
|
247
|
-
departments = Department.find(:all, :order => 'deptno numasc')
|
248
|
-
departments.length.should == department_data.length
|
249
|
-
|
250
|
-
department_data.sort_by {|i| i[DEPT_DEPTNO] || 0 }.each do |data|
|
251
|
-
department = departments.find {|i| i.id == data.id }
|
252
|
-
department.should_not be_nil
|
253
|
-
validate_department(data, department)
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
after do
|
258
|
-
TokyoCabinetSpec.clean
|
259
|
-
end
|
260
|
-
end
|