ashikawa-core 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +2 -0
- data/CONTRIBUTING.md +5 -8
- data/Guardfile +1 -1
- data/README.md +15 -1
- data/Rakefile +45 -12
- data/ashikawa-core.gemspec +13 -6
- data/lib/ashikawa-core/collection.rb +24 -160
- data/lib/ashikawa-core/connection.rb +64 -38
- data/lib/ashikawa-core/cursor.rb +15 -9
- data/lib/ashikawa-core/database.rb +5 -12
- data/lib/ashikawa-core/document.rb +13 -10
- data/lib/ashikawa-core/exceptions/document_not_found.rb +4 -1
- data/lib/ashikawa-core/exceptions/no_collection_provided.rb +11 -0
- data/lib/ashikawa-core/index.rb +6 -6
- data/lib/ashikawa-core/query.rb +251 -0
- data/lib/ashikawa-core/version.rb +1 -1
- data/spec/{integration → acceptance}/arango_helper.rb +1 -1
- data/spec/{integration → acceptance}/basic_spec.rb +4 -4
- data/spec/{integration → acceptance}/index_spec.rb +1 -1
- data/spec/acceptance/query_spec.rb +90 -0
- data/spec/{integration → acceptance}/spec_helper.rb +0 -0
- data/spec/{integration_auth → acceptance_auth}/arango_helper.rb +1 -1
- data/spec/{integration_auth → acceptance_auth}/auth_spec.rb +1 -1
- data/spec/{integration_auth → acceptance_auth}/spec_helper.rb +0 -0
- data/spec/fixtures/query/valid.json +5 -0
- data/spec/setup/arangodb.sh +68 -0
- data/spec/unit/collection_spec.rb +43 -143
- data/spec/unit/database_spec.rb +10 -14
- data/spec/unit/exception_spec.rb +14 -0
- data/spec/unit/query_spec.rb +215 -0
- data/spec/unit/spec_helper.rb +7 -1
- metadata +107 -30
- data/spec/integration/query_spec.rb +0 -78
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ashikawa-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-11-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
requirements:
|
36
36
|
- - ~>
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 2.2.
|
38
|
+
version: 2.2.2
|
39
39
|
type: :development
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.2.
|
46
|
+
version: 2.2.2
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - ~>
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.
|
102
|
+
version: 1.9.0
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -107,7 +107,71 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.9.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.7.1
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ~>
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 0.7.1
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: cane
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ~>
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 2.4.0
|
135
|
+
type: :development
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ~>
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 2.4.0
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: roodi1.9
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ~>
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 2.0.1
|
151
|
+
type: :development
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ~>
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 2.0.1
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: ruby_parser
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ~>
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.3.1
|
167
|
+
type: :development
|
168
|
+
prerelease: false
|
169
|
+
version_requirements: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
171
|
+
requirements:
|
172
|
+
- - ~>
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: 2.3.1
|
111
175
|
- !ruby/object:Gem::Dependency
|
112
176
|
name: guard
|
113
177
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +179,7 @@ dependencies:
|
|
115
179
|
requirements:
|
116
180
|
- - ~>
|
117
181
|
- !ruby/object:Gem::Version
|
118
|
-
version: 1.
|
182
|
+
version: 1.5.3
|
119
183
|
type: :development
|
120
184
|
prerelease: false
|
121
185
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -123,7 +187,7 @@ dependencies:
|
|
123
187
|
requirements:
|
124
188
|
- - ~>
|
125
189
|
- !ruby/object:Gem::Version
|
126
|
-
version: 1.
|
190
|
+
version: 1.5.3
|
127
191
|
- !ruby/object:Gem::Dependency
|
128
192
|
name: guard-rspec
|
129
193
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +195,7 @@ dependencies:
|
|
131
195
|
requirements:
|
132
196
|
- - ~>
|
133
197
|
- !ruby/object:Gem::Version
|
134
|
-
version: 2.1.
|
198
|
+
version: 2.1.1
|
135
199
|
type: :development
|
136
200
|
prerelease: false
|
137
201
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -139,7 +203,7 @@ dependencies:
|
|
139
203
|
requirements:
|
140
204
|
- - ~>
|
141
205
|
- !ruby/object:Gem::Version
|
142
|
-
version: 2.1.
|
206
|
+
version: 2.1.1
|
143
207
|
- !ruby/object:Gem::Dependency
|
144
208
|
name: guard-bundler
|
145
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,7 +227,7 @@ dependencies:
|
|
163
227
|
requirements:
|
164
228
|
- - ~>
|
165
229
|
- !ruby/object:Gem::Version
|
166
|
-
version: 2.0.
|
230
|
+
version: 2.0.1
|
167
231
|
type: :development
|
168
232
|
prerelease: false
|
169
233
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -171,7 +235,7 @@ dependencies:
|
|
171
235
|
requirements:
|
172
236
|
- - ~>
|
173
237
|
- !ruby/object:Gem::Version
|
174
|
-
version: 2.0.
|
238
|
+
version: 2.0.1
|
175
239
|
- !ruby/object:Gem::Dependency
|
176
240
|
name: rb-fsevent
|
177
241
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,7 +243,7 @@ dependencies:
|
|
179
243
|
requirements:
|
180
244
|
- - ~>
|
181
245
|
- !ruby/object:Gem::Version
|
182
|
-
version: 0.9.
|
246
|
+
version: 0.9.2
|
183
247
|
type: :development
|
184
248
|
prerelease: false
|
185
249
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -187,7 +251,7 @@ dependencies:
|
|
187
251
|
requirements:
|
188
252
|
- - ~>
|
189
253
|
- !ruby/object:Gem::Version
|
190
|
-
version: 0.9.
|
254
|
+
version: 0.9.2
|
191
255
|
description: Ashikawa Core is a wrapper around the ArangoDB REST API. It provides
|
192
256
|
low level access and will be used in different ArangoDB ODMs.
|
193
257
|
email:
|
@@ -214,8 +278,18 @@ files:
|
|
214
278
|
- lib/ashikawa-core/database.rb
|
215
279
|
- lib/ashikawa-core/document.rb
|
216
280
|
- lib/ashikawa-core/exceptions/document_not_found.rb
|
281
|
+
- lib/ashikawa-core/exceptions/no_collection_provided.rb
|
217
282
|
- lib/ashikawa-core/index.rb
|
283
|
+
- lib/ashikawa-core/query.rb
|
218
284
|
- lib/ashikawa-core/version.rb
|
285
|
+
- spec/acceptance/arango_helper.rb
|
286
|
+
- spec/acceptance/basic_spec.rb
|
287
|
+
- spec/acceptance/index_spec.rb
|
288
|
+
- spec/acceptance/query_spec.rb
|
289
|
+
- spec/acceptance/spec_helper.rb
|
290
|
+
- spec/acceptance_auth/arango_helper.rb
|
291
|
+
- spec/acceptance_auth/auth_spec.rb
|
292
|
+
- spec/acceptance_auth/spec_helper.rb
|
219
293
|
- spec/fixtures/collections/4588.json
|
220
294
|
- spec/fixtures/collections/4590-properties.json
|
221
295
|
- spec/fixtures/collections/4590.json
|
@@ -231,6 +305,7 @@ files:
|
|
231
305
|
- spec/fixtures/indices/all.json
|
232
306
|
- spec/fixtures/indices/hash-index.json
|
233
307
|
- spec/fixtures/indices/new-hash-index.json
|
308
|
+
- spec/fixtures/query/valid.json
|
234
309
|
- spec/fixtures/simple-queries/all.json
|
235
310
|
- spec/fixtures/simple-queries/all_limit.json
|
236
311
|
- spec/fixtures/simple-queries/all_skip.json
|
@@ -238,20 +313,15 @@ files:
|
|
238
313
|
- spec/fixtures/simple-queries/near.json
|
239
314
|
- spec/fixtures/simple-queries/range.json
|
240
315
|
- spec/fixtures/simple-queries/within.json
|
241
|
-
- spec/
|
242
|
-
- spec/integration/basic_spec.rb
|
243
|
-
- spec/integration/index_spec.rb
|
244
|
-
- spec/integration/query_spec.rb
|
245
|
-
- spec/integration/spec_helper.rb
|
246
|
-
- spec/integration_auth/arango_helper.rb
|
247
|
-
- spec/integration_auth/auth_spec.rb
|
248
|
-
- spec/integration_auth/spec_helper.rb
|
316
|
+
- spec/setup/arangodb.sh
|
249
317
|
- spec/unit/collection_spec.rb
|
250
318
|
- spec/unit/connection_spec.rb
|
251
319
|
- spec/unit/cursor_spec.rb
|
252
320
|
- spec/unit/database_spec.rb
|
253
321
|
- spec/unit/document_spec.rb
|
322
|
+
- spec/unit/exception_spec.rb
|
254
323
|
- spec/unit/index_spec.rb
|
324
|
+
- spec/unit/query_spec.rb
|
255
325
|
- spec/unit/spec_helper.rb
|
256
326
|
homepage: http://triagens.github.com/ashikawa-core
|
257
327
|
licenses: []
|
@@ -271,6 +341,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
341
|
- - ! '>='
|
272
342
|
- !ruby/object:Gem::Version
|
273
343
|
version: '0'
|
344
|
+
segments:
|
345
|
+
- 0
|
346
|
+
hash: 4004032968452563439
|
274
347
|
requirements:
|
275
348
|
- ArangoDB, v1.0 alpha or greater
|
276
349
|
rubyforge_project: ashikawa-core
|
@@ -279,6 +352,14 @@ signing_key:
|
|
279
352
|
specification_version: 3
|
280
353
|
summary: Ashikawa Core is a wrapper around the ArangoDB REST API
|
281
354
|
test_files:
|
355
|
+
- spec/acceptance/arango_helper.rb
|
356
|
+
- spec/acceptance/basic_spec.rb
|
357
|
+
- spec/acceptance/index_spec.rb
|
358
|
+
- spec/acceptance/query_spec.rb
|
359
|
+
- spec/acceptance/spec_helper.rb
|
360
|
+
- spec/acceptance_auth/arango_helper.rb
|
361
|
+
- spec/acceptance_auth/auth_spec.rb
|
362
|
+
- spec/acceptance_auth/spec_helper.rb
|
282
363
|
- spec/fixtures/collections/4588.json
|
283
364
|
- spec/fixtures/collections/4590-properties.json
|
284
365
|
- spec/fixtures/collections/4590.json
|
@@ -294,6 +375,7 @@ test_files:
|
|
294
375
|
- spec/fixtures/indices/all.json
|
295
376
|
- spec/fixtures/indices/hash-index.json
|
296
377
|
- spec/fixtures/indices/new-hash-index.json
|
378
|
+
- spec/fixtures/query/valid.json
|
297
379
|
- spec/fixtures/simple-queries/all.json
|
298
380
|
- spec/fixtures/simple-queries/all_limit.json
|
299
381
|
- spec/fixtures/simple-queries/all_skip.json
|
@@ -301,19 +383,14 @@ test_files:
|
|
301
383
|
- spec/fixtures/simple-queries/near.json
|
302
384
|
- spec/fixtures/simple-queries/range.json
|
303
385
|
- spec/fixtures/simple-queries/within.json
|
304
|
-
- spec/
|
305
|
-
- spec/integration/basic_spec.rb
|
306
|
-
- spec/integration/index_spec.rb
|
307
|
-
- spec/integration/query_spec.rb
|
308
|
-
- spec/integration/spec_helper.rb
|
309
|
-
- spec/integration_auth/arango_helper.rb
|
310
|
-
- spec/integration_auth/auth_spec.rb
|
311
|
-
- spec/integration_auth/spec_helper.rb
|
386
|
+
- spec/setup/arangodb.sh
|
312
387
|
- spec/unit/collection_spec.rb
|
313
388
|
- spec/unit/connection_spec.rb
|
314
389
|
- spec/unit/cursor_spec.rb
|
315
390
|
- spec/unit/database_spec.rb
|
316
391
|
- spec/unit/document_spec.rb
|
392
|
+
- spec/unit/exception_spec.rb
|
317
393
|
- spec/unit/index_spec.rb
|
394
|
+
- spec/unit/query_spec.rb
|
318
395
|
- spec/unit/spec_helper.rb
|
319
396
|
has_rdoc:
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'integration/spec_helper'
|
2
|
-
|
3
|
-
describe "Simple Queries" do
|
4
|
-
let(:database) { Ashikawa::Core::Database.new ARANGO_HOST }
|
5
|
-
subject { database["my_collection"] }
|
6
|
-
before(:each) { subject.truncate! }
|
7
|
-
|
8
|
-
it "should return all documents of a collection" do
|
9
|
-
subject << { name: "testname", age: 27}
|
10
|
-
subject.all.first["name"].should == "testname"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should be possible to limit and skip results" do
|
14
|
-
subject << { name: "test1"}
|
15
|
-
subject << { name: "test2"}
|
16
|
-
subject << { name: "test3"}
|
17
|
-
|
18
|
-
subject.all(limit: 2).length.should == 2
|
19
|
-
subject.all(skip: 2).length.should == 1
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should be possible to query documents by example" do
|
23
|
-
subject << { "name" => "Random Document" }
|
24
|
-
result = subject.by_example example: {"name" => "Random Document"}
|
25
|
-
result.length.should == 1
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should be possible to query documents with AQL" do
|
29
|
-
subject << { "name" => "Jeff Lebowski", "bowling" => true }
|
30
|
-
subject << { "name" => "Walter Sobchak", "bowling" => true }
|
31
|
-
subject << { "name" => "Donny Kerabatsos", "bowling" => true }
|
32
|
-
subject << { "name" => "Jeffrey Lebowski", "bowling" => false }
|
33
|
-
|
34
|
-
results = database.query "FOR u IN my_collection FILTER u.bowling == true RETURN u",
|
35
|
-
batch_size: 2,
|
36
|
-
count: true
|
37
|
-
|
38
|
-
results.length.should == 3
|
39
|
-
|
40
|
-
results = results.map { |person| person["name"] }
|
41
|
-
results.should include "Jeff Lebowski"
|
42
|
-
results.should_not include "Jeffrey Lebowski"
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "geolocation" do
|
46
|
-
before :each do
|
47
|
-
subject.add_index :geo, on: [:latitude, :longitude]
|
48
|
-
subject << { "name" => "cologne", "latitude" => 50.948045, "longitude" => 6.961212 }
|
49
|
-
subject << { "name" => "san francisco", "latitude" => -122.395899, "longitude" => 37.793621 }
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should be possible to query documents near a certain location" do
|
53
|
-
found_places = subject.near latitude: 50, longitude: 6
|
54
|
-
found_places.first["name"].should == "cologne"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should be possible to query documents within a certain range" do
|
58
|
-
found_places = subject.within latitude: 50.948040, longitude: 6.961210, radius: 2
|
59
|
-
found_places.length.should == 1
|
60
|
-
found_places.first["name"].should == "cologne"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "ranges" do
|
65
|
-
before :each do
|
66
|
-
subject.add_index :skiplist, on: [:age]
|
67
|
-
subject << { "name" => "Georg", "age" => 12 }
|
68
|
-
subject << { "name" => "Anne", "age" => 21 }
|
69
|
-
subject << { "name" => "Jens", "age" => 49 }
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should be possible to query documents for numbers in a certain range" do
|
73
|
-
found_people = subject.in_range attribute: "age", left: 20, right: 30, closed: true
|
74
|
-
found_people.length.should == 1
|
75
|
-
found_people.first["name"].should == "Anne"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|