arangorb 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ArangoRB.gemspec +20 -18
- data/Gemfile +3 -0
- data/README.md +1079 -908
- data/lib/AQL.rb +155 -0
- data/lib/Batch.rb +97 -0
- data/lib/Cache.rb +71 -0
- data/lib/Collection.rb +852 -0
- data/lib/Database.rb +417 -0
- data/lib/Document.rb +346 -0
- data/lib/Edge.rb +104 -0
- data/lib/Error.rb +125 -0
- data/lib/Foxx.rb +277 -0
- data/lib/Graph.rb +325 -0
- data/lib/Index.rb +126 -0
- data/lib/Replication.rb +235 -0
- data/lib/Request.rb +143 -0
- data/lib/Server.rb +466 -0
- data/lib/Task.rb +120 -0
- data/lib/Transaction.rb +115 -0
- data/lib/Traversal.rb +224 -0
- data/lib/User.rb +197 -0
- data/lib/Vertex.rb +127 -0
- data/lib/View.rb +151 -0
- data/lib/arangorb.rb +23 -15
- data/lib/helpers/Error.rb +28 -0
- data/lib/helpers/Return.rb +53 -0
- metadata +64 -45
- data/lib/ArangoRB_AQL.rb +0 -181
- data/lib/ArangoRB_Cache.rb +0 -174
- data/lib/ArangoRB_Col.rb +0 -526
- data/lib/ArangoRB_DB.rb +0 -363
- data/lib/ArangoRB_Doc.rb +0 -319
- data/lib/ArangoRB_Edg.rb +0 -184
- data/lib/ArangoRB_Gra.rb +0 -201
- data/lib/ArangoRB_Index.rb +0 -135
- data/lib/ArangoRB_Replication.rb +0 -261
- data/lib/ArangoRB_Ser.rb +0 -446
- data/lib/ArangoRB_Task.rb +0 -129
- data/lib/ArangoRB_Tra.rb +0 -169
- data/lib/ArangoRB_Tran.rb +0 -68
- data/lib/ArangoRB_User.rb +0 -157
- data/lib/ArangoRB_Ver.rb +0 -162
- data/spec/arangoRB_helper.rb +0 -4
- data/spec/arangoRestart_helper.rb +0 -14
- data/spec/arangorb-1.3.0.gem +0 -0
- data/spec/lib/0.1.0/arangoAQL_helper.rb +0 -64
- data/spec/lib/0.1.0/arangoC_helper.rb +0 -170
- data/spec/lib/0.1.0/arangoDB_helper.rb +0 -119
- data/spec/lib/0.1.0/arangoDoc_helper.rb +0 -79
- data/spec/lib/0.1.0/arangoE_helper.rb +0 -50
- data/spec/lib/0.1.0/arangoG_helper.rb +0 -78
- data/spec/lib/0.1.0/arangoS_helper.rb +0 -37
- data/spec/lib/0.1.0/arangoT_helper.rb +0 -48
- data/spec/lib/0.1.0/arangoV_helper.rb +0 -65
- data/spec/lib/1.0.0/arangoC_helper.rb +0 -73
- data/spec/lib/1.0.0/arangoDB_helper.rb +0 -48
- data/spec/lib/1.0.0/arangoI_helper.rb +0 -43
- data/spec/lib/1.0.0/arangoS_helper.rb +0 -192
- data/spec/lib/1.0.0/arangoTa_helper.rb +0 -49
- data/spec/lib/1.0.0/arangoTr_helper.rb +0 -15
- data/spec/lib/1.0.0/arangoU_helper.rb +0 -72
- data/spec/lib/1.1.0/arangoRB_helper.rb +0 -144
- data/spec/lib/1.1.0/arangoRB_walks_helper.rb +0 -19
- data/spec/lib/1.2.0/arangoCache_helper.rb +0 -66
- data/spec/lib/1.3.0/arangoHash_helper.rb +0 -30
- data/spec/lib/arangoRB_0.1.0_helper.rb +0 -9
- data/spec/lib/arangoRB_1.0.0_helper.rb +0 -6
- data/spec/lib/arangoRB_1.1.0_helper.rb +0 -2
- data/spec/lib/arangoRB_1.2.0_helper.rb +0 -2
- data/spec/spec_helper.rb +0 -42
data/lib/ArangoRB_Ver.rb
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
# === GRAPH VERTEX ===
|
2
|
-
|
3
|
-
# ==== DOCUMENT ====
|
4
|
-
|
5
|
-
class ArangoVertex < ArangoDocument
|
6
|
-
def initialize(key: nil, collection: @@collection, graph: @@graph, database: @@database, body: {}) # TESTED
|
7
|
-
if collection.is_a?(String)
|
8
|
-
@collection = collection
|
9
|
-
elsif collection.is_a?(ArangoCollection)
|
10
|
-
@collection = collection.collection
|
11
|
-
else
|
12
|
-
raise "collection should be a String or an ArangoCollection instance, not a #{collection.class}"
|
13
|
-
end
|
14
|
-
|
15
|
-
if graph.is_a?(String)
|
16
|
-
@graph = graph
|
17
|
-
elsif graph.is_a?(ArangoGraph)
|
18
|
-
@graph = graph.graph
|
19
|
-
else
|
20
|
-
raise "graph should be a String or an ArangoGraph instance, not a #{graph.class}"
|
21
|
-
end
|
22
|
-
|
23
|
-
if database.is_a?(String)
|
24
|
-
@database = database
|
25
|
-
else
|
26
|
-
raise "database should be a String, not a #{database.class}"
|
27
|
-
end
|
28
|
-
|
29
|
-
if key.is_a?(String) || key.nil?
|
30
|
-
@key = key
|
31
|
-
unless key.nil?
|
32
|
-
body["_key"] = @key
|
33
|
-
@id = "#{@collection}/#{@key}"
|
34
|
-
end
|
35
|
-
elsif key.is_a?(ArangoDocument)
|
36
|
-
@key = key.key
|
37
|
-
@id = key.id
|
38
|
-
else
|
39
|
-
raise "key should be a String, not a #{key.class}"
|
40
|
-
end
|
41
|
-
|
42
|
-
if body.is_a?(Hash)
|
43
|
-
@body = body
|
44
|
-
else
|
45
|
-
raise "body should be a Hash, not a #{body.class}"
|
46
|
-
end
|
47
|
-
@idCache = "VER_#{@id}"
|
48
|
-
end
|
49
|
-
|
50
|
-
attr_reader :key, :id, :body, :idCache
|
51
|
-
|
52
|
-
# === RETRIEVE ===
|
53
|
-
|
54
|
-
def to_hash
|
55
|
-
{
|
56
|
-
"key" => @key,
|
57
|
-
"id" => @id,
|
58
|
-
"collection" => @collection,
|
59
|
-
"database" => @database,
|
60
|
-
"body" => @body,
|
61
|
-
"idCache" => @idCache
|
62
|
-
}.delete_if{|k,v| v.nil?}
|
63
|
-
end
|
64
|
-
alias to_h to_hash
|
65
|
-
|
66
|
-
def graph
|
67
|
-
ArangoGraph.new(graph: @graph, database: @database)
|
68
|
-
end
|
69
|
-
|
70
|
-
# === GET ===
|
71
|
-
|
72
|
-
def retrieve # TESTED
|
73
|
-
result = self.class.get("/_db/#{@database}/_api/gharial/#{@graph}/vertex/#{@id}", @@request)
|
74
|
-
return result.headers["x-arango-async-id"] if @@async == "store"
|
75
|
-
return true if @@async
|
76
|
-
result = result.parsed_response
|
77
|
-
if @@verbose
|
78
|
-
@body = result["vertex"] unless result["error"]
|
79
|
-
result
|
80
|
-
else
|
81
|
-
return result["errorMessage"] if result["error"]
|
82
|
-
@body = result["vertex"]
|
83
|
-
self
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# === POST ====
|
88
|
-
|
89
|
-
def create(body: @body, waitForSync: nil) # TESTED
|
90
|
-
query = {"waitForSync" => waitForSync}.delete_if{|k,v| v.nil?}
|
91
|
-
body["_key"] = @key if body["_key"].nil? && !@key.nil?
|
92
|
-
request = @@request.merge({ :body => body.to_json, :query => query })
|
93
|
-
result = self.class.post("/_db/#{@database}/_api/gharial/#{@graph}/vertex/#{@collection}", request)
|
94
|
-
return_result result: result, body: body
|
95
|
-
end
|
96
|
-
alias create_vertex create
|
97
|
-
|
98
|
-
# === MODIFY ===
|
99
|
-
|
100
|
-
def replace(body: {}, waitForSync: nil) # TESTED
|
101
|
-
query = { "waitForSync" => waitForSync }.delete_if{|k,v| v.nil?}
|
102
|
-
request = @@request.merge({ :body => body.to_json, :query => query })
|
103
|
-
result = self.class.put("/_db/#{@database}/_api/gharial/#{@graph}/vertex/#{@id}", request)
|
104
|
-
return_result result: result, body: body
|
105
|
-
end
|
106
|
-
|
107
|
-
def update(body: {}, waitForSync: nil, keepNull: nil) # TESTED
|
108
|
-
query = {"waitForSync" => waitForSync, "keepNull" => keepNull}.delete_if{|k,v| v.nil?}
|
109
|
-
request = @@request.merge({ :body => body.to_json, :query => query })
|
110
|
-
result = self.class.patch("/_db/#{@database}/_api/gharial/#{@graph}/vertex/#{@id}", request)
|
111
|
-
return result.headers["x-arango-async-id"] if @@async == "store"
|
112
|
-
return true if @@async
|
113
|
-
result = result.parsed_response
|
114
|
-
if @@verbose
|
115
|
-
unless result["error"]
|
116
|
-
@key = result["_key"]
|
117
|
-
@id = "#{@collection}/#{@key}"
|
118
|
-
@body = result["vertex"].body
|
119
|
-
end
|
120
|
-
result
|
121
|
-
else
|
122
|
-
return result["errorMessage"] if result["error"]
|
123
|
-
@key = result["vertex"]["_key"]
|
124
|
-
@id = "#{@collection}/#{@key}"
|
125
|
-
@body = @body.merge(body)
|
126
|
-
@body = @body.merge(result["vertex"])
|
127
|
-
self
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
# === DELETE ===
|
132
|
-
|
133
|
-
def destroy(waitForSync: nil) # TESTED
|
134
|
-
query = { "waitForSync" => waitForSync }.delete_if{|k,v| v.nil?}
|
135
|
-
request = @@request.merge({ :query => query })
|
136
|
-
result = self.class.delete("/_db/#{@database}/_api/gharial/#{@graph}/vertex/#{@id}", request)
|
137
|
-
return_result result: result, caseTrue: true
|
138
|
-
end
|
139
|
-
|
140
|
-
# === UTILITY ===
|
141
|
-
|
142
|
-
def return_result(result:, body: {}, caseTrue: false)
|
143
|
-
return result.headers["x-arango-async-id"] if @@async == "store"
|
144
|
-
return true if @@async
|
145
|
-
result = result.parsed_response
|
146
|
-
if @@verbose
|
147
|
-
unless result["error"]
|
148
|
-
@key = result["vertex"]["_key"]
|
149
|
-
@id = "#{@collection}/#{@key}"
|
150
|
-
@body = result["vertex"].merge(body)
|
151
|
-
end
|
152
|
-
result
|
153
|
-
else
|
154
|
-
return result["errorMessage"] if result["error"]
|
155
|
-
return true if caseTrue
|
156
|
-
@key = result["vertex"]["_key"]
|
157
|
-
@id = "#{@collection}/#{@key}"
|
158
|
-
@body = result["vertex"].merge(body)
|
159
|
-
self
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
data/spec/arangoRB_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
require_relative File.expand_path('../../lib/arangorb', __FILE__)
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
config.color = true
|
6
|
-
end
|
7
|
-
|
8
|
-
describe ArangoServer do
|
9
|
-
context "#restart" do
|
10
|
-
it "restart" do
|
11
|
-
print ArangoServer.restart
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/arangorb-1.3.0.gem
DELETED
Binary file
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require_relative './../../spec_helper'
|
2
|
-
|
3
|
-
describe ArangoAQL do
|
4
|
-
context "#new" do
|
5
|
-
it "create a new AQL instance" do
|
6
|
-
myAQL = ArangoAQL.new query: "FOR u IN MyCollection RETURN u.num"
|
7
|
-
expect(myAQL.query).to eq "FOR u IN MyCollection RETURN u.num"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "instantiate size" do
|
11
|
-
@myAQL.size = 5
|
12
|
-
expect(@myAQL.size).to eq 5
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "#execute" do
|
17
|
-
it "execute Transaction" do
|
18
|
-
@myAQL.execute
|
19
|
-
expect(@myAQL.result.length).to eq 5
|
20
|
-
end
|
21
|
-
|
22
|
-
it "execute again Transaction" do
|
23
|
-
@myAQL.next
|
24
|
-
expect(@myAQL.result.length).to eq 5
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "#info" do
|
29
|
-
it "explain" do
|
30
|
-
expect(@myAQL.explain["cacheable"]).to be true
|
31
|
-
end
|
32
|
-
|
33
|
-
it "parse" do
|
34
|
-
expect(@myAQL.parse["parsed"]).to be true
|
35
|
-
end
|
36
|
-
|
37
|
-
it "properties" do
|
38
|
-
expect(@myAQL.properties["enabled"]).to be true
|
39
|
-
end
|
40
|
-
|
41
|
-
it "current" do
|
42
|
-
expect(@myAQL.current).to eq []
|
43
|
-
end
|
44
|
-
|
45
|
-
it "slow" do
|
46
|
-
expect(@myAQL.slow).to eq []
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "#delete" do
|
51
|
-
it "stopSlow" do
|
52
|
-
expect(@myAQL.stopSlow).to be true
|
53
|
-
end
|
54
|
-
|
55
|
-
it "kill" do
|
56
|
-
expect(@myAQL.kill.class).to be String
|
57
|
-
end
|
58
|
-
|
59
|
-
it "changeProperties" do
|
60
|
-
result = @myAQL.changeProperties maxSlowQueries: 65
|
61
|
-
expect(result["maxSlowQueries"]).to eq 65
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,170 +0,0 @@
|
|
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,119 +0,0 @@
|
|
1
|
-
require_relative './../../spec_helper'
|
2
|
-
|
3
|
-
describe ArangoDatabase do
|
4
|
-
|
5
|
-
context "#new" do
|
6
|
-
it "create a new instance without global" do
|
7
|
-
myDatabase = ArangoDatabase.new database: "MyDatabase"
|
8
|
-
expect(myDatabase.database).to eq "MyDatabase"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "create a new instance with global" do
|
12
|
-
myDatabase = ArangoDatabase.new
|
13
|
-
expect(myDatabase.database).to eq "MyDatabase"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "#create" do
|
18
|
-
it "create a new Database" do
|
19
|
-
@myDatabase.destroy
|
20
|
-
myDatabase = @myDatabase.create
|
21
|
-
expect(myDatabase.database).to eq "MyDatabase"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "create a duplicate Database" do
|
25
|
-
myDatabase = @myDatabase.create
|
26
|
-
expect(myDatabase).to eq "duplicate name"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "#info" do
|
31
|
-
it "obtain general info" do
|
32
|
-
info = @myDatabase.info
|
33
|
-
expect(info["name"]).to eq "MyDatabase"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "list databases" do
|
37
|
-
list = ArangoDatabase.databases
|
38
|
-
expect(list.length).to be >= 1
|
39
|
-
end
|
40
|
-
|
41
|
-
it "list collections" do
|
42
|
-
list = @myDatabase.collections
|
43
|
-
expect(list.length).to be 0
|
44
|
-
end
|
45
|
-
|
46
|
-
it "list graphs" do
|
47
|
-
list = @myDatabase.graphs
|
48
|
-
expect(list.length).to be 0
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "#query" do
|
53
|
-
it "properties" do
|
54
|
-
expect(@myDatabase.propertiesQuery["enabled"]).to be true
|
55
|
-
end
|
56
|
-
|
57
|
-
it "current" do
|
58
|
-
expect(@myDatabase.currentQuery).to eq []
|
59
|
-
end
|
60
|
-
|
61
|
-
it "slow" do
|
62
|
-
expect(@myDatabase.slowQuery).to eq []
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "#delete query" do
|
67
|
-
it "stopSlow" do
|
68
|
-
expect(@myDatabase.stopSlowQuery).to be true
|
69
|
-
end
|
70
|
-
|
71
|
-
it "kill" do
|
72
|
-
@myCollection = ArangoCollection.new.create
|
73
|
-
@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}]
|
74
|
-
@myAQL.size = 3
|
75
|
-
@myAQL.execute
|
76
|
-
expect((@myDatabase.killQuery query: @myAQL).split(" ")[0]).to eq "cannot"
|
77
|
-
end
|
78
|
-
|
79
|
-
it "changeProperties" do
|
80
|
-
result = @myDatabase.changePropertiesQuery maxSlowQueries: 65
|
81
|
-
expect(result["maxSlowQueries"]).to eq 65
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "#cache" do
|
86
|
-
it "clear" do
|
87
|
-
expect(@myDatabase.clearCache).to be true
|
88
|
-
end
|
89
|
-
|
90
|
-
it "change Property Cache" do
|
91
|
-
@myDatabase.changePropertyCache maxResults: 130
|
92
|
-
expect(@myDatabase.propertyCache["maxResults"]).to eq 130
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context "#function" do
|
97
|
-
it "create Function" do
|
98
|
-
result = @myDatabase.createFunction name: "myfunctions::temperature::celsiustofahrenheit", code: "function (celsius) { return celsius * 1.8 + 32; }"
|
99
|
-
expect(result.class).to eq Hash
|
100
|
-
end
|
101
|
-
|
102
|
-
it "list Functions" do
|
103
|
-
result = @myDatabase.functions
|
104
|
-
expect(result[0]["name"]).to eq "myfunctions::temperature::celsiustofahrenheit"
|
105
|
-
end
|
106
|
-
|
107
|
-
it "delete Function" do
|
108
|
-
result = @myDatabase.deleteFunction name: "myfunctions::temperature::celsiustofahrenheit"
|
109
|
-
expect(result).to be true
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "#destroy" do
|
114
|
-
it "delete a Database" do
|
115
|
-
myDatabase = @myDatabase.destroy
|
116
|
-
expect(myDatabase).to be true
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|