guacamole 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/.hound.yml +1 -1
- data/.travis.yml +16 -15
- data/CHANGELOG.md +16 -0
- data/GOALS.md +8 -0
- data/Guardfile +4 -0
- data/README.md +21 -81
- data/guacamole.gemspec +3 -3
- data/lib/guacamole.rb +1 -0
- data/lib/guacamole/aql_query.rb +6 -1
- data/lib/guacamole/collection.rb +34 -66
- data/lib/guacamole/configuration.rb +53 -25
- data/lib/guacamole/document_model_mapper.rb +149 -38
- data/lib/guacamole/edge.rb +74 -0
- data/lib/guacamole/edge_collection.rb +91 -0
- data/lib/guacamole/exceptions.rb +0 -5
- data/lib/guacamole/graph_query.rb +31 -0
- data/lib/guacamole/model.rb +4 -0
- data/lib/guacamole/proxies/proxy.rb +7 -3
- data/lib/guacamole/proxies/relation.rb +22 -0
- data/lib/guacamole/railtie.rb +1 -1
- data/lib/guacamole/transaction.rb +177 -0
- data/lib/guacamole/version.rb +1 -1
- data/shared/transaction.js +66 -0
- data/spec/acceptance/aql_spec.rb +32 -40
- data/spec/acceptance/relations_spec.rb +239 -0
- data/spec/acceptance/spec_helper.rb +2 -2
- data/spec/fabricators/author_fabricator.rb +2 -0
- data/spec/setup/arangodb.sh +2 -2
- data/spec/unit/collection_spec.rb +20 -97
- data/spec/unit/configuration_spec.rb +73 -50
- data/spec/unit/document_model_mapper_spec.rb +84 -77
- data/spec/unit/edge_collection_spec.rb +174 -0
- data/spec/unit/edge_spec.rb +57 -0
- data/spec/unit/proxies/relation_spec.rb +35 -0
- metadata +22 -14
- data/lib/guacamole/proxies/referenced_by.rb +0 -15
- data/lib/guacamole/proxies/references.rb +0 -15
- data/spec/acceptance/association_spec.rb +0 -40
- data/spec/unit/example_spec.rb +0 -8
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'guacamole/edge'
|
5
|
+
|
6
|
+
class TestEdge
|
7
|
+
include Guacamole::Edge
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Guacamole::Edge do
|
11
|
+
context 'having an instance of an edge' do
|
12
|
+
subject { TestEdge.new }
|
13
|
+
|
14
|
+
it 'should be a specialized Guacamole::Model' do
|
15
|
+
expect(subject).to be_kind_of Guacamole::Model
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have a special attribute :from' do
|
19
|
+
expect(subject).to respond_to(:from)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have a special attribute :to' do
|
23
|
+
expect(subject).to respond_to(:to)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'defining edges' do
|
28
|
+
subject { TestEdge }
|
29
|
+
|
30
|
+
it 'should define a :from definition' do
|
31
|
+
subject.from :orders
|
32
|
+
|
33
|
+
expect(subject.from).to eq :orders
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should define a :to definition' do
|
37
|
+
subject.to :customers
|
38
|
+
|
39
|
+
expect(subject.to).to eq :customers
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'looking up collections' do
|
43
|
+
let(:edge_collection) { double('EdgeCollection') }
|
44
|
+
|
45
|
+
before do
|
46
|
+
stub_const('FromCollection', edge_collection)
|
47
|
+
stub_const('ToCollection', edge_collection)
|
48
|
+
|
49
|
+
allow(subject).to receive(:to).and_return('to')
|
50
|
+
allow(subject).to receive(:from).and_return('from')
|
51
|
+
end
|
52
|
+
|
53
|
+
its(:to_collection) { should eq edge_collection }
|
54
|
+
its(:from_collection) { should eq edge_collection }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'guacamole/proxies/relation'
|
5
|
+
|
6
|
+
describe Guacamole::Proxies::Relation do
|
7
|
+
let(:model) { double('Model') }
|
8
|
+
let(:edge_class) { double('EdgeClass') }
|
9
|
+
let(:responsible_edge_collection) { double('EdgeCollection') }
|
10
|
+
let(:edge_collection_name) { 'name_of_the_edge_collection' }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(Guacamole::EdgeCollection).to receive(:for).with(edge_class).and_return(responsible_edge_collection)
|
14
|
+
allow(responsible_edge_collection).to receive(:collection_name).and_return(edge_collection_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'initialization' do
|
18
|
+
subject { Guacamole::Proxies::Relation }
|
19
|
+
|
20
|
+
it 'should take a model and edge class as params' do
|
21
|
+
expect { subject.new(model, edge_class) }.not_to raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'initialized proxy' do
|
26
|
+
subject { Guacamole::Proxies::Relation.new(model, edge_class) }
|
27
|
+
|
28
|
+
it 'should call the #neigbors method on the appropriate edge collection' do
|
29
|
+
expect(responsible_edge_collection).to receive(:neighbors)
|
30
|
+
.with(model)
|
31
|
+
|
32
|
+
subject.to_a
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guacamole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Dohmen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ashikawa-core
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.13.1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.13.1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: virtus
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,14 +255,14 @@ dependencies:
|
|
255
255
|
requirements:
|
256
256
|
- - "~>"
|
257
257
|
- !ruby/object:Gem::Version
|
258
|
-
version: 3.
|
258
|
+
version: 3.1.0
|
259
259
|
type: :development
|
260
260
|
prerelease: false
|
261
261
|
version_requirements: !ruby/object:Gem::Requirement
|
262
262
|
requirements:
|
263
263
|
- - "~>"
|
264
264
|
- !ruby/object:Gem::Version
|
265
|
-
version: 3.
|
265
|
+
version: 3.1.0
|
266
266
|
- !ruby/object:Gem::Dependency
|
267
267
|
name: timecop
|
268
268
|
requirement: !ruby/object:Gem::Requirement
|
@@ -293,8 +293,8 @@ dependencies:
|
|
293
293
|
version: 0.8.7.4
|
294
294
|
description: ODM for ArangoDB
|
295
295
|
email:
|
296
|
-
-
|
297
|
-
- dirk
|
296
|
+
- lucas@arangodb.com
|
297
|
+
- dirk@arangodb.com
|
298
298
|
executables: []
|
299
299
|
extensions: []
|
300
300
|
extra_rdoc_files: []
|
@@ -321,16 +321,19 @@ files:
|
|
321
321
|
- lib/guacamole/collection.rb
|
322
322
|
- lib/guacamole/configuration.rb
|
323
323
|
- lib/guacamole/document_model_mapper.rb
|
324
|
+
- lib/guacamole/edge.rb
|
325
|
+
- lib/guacamole/edge_collection.rb
|
324
326
|
- lib/guacamole/exceptions.rb
|
327
|
+
- lib/guacamole/graph_query.rb
|
325
328
|
- lib/guacamole/identity_map.rb
|
326
329
|
- lib/guacamole/model.rb
|
327
330
|
- lib/guacamole/proxies/proxy.rb
|
328
|
-
- lib/guacamole/proxies/
|
329
|
-
- lib/guacamole/proxies/references.rb
|
331
|
+
- lib/guacamole/proxies/relation.rb
|
330
332
|
- lib/guacamole/query.rb
|
331
333
|
- lib/guacamole/railtie.rb
|
332
334
|
- lib/guacamole/railtie/database.rake
|
333
335
|
- lib/guacamole/tasks/database.rake
|
336
|
+
- lib/guacamole/transaction.rb
|
334
337
|
- lib/guacamole/version.rb
|
335
338
|
- lib/rails/generators/guacamole/callbacks/callbacks_generator.rb
|
336
339
|
- lib/rails/generators/guacamole/callbacks/templates/callbacks.rb.tt
|
@@ -351,12 +354,13 @@ files:
|
|
351
354
|
- lib/rails/generators/test_unit/collection/collection_generator.rb
|
352
355
|
- lib/rails/generators/test_unit/collection/templates/collection_test.rb.tt
|
353
356
|
- log/.gitkeep
|
357
|
+
- shared/transaction.js
|
354
358
|
- spec/acceptance/.gitkeep
|
355
359
|
- spec/acceptance/aql_spec.rb
|
356
|
-
- spec/acceptance/association_spec.rb
|
357
360
|
- spec/acceptance/basic_spec.rb
|
358
361
|
- spec/acceptance/callbacks_spec.rb
|
359
362
|
- spec/acceptance/config/guacamole.yml
|
363
|
+
- spec/acceptance/relations_spec.rb
|
360
364
|
- spec/acceptance/spec_helper.rb
|
361
365
|
- spec/fabricators/article.rb
|
362
366
|
- spec/fabricators/article_fabricator.rb
|
@@ -376,9 +380,11 @@ files:
|
|
376
380
|
- spec/unit/collection_spec.rb
|
377
381
|
- spec/unit/configuration_spec.rb
|
378
382
|
- spec/unit/document_model_mapper_spec.rb
|
379
|
-
- spec/unit/
|
383
|
+
- spec/unit/edge_collection_spec.rb
|
384
|
+
- spec/unit/edge_spec.rb
|
380
385
|
- spec/unit/identiy_map_spec.rb
|
381
386
|
- spec/unit/model_spec.rb
|
387
|
+
- spec/unit/proxies/relation_spec.rb
|
382
388
|
- spec/unit/query_spec.rb
|
383
389
|
homepage: http://guacamolegem.org
|
384
390
|
licenses:
|
@@ -407,10 +413,10 @@ summary: An ODM for ArangoDB that uses the DataMapper pattern.
|
|
407
413
|
test_files:
|
408
414
|
- spec/acceptance/.gitkeep
|
409
415
|
- spec/acceptance/aql_spec.rb
|
410
|
-
- spec/acceptance/association_spec.rb
|
411
416
|
- spec/acceptance/basic_spec.rb
|
412
417
|
- spec/acceptance/callbacks_spec.rb
|
413
418
|
- spec/acceptance/config/guacamole.yml
|
419
|
+
- spec/acceptance/relations_spec.rb
|
414
420
|
- spec/acceptance/spec_helper.rb
|
415
421
|
- spec/fabricators/article.rb
|
416
422
|
- spec/fabricators/article_fabricator.rb
|
@@ -430,8 +436,10 @@ test_files:
|
|
430
436
|
- spec/unit/collection_spec.rb
|
431
437
|
- spec/unit/configuration_spec.rb
|
432
438
|
- spec/unit/document_model_mapper_spec.rb
|
433
|
-
- spec/unit/
|
439
|
+
- spec/unit/edge_collection_spec.rb
|
440
|
+
- spec/unit/edge_spec.rb
|
434
441
|
- spec/unit/identiy_map_spec.rb
|
435
442
|
- spec/unit/model_spec.rb
|
443
|
+
- spec/unit/proxies/relation_spec.rb
|
436
444
|
- spec/unit/query_spec.rb
|
437
445
|
has_rdoc:
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
require 'guacamole/proxies/proxy'
|
4
|
-
|
5
|
-
module Guacamole
|
6
|
-
module Proxies
|
7
|
-
# The {ReferencedBy} proxy is used to represent the 'one' in one-to-many relations.
|
8
|
-
class ReferencedBy < Proxy
|
9
|
-
def initialize(ref, model)
|
10
|
-
init model,
|
11
|
-
-> { DocumentModelMapper.collection_for(ref).by_example("#{model.class.name.underscore}_id" => model.key) }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
require 'guacamole/proxies/proxy'
|
4
|
-
|
5
|
-
module Guacamole
|
6
|
-
module Proxies
|
7
|
-
# The {References} proxy is used to represent the 'many' in one-to-many relations.
|
8
|
-
class References < Proxy
|
9
|
-
def initialize(ref, document)
|
10
|
-
init nil,
|
11
|
-
-> { DocumentModelMapper.collection_for(ref).by_key(document["#{ref}_id"]) }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'guacamole'
|
3
|
-
require 'acceptance/spec_helper'
|
4
|
-
|
5
|
-
require 'fabricators/book'
|
6
|
-
require 'fabricators/author'
|
7
|
-
|
8
|
-
class AuthorsCollection
|
9
|
-
include Guacamole::Collection
|
10
|
-
|
11
|
-
map do
|
12
|
-
referenced_by :books
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class BooksCollection
|
17
|
-
include Guacamole::Collection
|
18
|
-
|
19
|
-
map do
|
20
|
-
references :author
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'Associations' do
|
25
|
-
let(:author) { Fabricate(:author_with_three_books) }
|
26
|
-
|
27
|
-
it 'should load referenced models from the database' do
|
28
|
-
the_author = AuthorsCollection.by_key author.key
|
29
|
-
books_from_author = BooksCollection.by_example(author_id: author.key).to_a
|
30
|
-
|
31
|
-
expect(books_from_author).to eq the_author.books.to_a
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should load the referenced model from the database' do
|
35
|
-
the_author = AuthorsCollection.by_key author.key
|
36
|
-
a_book_by_the_author = BooksCollection.by_example(author_id: author.key).to_a.first
|
37
|
-
|
38
|
-
expect(a_book_by_the_author.author).to eq the_author
|
39
|
-
end
|
40
|
-
end
|