arangorb 0.1.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.
@@ -0,0 +1,92 @@
1
+ require_relative './../spec_helper'
2
+
3
+ describe ArangoDoc do
4
+ before :all do
5
+ ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
+ ArangoS.database = "MyDatabase"
7
+ ArangoS.collection = "MyCollection"
8
+ ArangoDB.new.create
9
+ @myCollection = ArangoC.new.create
10
+ @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
11
+ @myDocument = ArangoDoc.new body: {"Hello" => "World", "num" => 1}, key: "FirstDocument"
12
+ end
13
+
14
+ after :all do
15
+ ArangoDB.new.destroy
16
+ end
17
+
18
+ context "#new" do
19
+ it "create a new Document instance without global" do
20
+ myDocument = ArangoDoc.new collection: "MyCollection", database: "MyDatabase"
21
+ expect(myDocument.collection).to eq "MyCollection"
22
+ end
23
+
24
+ it "create a new instance with global" do
25
+ myDocument = ArangoDoc.new key: "myKey", body: {"Hello" => "World"}
26
+ expect(myDocument.key).to eq "myKey"
27
+ end
28
+
29
+ it "create a new Edge instance" do
30
+ a = ArangoDoc.new(key: "myA", body: {"Hello" => "World"}).create
31
+ b = ArangoDoc.new(key: "myB", body: {"Hello" => "World"}).create
32
+ myEdgeDocument = ArangoDoc.new collection: "MyEdgeCollection", from: a, to: b
33
+ expect(myEdgeDocument.body["_from"]).to eq a.id
34
+ end
35
+ end
36
+
37
+ context "#create" do
38
+ it "create a new Document" do
39
+ myDocument = @myDocument.create
40
+ expect(myDocument.body["Hello"]).to eq "World"
41
+ end
42
+
43
+ it "create a duplicate Document" do
44
+ myDocument = @myDocument.create
45
+ expect(myDocument).to eq "cannot create document, unique constraint violated"
46
+ end
47
+
48
+ it "create a new Edge" do
49
+ myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
50
+ myEdge = ArangoDoc.new collection: "MyEdgeCollection", from: myDoc[0].id, to: myDoc[1].id
51
+ myEdge = myEdge.create
52
+ expect(myEdge.body["_from"]).to eq myDoc[0].id
53
+ end
54
+ end
55
+
56
+ context "#info" do
57
+ it "retrieve Document" do
58
+ myDocument = @myDocument.retrieve
59
+ expect(myDocument.body["Hello"]).to eq "World"
60
+ end
61
+
62
+ it "retrieve Edges" do
63
+ testmy = @myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myDocument
64
+ myEdges = @myDocument.retrieve_edges(collection: @myEdgeCollection)
65
+ expect(myEdges.length).to eq 2
66
+ end
67
+
68
+ it "going in different directions" do
69
+ myDocument = @myDocument.in("MyEdgeCollection")[0].from.out(@myEdgeCollection)[0].to
70
+ expect(myDocument.id).to eq @myDocument.id
71
+ end
72
+ end
73
+
74
+ context "#modify" do
75
+ it "replace" do
76
+ myDocument = @myDocument.replace body: {"value" => 3}
77
+ expect(myDocument.body["value"]).to eq 3
78
+ end
79
+
80
+ it "update" do
81
+ myDocument = @myDocument.update body: {"time" => 13}
82
+ expect(myDocument.body["value"]).to eq 3
83
+ end
84
+ end
85
+
86
+ context "#destroy" do
87
+ it "delete a Document" do
88
+ result = @myDocument.destroy
89
+ expect(result).to eq true
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,70 @@
1
+ require_relative './../spec_helper'
2
+
3
+ describe ArangoE do
4
+ before :all do
5
+ ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
+ ArangoS.database = "MyDatabase"
7
+ ArangoS.collection = "MyCollection"
8
+ ArangoS.graph = "MyGraph"
9
+ ArangoDB.new.create
10
+ @myGraph = ArangoG.new.create
11
+ @myCollection = ArangoC.new.create
12
+ @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
13
+ @myGraph.addVertexCollection collection: "MyCollection"
14
+ @myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: "MyCollection"
15
+ @vertexA = ArangoV.new(body: {"Hello" => "World", "num" => 1}).create
16
+ @vertexB = ArangoV.new(body: {"Hello" => "Moon", "num" => 2}).create
17
+ @myEdge = ArangoE.new(from: @vertexA, to: @vertexB, collection: "MyEdgeCollection").create
18
+ end
19
+
20
+ after :all do
21
+ ArangoDB.new.destroy
22
+ end
23
+
24
+ context "#new" do
25
+ it "create a new Edge instance" do
26
+ a = ArangoV.new(key: "myA", body: {"Hello" => "World"}).create
27
+ b = ArangoV.new(key: "myB", body: {"Hello" => "World"}).create
28
+ myEdgeDocument = ArangoE.new collection: "MyEdgeCollection", from: a, to: b
29
+ expect(myEdgeDocument.body["_from"]).to eq a.id
30
+ end
31
+ end
32
+
33
+ context "#create" do
34
+ it "create a new Edge" do
35
+ myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
36
+ myEdge = ArangoE.new from: myDoc[0].id, to: myDoc[1].id, collection: "MyEdgeCollection"
37
+ myEdge = myEdge.create
38
+ expect(myEdge.body["_from"]).to eq myDoc[0].id
39
+ end
40
+ end
41
+
42
+ context "#info" do
43
+ it "retrieve Document" do
44
+ myDocument = @myEdge.retrieve
45
+ expect(myDocument.collection).to eq "MyEdgeCollection"
46
+ end
47
+ end
48
+
49
+ context "#modify" do
50
+ it "replace" do
51
+ a = ArangoV.new(body: {"Hello" => "World"}).create
52
+ b = ArangoV.new(body: {"Hello" => "World!!"}).create
53
+ myDocument = @myEdge.replace body: {"_from" => a.id, "_to" => b.id}
54
+ expect(myDocument.body["_from"]).to eq a.id
55
+ end
56
+
57
+ it "update" do
58
+ cc = ArangoV.new(body: {"Hello" => "World!!!"}).create
59
+ myDocument = @myEdge.update body: {"_to" => cc.id}
60
+ expect(myDocument.body["_to"]).to eq cc.id
61
+ end
62
+ end
63
+
64
+ context "#destroy" do
65
+ it "delete a Document" do
66
+ result = @myEdge.destroy
67
+ expect(result).to eq true
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,92 @@
1
+ require_relative './../spec_helper'
2
+
3
+ describe ArangoG do
4
+ before :all do
5
+ ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
+ ArangoS.database = "MyDatabase"
7
+ ArangoS.collection = "MyCollection"
8
+ ArangoDB.new.create
9
+ @myCollection = ArangoC.new.create
10
+ @myCollectionB = ArangoC.new(collection: "MyCollectionB").create
11
+ @myCollectionC = ArangoC.new(collection: "MyCollectionC").create
12
+ @myCollectionD = ArangoC.new(collection: "MyCollectionD").create
13
+ @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
14
+ @myGraph = ArangoG.new graph: "MyGraph"
15
+ end
16
+
17
+ after :all do
18
+ ArangoDB.new.destroy
19
+ end
20
+
21
+ context "#new" do
22
+ it "create a new Graph instance without global" do
23
+ myGraph = ArangoG.new graph: "MyGraph", database: "MyDatabase"
24
+ expect(myGraph.graph).to eq "MyGraph"
25
+ end
26
+
27
+ it "create a new instance with global" do
28
+ myGraph = ArangoG.new
29
+ expect(myGraph.graph).to eq "MyGraph"
30
+ end
31
+ end
32
+
33
+ context "#create" do
34
+ it "create new graph" do
35
+ myGraph = @myGraph.create
36
+ expect(myGraph.graph).to eq "MyGraph"
37
+ end
38
+ end
39
+
40
+ context "#info" do
41
+ it "info graph" do
42
+ myGraph = @myGraph.retrieve
43
+ expect(myGraph.graph).to eq "MyGraph"
44
+ end
45
+ end
46
+
47
+ context "#manageVertexCollections" do
48
+ it "add VertexCollection" do
49
+ myGraph = @myGraph.addVertexCollection collection: "MyCollection"
50
+ expect(myGraph.orphanCollections[0]).to eq "MyCollection"
51
+ end
52
+
53
+ it "retrieve VertexCollection" do
54
+ myGraph = @myGraph.vertexCollections
55
+ expect(myGraph[0].collection).to eq "MyCollection"
56
+ end
57
+
58
+ it "remove VertexCollection" do
59
+ myGraph = @myGraph.removeVertexCollection collection: "MyCollection"
60
+ expect(myGraph.orphanCollections[0]).to eq nil
61
+ end
62
+ end
63
+
64
+ context "#manageEdgeCollections" do
65
+ it "add EdgeCollection" do
66
+ myGraph = @myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: @myCollectionB
67
+ expect(myGraph.edgeDefinitions[0]["from"][0]).to eq "MyCollection"
68
+ end
69
+
70
+ it "retrieve EdgeCollection" do
71
+ myGraph = @myGraph.edgeCollections
72
+ expect(myGraph[0].collection).to eq "MyEdgeCollection"
73
+ end
74
+
75
+ it "replace EdgeCollection" do
76
+ myGraph = @myGraph.replaceEdgeCollection collection: @myEdgeCollection, from: "MyCollection", to: "MyCollection"
77
+ expect(myGraph.edgeDefinitions[0]["to"][0]).to eq "MyCollection"
78
+ end
79
+
80
+ it "remove EdgeCollection" do
81
+ myGraph = @myGraph.removeEdgeCollection collection: "MyEdgeCollection"
82
+ expect(myGraph.edgeDefinitions[0]).to eq nil
83
+ end
84
+ end
85
+
86
+ context "#destroy" do
87
+ it "delete graph" do
88
+ myGraph = @myGraph.destroy
89
+ expect(myGraph).to be true
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,28 @@
1
+ require_relative './../spec_helper'
2
+
3
+ describe ArangoS do
4
+ before :all do
5
+ ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
+ end
7
+
8
+ context "#database" do
9
+ it "setup a global database" do
10
+ ArangoS.database = "MyDatabase"
11
+ expect(ArangoS.database).to eq "MyDatabase"
12
+ end
13
+ end
14
+
15
+ context "#graph" do
16
+ it "setup a global graph" do
17
+ ArangoS.graph = "MyGraph"
18
+ expect(ArangoS.graph).to eq "MyGraph"
19
+ end
20
+ end
21
+
22
+ context "#collection" do
23
+ it "setup a global collection" do
24
+ ArangoS.collection = "MyCollection"
25
+ expect(ArangoS.collection).to eq "MyCollection"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,67 @@
1
+ require_relative './../spec_helper'
2
+
3
+ describe ArangoT do
4
+ before :all do
5
+ ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
+ ArangoS.database = "MyDatabase"
7
+ ArangoS.collection = "MyCollection"
8
+ ArangoS.graph = "MyGraph"
9
+ ArangoDB.new.create
10
+ @myGraph = ArangoG.new.create
11
+ @myCollection = ArangoC.new.create
12
+ @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
13
+ @myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: "MyCollection"
14
+ @myTransaction = ArangoT.new
15
+ @myDoc = @myCollection.create_document document: [{"num" => 1, "_key" => "FirstKey"}, {"num" => 2}, {"num" => 3}, {"num" => 4}, {"num" => 5}, {"num" => 6}, {"num" => 7}]
16
+ @myEdgeCollection.create_edge from: [@myDoc[0].id, @myDoc[1].id, @myDoc[2].id, @myDoc[3].id], to: [@myDoc[4].id, @myDoc[5].id, @myDoc[6].id]
17
+ end
18
+
19
+ after :all do
20
+ ArangoDB.new.destroy
21
+ end
22
+
23
+ context "#new" do
24
+ it "create a new Transaction instance" do
25
+ myTransaction = ArangoT.new
26
+ expect(@myTransaction.database).to eq "MyDatabase"
27
+ end
28
+
29
+ it "instantiate start Vertex" do
30
+ @myTransaction.vertex = @myDoc[0]
31
+ expect(@myTransaction.vertex).to eq "MyCollection/FirstKey"
32
+ end
33
+
34
+ it "instantiate Graph" do
35
+ @myTransaction.graph = @myGraph
36
+ expect(@myTransaction.graph).to eq @myGraph.graph
37
+ end
38
+
39
+ it "instantiate EdgeCollection" do
40
+ @myTransaction.collection = @myEdgeCollection
41
+ expect(@myTransaction.collection).to eq @myEdgeCollection.collection
42
+ end
43
+
44
+ it "instantiate Direction" do
45
+ @myTransaction.in
46
+ expect(@myTransaction.direction).to eq "inbound"
47
+ end
48
+
49
+ it "instantiate Max" do
50
+ @myTransaction.max = 3
51
+ expect(@myTransaction.max).to eq 3
52
+ end
53
+
54
+ it "instantiate Min" do
55
+ @myTransaction.min = 1
56
+ expect(@myTransaction.min).to eq 1
57
+ end
58
+ end
59
+
60
+ context "#execute" do
61
+ it "execute Transaction" do
62
+ @myTransaction.any
63
+ @myTransaction.execute
64
+ expect(@myTransaction.vertices.length).to eq 30
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,81 @@
1
+ require_relative './../spec_helper'
2
+
3
+ describe ArangoV do
4
+ before :all do
5
+ ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
+ ArangoS.database = "MyDatabase"
7
+ ArangoS.collection = "MyCollection"
8
+ ArangoS.graph = "MyGraph"
9
+ ArangoDB.new.create
10
+ @myGraph = ArangoG.new.create
11
+ @myCollection = ArangoC.new.create
12
+ @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
13
+ @myVertex = ArangoV.new body: {"Hello" => "World", "num" => 1}, key: "FirstDocument"
14
+ @myGraph.addVertexCollection collection: "MyCollection"
15
+ end
16
+
17
+ after :all do
18
+ ArangoDB.new.destroy
19
+ end
20
+
21
+ context "#new" do
22
+ it "create a new Document instance without global" do
23
+ myVertex = ArangoV.new collection: "MyCollection", database: "MyDatabase", graph: "MyGraph"
24
+ expect(myVertex.collection).to eq "MyCollection"
25
+ end
26
+
27
+ it "create a new instance with global" do
28
+ myVertex = ArangoV.new key: "myKey", body: {"Hello" => "World"}
29
+ expect(myVertex.key).to eq "myKey"
30
+ end
31
+ end
32
+
33
+ context "#create" do
34
+ it "create a new Document" do
35
+ myVertex = @myVertex.create
36
+ expect(myVertex.body["Hello"]).to eq "World"
37
+ end
38
+
39
+ it "create a duplicate Document" do
40
+ myVertex = @myVertex.create
41
+ expect(myVertex).to eq "unique constraint violated"
42
+ end
43
+ end
44
+
45
+ context "#info" do
46
+ it "retrieve Document" do
47
+ myVertex = @myVertex.retrieve
48
+ expect(myVertex.body["Hello"]).to eq "World"
49
+ end
50
+
51
+ it "retrieve Edges" do
52
+ testmy = @myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myVertex
53
+ myEdges = @myVertex.retrieve_edges(collection: @myEdgeCollection)
54
+ expect(myEdges.length).to eq 2
55
+ end
56
+
57
+ # it "going in different directions" do
58
+ # myVertex = @myVertex.in("MyEdgeCollection")[0].from.out(@myEdgeCollection)[0].to
59
+ # expect(myVertex.id).to eq @myVertex.id
60
+ # end
61
+ end
62
+
63
+ context "#modify" do
64
+ it "replace" do
65
+ myVertex = @myVertex.replace body: {"value" => 3}
66
+ expect(myVertex.body["value"]).to eq 3
67
+ end
68
+
69
+ it "update" do
70
+ myVertex = @myVertex.update body: {"time" => 13}
71
+ expect(myVertex.body["value"]).to eq 3
72
+ end
73
+ end
74
+
75
+ context "#destroy" do
76
+ it "delete a Document" do
77
+ result = @myVertex.destroy
78
+ expect(result).to eq true
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,6 @@
1
+ require "rspec"
2
+ require_relative File.expand_path('../../lib/arangorb', __FILE__)
3
+
4
+ RSpec.configure do |config|
5
+ config.color = true
6
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arangorb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stefano Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.14'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.14.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.14'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.14.0
33
+ description: ArangoDB is a powerful mixed database based on documents and graphs,
34
+ with an interesting language called AQl. ArangoRB is a Ruby gems to use Ruby to
35
+ interact with its HTTP API.
36
+ email:
37
+ - stefano@seluxit.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - ArangoRB.gemspec
43
+ - Gemfile
44
+ - LICENSE
45
+ - README.md
46
+ - lib/ArangoRB_AQL.rb
47
+ - lib/ArangoRB_Col.rb
48
+ - lib/ArangoRB_DB.rb
49
+ - lib/ArangoRB_Doc.rb
50
+ - lib/ArangoRB_Edg.rb
51
+ - lib/ArangoRB_Gra.rb
52
+ - lib/ArangoRB_Ser.rb
53
+ - lib/ArangoRB_Tra.rb
54
+ - lib/ArangoRB_Ver.rb
55
+ - lib/arangorb.rb
56
+ - spec/arangoRB_helper.rb
57
+ - spec/lib/arangoAQL_helper.rb
58
+ - spec/lib/arangoC_helper.rb
59
+ - spec/lib/arangoDB_helper.rb
60
+ - spec/lib/arangoDoc_helper.rb
61
+ - spec/lib/arangoE_helper.rb
62
+ - spec/lib/arangoG_helper.rb
63
+ - spec/lib/arangoS_helper.rb
64
+ - spec/lib/arangoT_helper.rb
65
+ - spec/lib/arangoV_helper.rb
66
+ - spec/spec_helper.rb
67
+ homepage: https://github.com/StefanoMartin/ArangoRB
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.8
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: A simple ruby client for ArangoDB
91
+ test_files: []
92
+ has_rdoc: