arangorb 1.4.1 → 2.0.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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/ArangoRB.gemspec +20 -18
  3. data/Gemfile +3 -0
  4. data/README.md +1079 -908
  5. data/lib/AQL.rb +155 -0
  6. data/lib/Batch.rb +97 -0
  7. data/lib/Cache.rb +71 -0
  8. data/lib/Collection.rb +852 -0
  9. data/lib/Database.rb +417 -0
  10. data/lib/Document.rb +346 -0
  11. data/lib/Edge.rb +104 -0
  12. data/lib/Error.rb +125 -0
  13. data/lib/Foxx.rb +277 -0
  14. data/lib/Graph.rb +325 -0
  15. data/lib/Index.rb +126 -0
  16. data/lib/Replication.rb +235 -0
  17. data/lib/Request.rb +143 -0
  18. data/lib/Server.rb +466 -0
  19. data/lib/Task.rb +120 -0
  20. data/lib/Transaction.rb +115 -0
  21. data/lib/Traversal.rb +224 -0
  22. data/lib/User.rb +197 -0
  23. data/lib/Vertex.rb +127 -0
  24. data/lib/View.rb +151 -0
  25. data/lib/arangorb.rb +23 -15
  26. data/lib/helpers/Error.rb +28 -0
  27. data/lib/helpers/Return.rb +53 -0
  28. metadata +64 -45
  29. data/lib/ArangoRB_AQL.rb +0 -181
  30. data/lib/ArangoRB_Cache.rb +0 -174
  31. data/lib/ArangoRB_Col.rb +0 -526
  32. data/lib/ArangoRB_DB.rb +0 -363
  33. data/lib/ArangoRB_Doc.rb +0 -319
  34. data/lib/ArangoRB_Edg.rb +0 -184
  35. data/lib/ArangoRB_Gra.rb +0 -201
  36. data/lib/ArangoRB_Index.rb +0 -135
  37. data/lib/ArangoRB_Replication.rb +0 -261
  38. data/lib/ArangoRB_Ser.rb +0 -446
  39. data/lib/ArangoRB_Task.rb +0 -129
  40. data/lib/ArangoRB_Tra.rb +0 -169
  41. data/lib/ArangoRB_Tran.rb +0 -68
  42. data/lib/ArangoRB_User.rb +0 -157
  43. data/lib/ArangoRB_Ver.rb +0 -162
  44. data/spec/arangoRB_helper.rb +0 -4
  45. data/spec/arangoRestart_helper.rb +0 -14
  46. data/spec/arangorb-1.3.0.gem +0 -0
  47. data/spec/lib/0.1.0/arangoAQL_helper.rb +0 -64
  48. data/spec/lib/0.1.0/arangoC_helper.rb +0 -170
  49. data/spec/lib/0.1.0/arangoDB_helper.rb +0 -119
  50. data/spec/lib/0.1.0/arangoDoc_helper.rb +0 -79
  51. data/spec/lib/0.1.0/arangoE_helper.rb +0 -50
  52. data/spec/lib/0.1.0/arangoG_helper.rb +0 -78
  53. data/spec/lib/0.1.0/arangoS_helper.rb +0 -37
  54. data/spec/lib/0.1.0/arangoT_helper.rb +0 -48
  55. data/spec/lib/0.1.0/arangoV_helper.rb +0 -65
  56. data/spec/lib/1.0.0/arangoC_helper.rb +0 -73
  57. data/spec/lib/1.0.0/arangoDB_helper.rb +0 -48
  58. data/spec/lib/1.0.0/arangoI_helper.rb +0 -43
  59. data/spec/lib/1.0.0/arangoS_helper.rb +0 -192
  60. data/spec/lib/1.0.0/arangoTa_helper.rb +0 -49
  61. data/spec/lib/1.0.0/arangoTr_helper.rb +0 -15
  62. data/spec/lib/1.0.0/arangoU_helper.rb +0 -72
  63. data/spec/lib/1.1.0/arangoRB_helper.rb +0 -144
  64. data/spec/lib/1.1.0/arangoRB_walks_helper.rb +0 -19
  65. data/spec/lib/1.2.0/arangoCache_helper.rb +0 -66
  66. data/spec/lib/1.3.0/arangoHash_helper.rb +0 -30
  67. data/spec/lib/arangoRB_0.1.0_helper.rb +0 -9
  68. data/spec/lib/arangoRB_1.0.0_helper.rb +0 -6
  69. data/spec/lib/arangoRB_1.1.0_helper.rb +0 -2
  70. data/spec/lib/arangoRB_1.2.0_helper.rb +0 -2
  71. data/spec/spec_helper.rb +0 -42
