arangorb 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ArangoRB.gemspec +1 -1
- data/README.md +3 -3
- data/lib/ArangoRB_Col.rb +1 -1
- data/lib/ArangoRB_User.rb +8 -0
- data/spec/lib/0.1.0/arangoC_helper.rb +170 -170
- data/spec/lib/0.1.0/arangoDoc_helper.rb +79 -79
- data/spec/lib/0.1.0/arangoV_helper.rb +65 -65
- data/spec/lib/1.0.0/arangoU_helper.rb +72 -72
- data/spec/spec_helper.rb +42 -42
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7898e5b31c9c45cc10d0deccb84c18309f85e04
|
4
|
+
data.tar.gz: a3d414487bd4fdaba84bc5f3c1c72e23011942cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0042e4fc89867ce6a3255bbe4a14f8d61a2ff7e2a1a91ed9f0f668da4823587e41be4823c643064dbf67855c23ffe3bdd5e38db28fe4c8a916e7ff8035dbf7ee
|
7
|
+
data.tar.gz: 848cb9a73042f29651be327028cad40329478d17dbc64a09401fb11b48b9252d20501b8986d6aef8db780087c63482df1cb8df882ac58359131b34617b7f0825
|
data/ArangoRB.gemspec
CHANGED
data/README.md
CHANGED
@@ -4,9 +4,9 @@ ArangoRB [![Gem Version](https://badge.fury.io/rb/arangorb.svg)](https://badge.f
|
|
4
4
|
[ArangoDatabase](https://www.arangodb.com/) is a native multi-model database with flexible data models for document, graphs, and key-values.
|
5
5
|
ArangoRB is a Gem to use ArangoDatabase with Ruby. ArangoRB is based on the [HTTP API of ArangoDB](https://docs.arangodb.com/3.0/HTTP/index.html).
|
6
6
|
|
7
|
-
ArangoRB 0.1.0 - 1.3.0 have been tested with ArangoDB 3.0 with Ruby 2.3.1
|
8
|
-
ArangoRB 1.4.0
|
9
|
-
It requires the gem "HTTParty"
|
7
|
+
ArangoRB 0.1.0 - 1.3.0 have been tested with ArangoDB 3.0 with Ruby 2.3.1</br>
|
8
|
+
ArangoRB 1.4.0 has been tested with ArangoDB 3.1 with Ruby 2.3.3</br>
|
9
|
+
It requires the gem "HTTParty"</br>
|
10
10
|
|
11
11
|
To install ArangoRB: `gem install arangorb`
|
12
12
|
|
data/lib/ArangoRB_Col.rb
CHANGED
@@ -102,7 +102,7 @@ class ArangoCollection < ArangoServer
|
|
102
102
|
|
103
103
|
# === POST ===
|
104
104
|
|
105
|
-
def create(type:
|
105
|
+
def create(type: @type, journalSize: nil, keyOptions: nil, waitForSync: nil, doCompact: nil, isVolatile: nil, shardKeys: nil, numberOfShards: nil, isSystem: nil, indexBuckets: nil) # TESTED
|
106
106
|
type = 3 if type == "Edge"
|
107
107
|
type = nil if type == "Document"
|
108
108
|
body = {
|
data/lib/ArangoRB_User.rb
CHANGED
@@ -56,6 +56,14 @@ class ArangoUser < ArangoServer
|
|
56
56
|
return_result result: result, caseTrue: true
|
57
57
|
end
|
58
58
|
|
59
|
+
def grant_read(database: @@database) # TESTED
|
60
|
+
database = database.database if database.is_a?(ArangoDatabase)
|
61
|
+
body = { "grant" => "ro" }.to_json
|
62
|
+
request = @@request.merge({ :body => body })
|
63
|
+
result = self.class.put("/_api/user/#{@user}/database/#{database}", request)
|
64
|
+
return_result result: result, caseTrue: true
|
65
|
+
end
|
66
|
+
|
59
67
|
def revoke(database: @@database) # TESTED
|
60
68
|
database = database.database if database.is_a?(ArangoDatabase)
|
61
69
|
body = { "grant" => "none" }.to_json
|
@@ -1,170 +1,170 @@
|
|
1
|
-
require_relative './../../spec_helper'
|
2
|
-
|
3
|
-
describe ArangoCollection do
|
4
|
-
context "#new" do
|
5
|
-
it "create a new instance without global" do
|
6
|
-
myCollection = ArangoCollection.new collection: "MyCollection"
|
7
|
-
expect(myCollection.collection).to eq "MyCollection"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "create a new instance with global" do
|
11
|
-
myCollection = ArangoCollection.new
|
12
|
-
expect(myCollection.collection).to eq "MyCollection"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "create a new instance with type Edge" do
|
16
|
-
myCollection = ArangoCollection.new collection: "MyCollection", type: "Edge"
|
17
|
-
expect(myCollection.type).to eq "Edge"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "#create" do
|
22
|
-
it "create a new Collection" do
|
23
|
-
@myCollection.destroy
|
24
|
-
myCollection = @myCollection.create
|
25
|
-
expect(myCollection.collection).to eq "MyCollection"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "create a duplicate Collection" do
|
29
|
-
myCollection = @myCollection.create
|
30
|
-
expect(myCollection).to eq "duplicate name: duplicate name"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "create a new Edge Collection" do
|
34
|
-
@myEdgeCollection.destroy
|
35
|
-
myCollection = @myEdgeCollection.create_edge_collection
|
36
|
-
expect(myCollection.type).to eq "Edge"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "create a new Document in the Collection" do
|
40
|
-
myDocument = @myCollection.create_document document: {"Hello" => "World", "num" => 1}
|
41
|
-
expect(myDocument.body["Hello"]).to eq "World"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "create new Documents in the Collection" do
|
45
|
-
myDocument = @myCollection.create_document document: [{"Ciao" => "Mondo", "num" => 1}, {"Hallo" => "Welt", "num" => 2}]
|
46
|
-
expect(myDocument[0].body["Ciao"]).to eq "Mondo"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "create a new Edge in the Collection" do
|
50
|
-
myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
|
51
|
-
myEdge = @myEdgeCollection.create_edge from: myDoc[0].id, to: myDoc[1].id
|
52
|
-
expect(myEdge.body["_from"]).to eq myDoc[0].id
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "#info" do
|
57
|
-
it "retrieve the Collection" do
|
58
|
-
info = @myCollection.retrieve
|
59
|
-
expect(info.collection).to eq "MyCollection"
|
60
|
-
end
|
61
|
-
|
62
|
-
it "properties of the Collection" do
|
63
|
-
info = @myCollection.properties
|
64
|
-
expect(info["name"]).to eq "MyCollection"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "documents in the Collection" do
|
68
|
-
info = @myCollection.count
|
69
|
-
expect(info).to eq 5
|
70
|
-
end
|
71
|
-
|
72
|
-
it "statistics" do
|
73
|
-
info = @myCollection.statistics
|
74
|
-
expect(info["lastTick"]).to eq 0
|
75
|
-
end
|
76
|
-
|
77
|
-
it "checksum" do
|
78
|
-
info = @myCollection.checksum
|
79
|
-
expect(info.class).to eq String
|
80
|
-
end
|
81
|
-
|
82
|
-
it "list Documents" do
|
83
|
-
info = @myCollection.allDocuments
|
84
|
-
expect(info.length).to eq 5
|
85
|
-
end
|
86
|
-
|
87
|
-
it "search Documents by match" do
|
88
|
-
info = @myCollection.documentsMatch match: {"num" => 1}
|
89
|
-
expect(info.length).to eq 3
|
90
|
-
end
|
91
|
-
|
92
|
-
it "search Document by match" do
|
93
|
-
info = @myCollection.documentMatch match: {"num" => 1}
|
94
|
-
expect(info.collection.name).to eq "MyCollection"
|
95
|
-
end
|
96
|
-
|
97
|
-
it "search Document by key match" do
|
98
|
-
docs = @myCollection.create_document document: [{"_key" => "ThisIsATest1", "test" => "fantastic"}, {"_key" => "ThisIsATest2"}]
|
99
|
-
result = @myCollection.documentByKeys keys: ["ThisIsATest1", docs[1]]
|
100
|
-
expect(result[0].body["test"]).to eq "fantastic"
|
101
|
-
end
|
102
|
-
|
103
|
-
it "remove Document by key match" do
|
104
|
-
docs = @myCollection.create_document document: [{"_key" => "ThisIsATest3", "test" => "fantastic"}, {"_key" => "ThisIsATest4"}]
|
105
|
-
result = @myCollection.removeByKeys keys: ["ThisIsATest3", docs[1]]
|
106
|
-
expect(result).to eq 2
|
107
|
-
end
|
108
|
-
|
109
|
-
it "remove Document by match" do
|
110
|
-
@myCollection.create_document document: [{"_key" => "ThisIsATest5", "test" => "fantastic"}, {"_key" => "ThisIsATest6"}]
|
111
|
-
result = @myCollection.removeMatch match: {"test" => "fantastic"}
|
112
|
-
expect(result).to eq 2
|
113
|
-
end
|
114
|
-
|
115
|
-
it "replace Document by match" do
|
116
|
-
@myCollection.create_document document: {"test" => "fantastic", "val" => 4}
|
117
|
-
result = @myCollection.replaceMatch match: {"test" => "fantastic"}, newValue: {"val" => 5}
|
118
|
-
expect(result).to eq 1
|
119
|
-
end
|
120
|
-
|
121
|
-
it "update Document by match" do
|
122
|
-
@myCollection.create_document document: {"test" => "fantastic2", "val" => 5}
|
123
|
-
result = @myCollection.updateMatch match: {"val" => 5}, newValue: {"val" => 6}
|
124
|
-
expect(result).to eq 2
|
125
|
-
end
|
126
|
-
|
127
|
-
it "search random Document" do
|
128
|
-
info = @myCollection.random
|
129
|
-
expect(info.collection.name).to eq "MyCollection"
|
130
|
-
end
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
context "#modify" do
|
136
|
-
it "load" do
|
137
|
-
myCollection = @myCollection.load
|
138
|
-
expect(myCollection.collection).to eq "MyCollection"
|
139
|
-
end
|
140
|
-
|
141
|
-
it "unload" do
|
142
|
-
myCollection = @myCollection.unload
|
143
|
-
expect(myCollection.collection).to eq "MyCollection"
|
144
|
-
end
|
145
|
-
|
146
|
-
it "change" do
|
147
|
-
myCollection = @myCollection.change waitForSync: true
|
148
|
-
expect(myCollection.body["waitForSync"]).to be true
|
149
|
-
end
|
150
|
-
|
151
|
-
it "rename" do
|
152
|
-
myCollection = @myCollection.rename "MyCollection2"
|
153
|
-
expect(myCollection.collection).to eq "MyCollection2"
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
context "#truncate" do
|
158
|
-
it "truncate a Collection" do
|
159
|
-
myCollection = @myCollection.truncate
|
160
|
-
expect(myCollection.count).to eq 0
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context "#destroy" do
|
165
|
-
it "delete a Collection" do
|
166
|
-
myCollection = @myCollection.destroy
|
167
|
-
expect(myCollection).to be true
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
1
|
+
require_relative './../../spec_helper'
|
2
|
+
|
3
|
+
describe ArangoCollection do
|
4
|
+
context "#new" do
|
5
|
+
it "create a new instance without global" do
|
6
|
+
myCollection = ArangoCollection.new collection: "MyCollection"
|
7
|
+
expect(myCollection.collection).to eq "MyCollection"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "create a new instance with global" do
|
11
|
+
myCollection = ArangoCollection.new
|
12
|
+
expect(myCollection.collection).to eq "MyCollection"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "create a new instance with type Edge" do
|
16
|
+
myCollection = ArangoCollection.new collection: "MyCollection", type: "Edge"
|
17
|
+
expect(myCollection.type).to eq "Edge"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "#create" do
|
22
|
+
it "create a new Collection" do
|
23
|
+
@myCollection.destroy
|
24
|
+
myCollection = @myCollection.create
|
25
|
+
expect(myCollection.collection).to eq "MyCollection"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "create a duplicate Collection" do
|
29
|
+
myCollection = @myCollection.create
|
30
|
+
expect(myCollection).to eq "duplicate name: duplicate name"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "create a new Edge Collection" do
|
34
|
+
@myEdgeCollection.destroy
|
35
|
+
myCollection = @myEdgeCollection.create_edge_collection
|
36
|
+
expect(myCollection.type).to eq "Edge"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "create a new Document in the Collection" do
|
40
|
+
myDocument = @myCollection.create_document document: {"Hello" => "World", "num" => 1}
|
41
|
+
expect(myDocument.body["Hello"]).to eq "World"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "create new Documents in the Collection" do
|
45
|
+
myDocument = @myCollection.create_document document: [{"Ciao" => "Mondo", "num" => 1}, {"Hallo" => "Welt", "num" => 2}]
|
46
|
+
expect(myDocument[0].body["Ciao"]).to eq "Mondo"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "create a new Edge in the Collection" do
|
50
|
+
myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
|
51
|
+
myEdge = @myEdgeCollection.create_edge from: myDoc[0].id, to: myDoc[1].id
|
52
|
+
expect(myEdge.body["_from"]).to eq myDoc[0].id
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "#info" do
|
57
|
+
it "retrieve the Collection" do
|
58
|
+
info = @myCollection.retrieve
|
59
|
+
expect(info.collection).to eq "MyCollection"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "properties of the Collection" do
|
63
|
+
info = @myCollection.properties
|
64
|
+
expect(info["name"]).to eq "MyCollection"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "documents in the Collection" do
|
68
|
+
info = @myCollection.count
|
69
|
+
expect(info).to eq 5
|
70
|
+
end
|
71
|
+
|
72
|
+
it "statistics" do
|
73
|
+
info = @myCollection.statistics
|
74
|
+
expect(info["lastTick"]).to eq 0
|
75
|
+
end
|
76
|
+
|
77
|
+
it "checksum" do
|
78
|
+
info = @myCollection.checksum
|
79
|
+
expect(info.class).to eq String
|
80
|
+
end
|
81
|
+
|
82
|
+
it "list Documents" do
|
83
|
+
info = @myCollection.allDocuments
|
84
|
+
expect(info.length).to eq 5
|
85
|
+
end
|
86
|
+
|
87
|
+
it "search Documents by match" do
|
88
|
+
info = @myCollection.documentsMatch match: {"num" => 1}
|
89
|
+
expect(info.length).to eq 3
|
90
|
+
end
|
91
|
+
|
92
|
+
it "search Document by match" do
|
93
|
+
info = @myCollection.documentMatch match: {"num" => 1}
|
94
|
+
expect(info.collection.name).to eq "MyCollection"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "search Document by key match" do
|
98
|
+
docs = @myCollection.create_document document: [{"_key" => "ThisIsATest1", "test" => "fantastic"}, {"_key" => "ThisIsATest2"}]
|
99
|
+
result = @myCollection.documentByKeys keys: ["ThisIsATest1", docs[1]]
|
100
|
+
expect(result[0].body["test"]).to eq "fantastic"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "remove Document by key match" do
|
104
|
+
docs = @myCollection.create_document document: [{"_key" => "ThisIsATest3", "test" => "fantastic"}, {"_key" => "ThisIsATest4"}]
|
105
|
+
result = @myCollection.removeByKeys keys: ["ThisIsATest3", docs[1]]
|
106
|
+
expect(result).to eq 2
|
107
|
+
end
|
108
|
+
|
109
|
+
it "remove Document by match" do
|
110
|
+
@myCollection.create_document document: [{"_key" => "ThisIsATest5", "test" => "fantastic"}, {"_key" => "ThisIsATest6"}]
|
111
|
+
result = @myCollection.removeMatch match: {"test" => "fantastic"}
|
112
|
+
expect(result).to eq 2
|
113
|
+
end
|
114
|
+
|
115
|
+
it "replace Document by match" do
|
116
|
+
@myCollection.create_document document: {"test" => "fantastic", "val" => 4}
|
117
|
+
result = @myCollection.replaceMatch match: {"test" => "fantastic"}, newValue: {"val" => 5}
|
118
|
+
expect(result).to eq 1
|
119
|
+
end
|
120
|
+
|
121
|
+
it "update Document by match" do
|
122
|
+
@myCollection.create_document document: {"test" => "fantastic2", "val" => 5}
|
123
|
+
result = @myCollection.updateMatch match: {"val" => 5}, newValue: {"val" => 6}
|
124
|
+
expect(result).to eq 2
|
125
|
+
end
|
126
|
+
|
127
|
+
it "search random Document" do
|
128
|
+
info = @myCollection.random
|
129
|
+
expect(info.collection.name).to eq "MyCollection"
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
context "#modify" do
|
136
|
+
it "load" do
|
137
|
+
myCollection = @myCollection.load
|
138
|
+
expect(myCollection.collection).to eq "MyCollection"
|
139
|
+
end
|
140
|
+
|
141
|
+
it "unload" do
|
142
|
+
myCollection = @myCollection.unload
|
143
|
+
expect(myCollection.collection).to eq "MyCollection"
|
144
|
+
end
|
145
|
+
|
146
|
+
it "change" do
|
147
|
+
myCollection = @myCollection.change waitForSync: true
|
148
|
+
expect(myCollection.body["waitForSync"]).to be true
|
149
|
+
end
|
150
|
+
|
151
|
+
it "rename" do
|
152
|
+
myCollection = @myCollection.rename "MyCollection2"
|
153
|
+
expect(myCollection.collection).to eq "MyCollection2"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context "#truncate" do
|
158
|
+
it "truncate a Collection" do
|
159
|
+
myCollection = @myCollection.truncate
|
160
|
+
expect(myCollection.count).to eq 0
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "#destroy" do
|
165
|
+
it "delete a Collection" do
|
166
|
+
myCollection = @myCollection.destroy
|
167
|
+
expect(myCollection).to be true
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -1,79 +1,79 @@
|
|
1
|
-
require_relative './../../spec_helper'
|
2
|
-
|
3
|
-
describe ArangoDocument do
|
4
|
-
context "#new" do
|
5
|
-
it "create a new Document instance without global" do
|
6
|
-
myDocument = ArangoDocument.new collection: "MyCollection", database: "MyDatabase"
|
7
|
-
expect(myDocument.collection.name).to eq "MyCollection"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "create a new instance with global" do
|
11
|
-
myDocument = ArangoDocument.new key: "myKey", body: {"Hello" => "World"}
|
12
|
-
expect(myDocument.key).to eq "myKey"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "create a new Edge instance" do
|
16
|
-
a = ArangoDocument.new(key: "myA", body: {"Hello" => "World"}).create
|
17
|
-
b = ArangoDocument.new(key: "myB", body: {"Hello" => "World"}).create
|
18
|
-
myEdgeDocument = ArangoDocument.new collection: "MyEdgeCollection", from: a, to: b
|
19
|
-
expect(myEdgeDocument.body["_from"]).to eq a.id
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "#create" do
|
24
|
-
it "create a new Document" do
|
25
|
-
@myDocument.destroy
|
26
|
-
myDocument = @myDocument.create
|
27
|
-
expect(myDocument.body["Hello"]).to eq "World"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "create a duplicate Document" do
|
31
|
-
myDocument = @myDocument.create
|
32
|
-
expect(myDocument).to eq "cannot create document, unique constraint violated"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "create a new Edge" do
|
36
|
-
myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
|
37
|
-
myEdge = ArangoDocument.new collection: "MyEdgeCollection", from: myDoc[0].id, to: myDoc[1].id
|
38
|
-
myEdge = myEdge.create
|
39
|
-
expect(myEdge.body["_from"]).to eq myDoc[0].id
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "#info" do
|
44
|
-
it "retrieve Document" do
|
45
|
-
myDocument = @myDocument.retrieve
|
46
|
-
expect(myDocument.body["Hello"]).to eq "World"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "retrieve Edges" do
|
50
|
-
@myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myDocument
|
51
|
-
myEdges = @myDocument.retrieve_edges(collection: @myEdgeCollection)
|
52
|
-
expect(myEdges.length).to eq 2
|
53
|
-
end
|
54
|
-
|
55
|
-
it "going in different directions" do
|
56
|
-
myDocument = @myDocument.in("MyEdgeCollection")[0].from.out(@myEdgeCollection)[0].to
|
57
|
-
expect(myDocument.id).to eq @myDocument.id
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "#modify" do
|
62
|
-
it "replace" do
|
63
|
-
myDocument = @myDocument.replace body: {"value" => 3}
|
64
|
-
expect(myDocument.body["value"]).to eq 3
|
65
|
-
end
|
66
|
-
|
67
|
-
it "update" do
|
68
|
-
myDocument = @myDocument.update body: {"time" => 13}
|
69
|
-
expect(myDocument.body["value"]).to eq 3
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "#destroy" do
|
74
|
-
it "delete a Document" do
|
75
|
-
result = @myDocument.destroy
|
76
|
-
expect(result).to eq true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
1
|
+
require_relative './../../spec_helper'
|
2
|
+
|
3
|
+
describe ArangoDocument do
|
4
|
+
context "#new" do
|
5
|
+
it "create a new Document instance without global" do
|
6
|
+
myDocument = ArangoDocument.new collection: "MyCollection", database: "MyDatabase"
|
7
|
+
expect(myDocument.collection.name).to eq "MyCollection"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "create a new instance with global" do
|
11
|
+
myDocument = ArangoDocument.new key: "myKey", body: {"Hello" => "World"}
|
12
|
+
expect(myDocument.key).to eq "myKey"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "create a new Edge instance" do
|
16
|
+
a = ArangoDocument.new(key: "myA", body: {"Hello" => "World"}).create
|
17
|
+
b = ArangoDocument.new(key: "myB", body: {"Hello" => "World"}).create
|
18
|
+
myEdgeDocument = ArangoDocument.new collection: "MyEdgeCollection", from: a, to: b
|
19
|
+
expect(myEdgeDocument.body["_from"]).to eq a.id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#create" do
|
24
|
+
it "create a new Document" do
|
25
|
+
@myDocument.destroy
|
26
|
+
myDocument = @myDocument.create
|
27
|
+
expect(myDocument.body["Hello"]).to eq "World"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "create a duplicate Document" do
|
31
|
+
myDocument = @myDocument.create
|
32
|
+
expect(myDocument).to eq "cannot create document, unique constraint violated"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "create a new Edge" do
|
36
|
+
myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
|
37
|
+
myEdge = ArangoDocument.new collection: "MyEdgeCollection", from: myDoc[0].id, to: myDoc[1].id
|
38
|
+
myEdge = myEdge.create
|
39
|
+
expect(myEdge.body["_from"]).to eq myDoc[0].id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "#info" do
|
44
|
+
it "retrieve Document" do
|
45
|
+
myDocument = @myDocument.retrieve
|
46
|
+
expect(myDocument.body["Hello"]).to eq "World"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "retrieve Edges" do
|
50
|
+
@myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myDocument
|
51
|
+
myEdges = @myDocument.retrieve_edges(collection: @myEdgeCollection)
|
52
|
+
expect(myEdges.length).to eq 2
|
53
|
+
end
|
54
|
+
|
55
|
+
it "going in different directions" do
|
56
|
+
myDocument = @myDocument.in("MyEdgeCollection")[0].from.out(@myEdgeCollection)[0].to
|
57
|
+
expect(myDocument.id).to eq @myDocument.id
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "#modify" do
|
62
|
+
it "replace" do
|
63
|
+
myDocument = @myDocument.replace body: {"value" => 3}
|
64
|
+
expect(myDocument.body["value"]).to eq 3
|
65
|
+
end
|
66
|
+
|
67
|
+
it "update" do
|
68
|
+
myDocument = @myDocument.update body: {"time" => 13}
|
69
|
+
expect(myDocument.body["value"]).to eq 3
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "#destroy" do
|
74
|
+
it "delete a Document" do
|
75
|
+
result = @myDocument.destroy
|
76
|
+
expect(result).to eq true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -1,65 +1,65 @@
|
|
1
|
-
require_relative './../../spec_helper'
|
2
|
-
|
3
|
-
describe ArangoVertex do
|
4
|
-
context "#new" do
|
5
|
-
it "create a new Document instance without global" do
|
6
|
-
myVertex = ArangoVertex.new collection: "MyCollection", database: "MyDatabase", graph: "MyGraph"
|
7
|
-
expect(myVertex.collection.name).to eq "MyCollection"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "create a new instance with global" do
|
11
|
-
myVertex = ArangoVertex.new key: "myKey", body: {"Hello" => "World"}
|
12
|
-
expect(myVertex.key).to eq "myKey"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "#create" do
|
17
|
-
it "create a new Document" do
|
18
|
-
@myVertex.destroy
|
19
|
-
myVertex = @myVertex.create
|
20
|
-
expect(myVertex.body["Hello"]).to eq "World"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "create a duplicate Document" do
|
24
|
-
myVertex = @myVertex.create
|
25
|
-
expect(myVertex).to eq "unique constraint violated"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "#info" do
|
30
|
-
it "retrieve Document" do
|
31
|
-
myVertex = @myVertex.retrieve
|
32
|
-
expect(myVertex.body["Hello"]).to eq "World"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "retrieve Edges" do
|
36
|
-
@myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myVertex
|
37
|
-
myEdges = @myVertex.retrieve_edges(collection: @myEdgeCollection)
|
38
|
-
expect(myEdges.length).to eq 2
|
39
|
-
end
|
40
|
-
|
41
|
-
# it "going in different directions" do
|
42
|
-
# myVertex = @myVertex.in("MyEdgeCollection")[0].from.out(@myEdgeCollection)[0].to
|
43
|
-
# expect(myVertex.id).to eq @myVertex.id
|
44
|
-
# end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "#modify" do
|
48
|
-
it "replace" do
|
49
|
-
myVertex = @myVertex.replace body: {"value" => 3}
|
50
|
-
expect(myVertex.body["value"]).to eq 3
|
51
|
-
end
|
52
|
-
|
53
|
-
it "update" do
|
54
|
-
myVertex = @myVertex.update body: {"time" => 13}
|
55
|
-
expect(myVertex.body["value"]).to eq 3
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "#destroy" do
|
60
|
-
it "delete a Document" do
|
61
|
-
result = @myVertex.destroy
|
62
|
-
expect(result).to eq true
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
1
|
+
require_relative './../../spec_helper'
|
2
|
+
|
3
|
+
describe ArangoVertex do
|
4
|
+
context "#new" do
|
5
|
+
it "create a new Document instance without global" do
|
6
|
+
myVertex = ArangoVertex.new collection: "MyCollection", database: "MyDatabase", graph: "MyGraph"
|
7
|
+
expect(myVertex.collection.name).to eq "MyCollection"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "create a new instance with global" do
|
11
|
+
myVertex = ArangoVertex.new key: "myKey", body: {"Hello" => "World"}
|
12
|
+
expect(myVertex.key).to eq "myKey"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "#create" do
|
17
|
+
it "create a new Document" do
|
18
|
+
@myVertex.destroy
|
19
|
+
myVertex = @myVertex.create
|
20
|
+
expect(myVertex.body["Hello"]).to eq "World"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "create a duplicate Document" do
|
24
|
+
myVertex = @myVertex.create
|
25
|
+
expect(myVertex).to eq "unique constraint violated"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "#info" do
|
30
|
+
it "retrieve Document" do
|
31
|
+
myVertex = @myVertex.retrieve
|
32
|
+
expect(myVertex.body["Hello"]).to eq "World"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "retrieve Edges" do
|
36
|
+
@myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myVertex
|
37
|
+
myEdges = @myVertex.retrieve_edges(collection: @myEdgeCollection)
|
38
|
+
expect(myEdges.length).to eq 2
|
39
|
+
end
|
40
|
+
|
41
|
+
# it "going in different directions" do
|
42
|
+
# myVertex = @myVertex.in("MyEdgeCollection")[0].from.out(@myEdgeCollection)[0].to
|
43
|
+
# expect(myVertex.id).to eq @myVertex.id
|
44
|
+
# end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "#modify" do
|
48
|
+
it "replace" do
|
49
|
+
myVertex = @myVertex.replace body: {"value" => 3}
|
50
|
+
expect(myVertex.body["value"]).to eq 3
|
51
|
+
end
|
52
|
+
|
53
|
+
it "update" do
|
54
|
+
myVertex = @myVertex.update body: {"time" => 13}
|
55
|
+
expect(myVertex.body["value"]).to eq 3
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "#destroy" do
|
60
|
+
it "delete a Document" do
|
61
|
+
result = @myVertex.destroy
|
62
|
+
expect(result).to eq true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,72 +1,72 @@
|
|
1
|
-
require_relative './../../spec_helper'
|
2
|
-
|
3
|
-
describe ArangoUser do
|
4
|
-
context "#new" do
|
5
|
-
it "create a new User without global" do
|
6
|
-
myUser = ArangoUser.new user: "MyUser2", password: "Test"
|
7
|
-
expect(myUser.user).to eq "MyUser2"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "create a new instance with global" do
|
11
|
-
myUser = ArangoUser.new
|
12
|
-
expect(myUser.user).to eq "MyUser"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "#create" do
|
17
|
-
it "create a new user" do
|
18
|
-
@myUser.destroy
|
19
|
-
@myUser = ArangoUser.new user: "MyUser", password: "Test"
|
20
|
-
result = @myUser.create
|
21
|
-
expect(result.user).to eq "MyUser"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "create a duplicate user" do
|
25
|
-
result = @myUser.create
|
26
|
-
expect(result).to eq "duplicate user"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "#info" do
|
31
|
-
it "retrieve User" do
|
32
|
-
myUser = @myUser.retrieve
|
33
|
-
expect(myUser.active).to be true
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "#database" do
|
38
|
-
it "grant" do
|
39
|
-
result = @myUser.grant database: @myDatabase
|
40
|
-
expect(result).to be true
|
41
|
-
end
|
42
|
-
|
43
|
-
it "databases" do
|
44
|
-
result = @myUser.databases
|
45
|
-
expect(result["MyDatabase"]).to eq "rw"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "revoke" do
|
49
|
-
result = @myUser.revoke database: @myDatabase
|
50
|
-
expect(result).to be true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "#modify" do
|
55
|
-
it "replace" do
|
56
|
-
@myUser.replace active: false, password: "Test"
|
57
|
-
expect(@myUser.active).to be false
|
58
|
-
end
|
59
|
-
|
60
|
-
it "update" do
|
61
|
-
@myUser.update active: false, password: "Test"
|
62
|
-
expect(@myUser.active).to be false
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "#destroy" do
|
67
|
-
it "destroy" do
|
68
|
-
result = @myUser.destroy
|
69
|
-
expect(result).to be true
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
1
|
+
require_relative './../../spec_helper'
|
2
|
+
|
3
|
+
describe ArangoUser do
|
4
|
+
context "#new" do
|
5
|
+
it "create a new User without global" do
|
6
|
+
myUser = ArangoUser.new user: "MyUser2", password: "Test"
|
7
|
+
expect(myUser.user).to eq "MyUser2"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "create a new instance with global" do
|
11
|
+
myUser = ArangoUser.new
|
12
|
+
expect(myUser.user).to eq "MyUser"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "#create" do
|
17
|
+
it "create a new user" do
|
18
|
+
@myUser.destroy
|
19
|
+
@myUser = ArangoUser.new user: "MyUser", password: "Test"
|
20
|
+
result = @myUser.create
|
21
|
+
expect(result.user).to eq "MyUser"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "create a duplicate user" do
|
25
|
+
result = @myUser.create
|
26
|
+
expect(result).to eq "duplicate user"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "#info" do
|
31
|
+
it "retrieve User" do
|
32
|
+
myUser = @myUser.retrieve
|
33
|
+
expect(myUser.active).to be true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "#database" do
|
38
|
+
it "grant" do
|
39
|
+
result = @myUser.grant database: @myDatabase
|
40
|
+
expect(result).to be true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "databases" do
|
44
|
+
result = @myUser.databases
|
45
|
+
expect(result["MyDatabase"]).to eq "rw"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "revoke" do
|
49
|
+
result = @myUser.revoke database: @myDatabase
|
50
|
+
expect(result).to be true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "#modify" do
|
55
|
+
it "replace" do
|
56
|
+
@myUser.replace active: false, password: "Test"
|
57
|
+
expect(@myUser.active).to be false
|
58
|
+
end
|
59
|
+
|
60
|
+
it "update" do
|
61
|
+
@myUser.update active: false, password: "Test"
|
62
|
+
expect(@myUser.active).to be false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "#destroy" do
|
67
|
+
it "destroy" do
|
68
|
+
result = @myUser.destroy
|
69
|
+
expect(result).to be true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
require "rspec"
|
2
|
-
require "arangorb"
|
3
|
-
# require_relative File.expand_path('../../lib/arangorb', __FILE__)
|
4
|
-
|
5
|
-
RSpec.configure do |config|
|
6
|
-
config.color = true
|
7
|
-
config.before(:all) do
|
8
|
-
ArangoServer.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
|
9
|
-
ArangoServer.database = "MyDatabase"
|
10
|
-
ArangoServer.collection = "MyCollection"
|
11
|
-
ArangoServer.graph = "MyGraph"
|
12
|
-
ArangoServer.user = "MyUser"
|
13
|
-
ArangoServer.verbose = false
|
14
|
-
ArangoServer.async = false
|
15
|
-
@myDatabase = ArangoDatabase.new.create
|
16
|
-
@myGraph = ArangoGraph.new.create
|
17
|
-
@myCollection = ArangoCollection.new.create
|
18
|
-
@myCollectionB = ArangoCollection.new(collection: "MyCollectionB").create
|
19
|
-
@myDocument = ArangoDocument.new(body: {"Hello" => "World", "num" => 1}, key: "FirstDocument").create
|
20
|
-
@myEdgeCollection = ArangoCollection.new(collection: "MyEdgeCollection").create_edge_collection
|
21
|
-
@myGraph.addVertexCollection collection: "MyCollection"
|
22
|
-
@myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: "MyCollection"
|
23
|
-
@myAQL = ArangoAQL.new query: "FOR u IN MyCollection RETURN u.num"
|
24
|
-
@myDoc = @myCollection.create_document document: [{"num" => 1, "_key" => "FirstKey"}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 2}, {"num" => 2}, {"num" => 2}, {"num" => 3}, {"num" => 2}, {"num" => 5}, {"num" => 2}]
|
25
|
-
@myEdgeCollection.create_edge from: [@myDoc[0].id, @myDoc[1].id, @myDoc[2].id, @myDoc[3].id, @myDoc[7].id], to: [@myDoc[4].id, @myDoc[5].id, @myDoc[6].id, @myDoc[8].id]
|
26
|
-
@myVertex = ArangoVertex.new(body: {"Hello" => "World", "num" => 1}, key: "FirstVertex").create
|
27
|
-
@vertexA = ArangoVertex.new(body: {"Hello" => "World", "num" => 1}).create
|
28
|
-
@vertexB = ArangoVertex.new(body: {"Hello" => "Moon", "num" => 2}).create
|
29
|
-
@myEdge = ArangoEdge.new(from: @vertexA, to: @vertexB, collection: "MyEdgeCollection").create
|
30
|
-
@myIndex = @myCollection.createIndex unique: false, fields: "num", type: "hash", id: "MyIndex"
|
31
|
-
@myTraversal = ArangoTraversal.new
|
32
|
-
@myUser = ArangoUser.new.create
|
33
|
-
@myTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo" => "bar", "bar" => "foo"}, period: 60
|
34
|
-
end
|
35
|
-
|
36
|
-
config.after(:all) do
|
37
|
-
ArangoDatabase.new.destroy
|
38
|
-
ArangoUser.new.destroy
|
39
|
-
@myUser.destroy unless @myUser.nil?
|
40
|
-
@myIndex.destroy unless @myIndex.nil?
|
41
|
-
end
|
42
|
-
end
|
1
|
+
require "rspec"
|
2
|
+
require "arangorb"
|
3
|
+
# require_relative File.expand_path('../../lib/arangorb', __FILE__)
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.color = true
|
7
|
+
config.before(:all) do
|
8
|
+
ArangoServer.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
|
9
|
+
ArangoServer.database = "MyDatabase"
|
10
|
+
ArangoServer.collection = "MyCollection"
|
11
|
+
ArangoServer.graph = "MyGraph"
|
12
|
+
ArangoServer.user = "MyUser"
|
13
|
+
ArangoServer.verbose = false
|
14
|
+
ArangoServer.async = false
|
15
|
+
@myDatabase = ArangoDatabase.new.create
|
16
|
+
@myGraph = ArangoGraph.new.create
|
17
|
+
@myCollection = ArangoCollection.new.create
|
18
|
+
@myCollectionB = ArangoCollection.new(collection: "MyCollectionB").create
|
19
|
+
@myDocument = ArangoDocument.new(body: {"Hello" => "World", "num" => 1}, key: "FirstDocument").create
|
20
|
+
@myEdgeCollection = ArangoCollection.new(collection: "MyEdgeCollection").create_edge_collection
|
21
|
+
@myGraph.addVertexCollection collection: "MyCollection"
|
22
|
+
@myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: "MyCollection"
|
23
|
+
@myAQL = ArangoAQL.new query: "FOR u IN MyCollection RETURN u.num"
|
24
|
+
@myDoc = @myCollection.create_document document: [{"num" => 1, "_key" => "FirstKey"}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 2}, {"num" => 2}, {"num" => 2}, {"num" => 3}, {"num" => 2}, {"num" => 5}, {"num" => 2}]
|
25
|
+
@myEdgeCollection.create_edge from: [@myDoc[0].id, @myDoc[1].id, @myDoc[2].id, @myDoc[3].id, @myDoc[7].id], to: [@myDoc[4].id, @myDoc[5].id, @myDoc[6].id, @myDoc[8].id]
|
26
|
+
@myVertex = ArangoVertex.new(body: {"Hello" => "World", "num" => 1}, key: "FirstVertex").create
|
27
|
+
@vertexA = ArangoVertex.new(body: {"Hello" => "World", "num" => 1}).create
|
28
|
+
@vertexB = ArangoVertex.new(body: {"Hello" => "Moon", "num" => 2}).create
|
29
|
+
@myEdge = ArangoEdge.new(from: @vertexA, to: @vertexB, collection: "MyEdgeCollection").create
|
30
|
+
@myIndex = @myCollection.createIndex unique: false, fields: "num", type: "hash", id: "MyIndex"
|
31
|
+
@myTraversal = ArangoTraversal.new
|
32
|
+
@myUser = ArangoUser.new.create
|
33
|
+
@myTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo" => "bar", "bar" => "foo"}, period: 60
|
34
|
+
end
|
35
|
+
|
36
|
+
config.after(:all) do
|
37
|
+
ArangoDatabase.new.destroy
|
38
|
+
ArangoUser.new.destroy
|
39
|
+
@myUser.destroy unless @myUser.nil?
|
40
|
+
@myIndex.destroy unless @myIndex.nil?
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arangorb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.6.12
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: A simple ruby client for ArangoDB
|