@@ -1,43 +0,0 @@
1
- require_relative './../../spec_helper'
2
-
3
- describe ArangoIndex do
4
- context "#new" do
5
- it "create a new Index without global" do
6
- myIndex = ArangoIndex.new collection: @myCollection, database: @myDatabase, fields: "num", unique: false, id: "myIndex"
7
- expect(myIndex.id).to eq "myIndex"
8
- end
9
-
10
- it "create a new Index with global" do
11
- myIndex = ArangoIndex.new fields: "num", unique: false, id: "myIndex2"
12
- expect(myIndex.id).to eq "myIndex2"
13
- end
14
- end
15
-
16
- context "#create" do
17
- it "create a new Index" do
18
- result = @myIndex.create
19
- expect(result.type).to eq "hash"
20
- end
21
- end
22
-
23
- context "#retrieve" do
24
- it "retrieve an Index" do
25
- result = @myIndex.retrieve
26
- expect(result.type).to eq "hash"
27
- end
28
- end
29
-
30
- context "#info" do
31
- it "list Indexes" do
32
- result = ArangoIndex.indexes
33
- expect(result["indexes"][0].class).to be ArangoIndex
34
- end
35
- end
36
-
37
- context "#destroy" do
38
- it "destroy" do
39
- result = @myIndex.destroy
40
- expect(result).to be true
41
- end
42
- end
43
- end
@@ -1,192 +0,0 @@
1
- require_relative './../../spec_helper'
2
-
3
- describe ArangoServer do
4
- context "#general" do
5
- it "address" do
6
- expect(ArangoServer.address).to eq "localhost:8529"
7
- end
8
-
9
- it "username" do
10
- expect(ArangoServer.username).to eq "root"
11
- end
12
-
13
- it "request" do
14
- expect(ArangoServer.request[":body"].class).to be NilClass
15
- end
16
- end
17
-
18
- context "#user" do
19
- it "setup a global user" do
20
- ArangoServer.user = "MyUser2"
21
- expect(ArangoServer.user.name).to eq "MyUser2"
22
- end
23
- end
24
-
25
- context "#monitoring" do
26
- it "log" do
27
- expect(ArangoServer.log["totalAmount"]).to be >= 0
28
- end
29
-
30
- it "reload" do
31
- expect(ArangoServer.reload).to be true
32
- end
33
-
34
- it "statistics" do
35
- expect(ArangoServer.statistics["enabled"]).to be true
36
- end
37
-
38
- it "statisticsDescription" do
39
- expect(ArangoServer.statistics(description: true)["groups"][0].nil?).to be false
40
- end
41
-
42
- it "role" do
43
- expect(ArangoServer.role.class).to eq String
44
- end
45
-
46
- # it "server" do
47
- # expect(ArangoServer.server.class).to eq String
48
- # end
49
-
50
- it "serverID" do
51
- expect(ArangoServer.serverId.to_i).to be >= 1
52
- end
53
-
54
- # it "clusterStatistics" do
55
- # expect(ArangoServer.clusterStatistics.class).to eq String
56
- # end
57
- end
58
-
59
- context "#lists" do
60
- it "endpoints" do
61
- expect(ArangoServer.endpoints[0].keys[0]).to eq "endpoint"
62
- end
63
-
64
- it "users" do
65
- expect(ArangoServer.users[0].class).to be ArangoUser
66
- end
67
-
68
- it "databases" do
69
- expect(ArangoServer.databases[0].class).to be ArangoDatabase
70
- end
71
- end
72
-
73
- context "#async" do
74
- it "create async" do
75
- ArangoServer.async = "store"
76
- expect(ArangoServer.async).to eq "store"
77
- end
78
-
79
- it "pendingAsync" do
80
- ArangoServer.async = "store"
81
- ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
82
- expect(ArangoServer.pendingAsync).to eq []
83
- end
84
-
85
- it "fetchAsync" do
86
- ArangoServer.async = "store"
87
- id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
88
- expect(ArangoServer.fetchAsync(id: id)["count"]).to eq 18
89
- end
90
-
91
- it "retrieveAsync" do
92
- ArangoServer.async = "store"
93
- ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
94
- expect(ArangoServer.retrievePendingAsync).to eq []
95
- end
96
-
97
- it "cancelAsync" do
98
- ArangoServer.async = "store"
99
- id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
100
- expect(ArangoServer.cancelAsync(id: id)).to eq "not found"
101
- end
102
-
103
- it "destroyAsync" do
104
- ArangoServer.async = "store"
105
- id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
106
- expect(ArangoServer.destroyAsync type: id).to be true
107
- end
108
- end
109
-
110
- context "#batch" do
111
- it "batch" do
112
- ArangoServer.async = false
113
- ArangoCollection.new.create
114
- queries = [{
115
- "type": "POST",
116
- "address": "/_db/MyDatabase/_api/collection",
117
- "body": {"name": "newCOLLECTION"},
118
- "id": "1"
119
- },
120
- {
121
- "type": "GET",
122
- "address": "/_api/database",
123
- "id": "2"
124
- }]
125
- expect((ArangoServer.batch queries: queries).class).to be String
126
- end
127
-
128
- it "createDumpBatch" do
129
- expect((ArangoServer.createDumpBatch ttl: 100).to_i).to be > 1
130
- end
131
-
132
- it "prolongDumpBatch" do
133
- dumpBatchID = ArangoServer.createDumpBatch ttl: 100
134
- expect((ArangoServer.prolongDumpBatch ttl: 100, id: dumpBatchID).to_i).to be > 1
135
- end
136
-
137
- it "destroyDumpBatch" do
138
- dumpBatchID = ArangoServer.createDumpBatch ttl: 100
139
- expect(ArangoServer.destroyDumpBatch id: dumpBatchID).to be true
140
- end
141
- end
142
-
143
- context "#task" do
144
- it "tasks" do
145
- result = ArangoServer.tasks
146
- expect(result[0].id.class).to be String
147
- end
148
- end
149
-
150
- context "#miscellaneous" do
151
- it "version" do
152
- expect(ArangoServer.version["server"]).to eq "arango"
153
- end
154
-
155
- it "propertyWAL" do
156
- ArangoServer.changePropertyWAL historicLogfiles: 14
157
- expect(ArangoServer.propertyWAL["historicLogfiles"]).to eq 14
158
- end
159
-
160
- it "flushWAL" do
161
- expect(ArangoServer.flushWAL).to be true
162
- end
163
-
164
- it "transactions" do
165
- expect(ArangoServer.transactions["runningTransactions"]).to be >= 0
166
- end
167
-
168
- it "time" do
169
- expect(ArangoServer.time.class).to be Float
170
- end
171
-
172
- it "echo" do
173
- expect(ArangoServer.echo["user"]).to eq "root"
174
- end
175
-
176
- it "databaseVersion" do
177
- expect(ArangoServer.databaseVersion.to_i).to be >= 1
178
- end
179
-
180
- it "sleep" do
181
- expect(ArangoServer.sleep duration: 10).to be >= 1
182
- end
183
-
184
- # it "shutdown" do
185
- # result = ArangoServer.shutdown
186
- # `sudo service arangodb restart`
187
- # expect(result).to eq "OK"
188
- # end
189
- end
190
-
191
-
192
- end
@@ -1,49 +0,0 @@
1
- require_relative './../../spec_helper'
2
-
3
- describe ArangoTask do
4
- context "#new" do
5
- it "create new instance" do
6
- myArangoTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo" => "bar", "bar" => "foo"}, period: 2
7
- expect(myArangoTask.params["foo"]).to eq "bar"
8
- end
9
- end
10
-
11
- context "#create" do
12
- it "create a new Task instance" do
13
- myArangoTask = ArangoTask.new name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo" => "bar", "bar" => "foo"}, period: 2
14
- expect(myArangoTask.create.created.class).to eq Float
15
- end
16
-
17
- it "create a new Task instance with ID" do
18
- myArangoTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo2" => "bar2", "bar2" => "foo2"}, period: 2
19
- expect(myArangoTask.create.params["foo2"]).to eq "bar2"
20
- end
21
-
22
- it "duplilcate a Task instance with ID" do
23
- myArangoTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo21" => "bar2", "bar21" => "foo21"}, period: 2
24
- expect(myArangoTask.create).to eq "duplicate task id"
25
- end
26
- end
27
-
28
- context "#retrieve" do
29
- it "retrieve lists" do
30
- myArangoTask = ArangoTask.new name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo2" => "bar2", "bar2" => "foo2"}, period: 2
31
- myArangoTask.create
32
- result = ArangoTask.tasks.map{|x| x.database.name}
33
- expect(result.include? 'MyDatabase').to be true
34
- end
35
-
36
- it "retrieve" do
37
- myArangoTask = ArangoTask.new name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo2" => "bar2", "bar2" => "foo2"}, period: 2
38
- myArangoTask.create
39
- expect(myArangoTask.retrieve.params["foo2"]).to eq "bar2"
40
- end
41
- end
42
-
43
- context "#destroy" do
44
- it "destroy" do
45
- myArangoTask = ArangoTask.new id: "mytaskid"
46
- expect(myArangoTask.destroy).to be true
47
- end
48
- end
49
- end
@@ -1,15 +0,0 @@
1
- require_relative './../../spec_helper'
2
-
3
- describe ArangoTransaction do
4
- context "#new and use" do
5
- it "create new instance" do
6
- myArangoTransaction = ArangoTransaction.new action: "function(){ var db = require('@arangodb').db; db.MyCollection.save({}); return db.MyCollection.count(); }", write: @myCollection
7
- expect(myArangoTransaction.collections["write"][0].name).to eq "MyCollection"
8
- end
9
-
10
- it "execute" do
11
- myArangoTransaction = ArangoTransaction.new action: "function(){ var db = require('@arangodb').db; db.MyCollection.save({}); return db.MyCollection.count(); }", write: @myCollection
12
- expect(myArangoTransaction.execute).to be >= 1
13
- end
14
- end
15
- end
@@ -1,72 +0,0 @@
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,144 +0,0 @@
1
- require_relative './../../spec_helper'
2
-
3
- describe ArangoDatabase do
4
- context "#retrieve" do
5
- it "collection" do
6
- expect(@myDatabase["MyCollection"].class).to be ArangoCollection
7
- end
8
-
9
- it "collection" do
10
- expect(@myDatabase.collection("MyCollection").class).to be ArangoCollection
11
- end
12
-
13
- it "graph" do
14
- expect(@myDatabase.graph("MyGraph").class).to be ArangoGraph
15
- end
16
- end
17
- end
18
-
19
- describe ArangoCollection do
20
- context "#retrieve" do
21
- it "document" do
22
- expect(@myCollection["MyDocument"].class).to be ArangoDocument
23
- end
24
-
25
- it "database" do
26
- expect(@myCollection.database.class).to be ArangoDatabase
27
- end
28
- end
29
- end
30
-
31
- describe ArangoDocument do
32
- context "#retrieve" do
33
- it "collection" do
34
- expect(@myDocument.collection.class).to be ArangoCollection
35
- end
36
-
37
- it "database" do
38
- expect(@myDocument.database.class).to be ArangoDatabase
39
- end
40
- end
41
- end
42
-
43
- describe ArangoVertex do
44
- context "#retrieve" do
45
- it "collection" do
46
- expect(@myVertex.collection.class).to be ArangoCollection
47
- end
48
-
49
- it "database" do
50
- expect(@myVertex.database.class).to be ArangoDatabase
51
- end
52
-
53
- it "graph" do
54
- expect(@myVertex.graph.class).to be ArangoGraph
55
- end
56
- end
57
- end
58
-
59
- describe ArangoEdge do
60
- context "#retrieve" do
61
- it "collection" do
62
- expect(@myEdge.collection.class).to be ArangoCollection
63
- end
64
-
65
- it "database" do
66
- expect(@myEdge.database.class).to be ArangoDatabase
67
- end
68
-
69
- it "graph" do
70
- expect(@myEdge.graph.class).to be ArangoGraph
71
- end
72
- end
73
- end
74
-
75
-
76
- describe ArangoGraph do
77
- context "#retrieve" do
78
- it "database" do
79
- expect(@myGraph.database.class).to be ArangoDatabase
80
- end
81
- end
82
- end
83
-
84
- describe ArangoIndex do
85
- context "#retrieve" do
86
- it "collection" do
87
- expect(@myIndex.collection.class).to be ArangoCollection
88
- end
89
-
90
- it "database" do
91
- expect(@myIndex.database.class).to be ArangoDatabase
92
- end
93
- end
94
- end
95
-
96
- describe ArangoTask do
97
- context "#retrieve" do
98
- it "database" do
99
- expect(@myTask.database.class).to be ArangoDatabase
100
- end
101
- end
102
- end
103
-
104
- describe ArangoTraversal do
105
- context "#retrieve" do
106
- it "database" do
107
- @myTraversal.vertex = @myDoc[0]
108
- @myTraversal.graph = @myGraph
109
- @myTraversal.collection = @myEdgeCollection
110
- @myTraversal.in
111
- expect(@myTraversal.database.class).to be ArangoDatabase
112
- end
113
-
114
- it "graph" do
115
- expect(@myTraversal.graph.class).to be ArangoGraph
116
- end
117
-
118
- it "vertex" do
119
- expect(@myTraversal.vertex.class).to be ArangoDocument
120
- end
121
-
122
- it "collection" do
123
- expect(@myTraversal.collection.class).to be ArangoCollection
124
- end
125
- end
126
- end
127
-
128
- describe ArangoUser do
129
- context "#retrieve" do
130
- it "database" do
131
- expect(@myUser["MyDatabase"].class).to be String
132
- end
133
-
134
- it "database" do
135
- @myUser.grant database: @myDatabase
136
- expect(@myUser["MyDatabase"].class).to be ArangoDatabase
137
- end
138
-
139
- it "database" do
140
- @myUser.revoke database: @myDatabase
141
- expect(@myUser["MyDatabase"].class).to be String
142
- end
143
- end
144
- end