arangorb 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/ArangoRB.gemspec +18 -18
  3. data/Gemfile +8 -7
  4. data/LICENSE +21 -21
  5. data/README.md +906 -867
  6. data/lib/ArangoRB_AQL.rb +181 -160
  7. data/lib/ArangoRB_Cache.rb +174 -174
  8. data/lib/ArangoRB_Col.rb +526 -499
  9. data/lib/ArangoRB_DB.rb +363 -339
  10. data/lib/ArangoRB_Doc.rb +319 -298
  11. data/lib/ArangoRB_Edg.rb +184 -169
  12. data/lib/ArangoRB_Gra.rb +201 -180
  13. data/lib/ArangoRB_Index.rb +135 -115
  14. data/lib/ArangoRB_Replication.rb +261 -0
  15. data/lib/ArangoRB_Ser.rb +446 -441
  16. data/lib/ArangoRB_Task.rb +129 -113
  17. data/lib/ArangoRB_Tra.rb +169 -142
  18. data/lib/ArangoRB_Tran.rb +68 -53
  19. data/lib/ArangoRB_User.rb +149 -136
  20. data/lib/ArangoRB_Ver.rb +162 -147
  21. data/lib/arangorb.rb +16 -15
  22. data/spec/arangoRB_helper.rb +4 -4
  23. data/spec/arangoRestart_helper.rb +14 -14
  24. data/spec/lib/0.1.0/arangoAQL_helper.rb +64 -64
  25. data/spec/lib/0.1.0/arangoC_helper.rb +170 -170
  26. data/spec/lib/0.1.0/arangoDB_helper.rb +119 -119
  27. data/spec/lib/0.1.0/arangoDoc_helper.rb +79 -79
  28. data/spec/lib/0.1.0/arangoE_helper.rb +50 -50
  29. data/spec/lib/0.1.0/arangoG_helper.rb +78 -78
  30. data/spec/lib/0.1.0/arangoS_helper.rb +37 -37
  31. data/spec/lib/0.1.0/arangoT_helper.rb +48 -48
  32. data/spec/lib/0.1.0/arangoV_helper.rb +65 -65
  33. data/spec/lib/1.0.0/arangoC_helper.rb +73 -73
  34. data/spec/lib/1.0.0/arangoDB_helper.rb +48 -48
  35. data/spec/lib/1.0.0/arangoI_helper.rb +43 -43
  36. data/spec/lib/1.0.0/arangoS_helper.rb +192 -192
  37. data/spec/lib/1.0.0/arangoTa_helper.rb +49 -49
  38. data/spec/lib/1.0.0/arangoTr_helper.rb +15 -15
  39. data/spec/lib/1.0.0/arangoU_helper.rb +72 -72
  40. data/spec/lib/1.1.0/arangoRB_helper.rb +144 -144
  41. data/spec/lib/1.1.0/arangoRB_walks_helper.rb +19 -19
  42. data/spec/lib/1.2.0/arangoCache_helper.rb +66 -66
  43. data/spec/lib/1.3.0/arangoHash_helper.rb +30 -0
  44. data/spec/lib/arangoRB_0.1.0_helper.rb +9 -9
  45. data/spec/lib/arangoRB_1.0.0_helper.rb +6 -6
  46. data/spec/lib/arangoRB_1.1.0_helper.rb +2 -2
  47. data/spec/lib/arangoRB_1.2.0_helper.rb +2 -1
  48. data/spec/spec_helper.rb +41 -41
  49. metadata +6 -5
@@ -1,15 +1,16 @@
1
- require "httparty"
2
- require_relative "ArangoRB_Ser"
3
- require_relative "ArangoRB_DB"
4
- require_relative "ArangoRB_Col"
5
- require_relative "ArangoRB_Doc"
6
- require_relative "ArangoRB_Gra"
7
- require_relative "ArangoRB_Ver"
8
- require_relative "ArangoRB_Edg"
9
- require_relative "ArangoRB_Tra"
10
- require_relative "ArangoRB_AQL"
11
- require_relative "ArangoRB_User"
12
- require_relative "ArangoRB_Index"
13
- require_relative "ArangoRB_Task"
14
- require_relative "ArangoRB_Tran"
15
- require_relative "ArangoRB_Cache"
1
+ require "httparty"
2
+ require_relative "ArangoRB_Ser"
3
+ require_relative "ArangoRB_DB"
4
+ require_relative "ArangoRB_Col"
5
+ require_relative "ArangoRB_Doc"
6
+ require_relative "ArangoRB_Gra"
7
+ require_relative "ArangoRB_Ver"
8
+ require_relative "ArangoRB_Edg"
9
+ require_relative "ArangoRB_Tra"
10
+ require_relative "ArangoRB_AQL"
11
+ require_relative "ArangoRB_User"
12
+ require_relative "ArangoRB_Index"
13
+ require_relative "ArangoRB_Task"
14
+ require_relative "ArangoRB_Tran"
15
+ require_relative "ArangoRB_Cache"
16
+ require_relative "ArangoRB_Replication"
@@ -1,4 +1,4 @@
1
- require "lib/arangoRB_0.1.0_helper"
2
- require "lib/arangoRB_1.0.0_helper"
3
- require "lib/arangoRB_1.1.0_helper"
4
- require "lib/arangoRB_1.2.0_helper"
1
+ require "lib/arangoRB_0.1.0_helper"
2
+ require "lib/arangoRB_1.0.0_helper"
3
+ require "lib/arangoRB_1.1.0_helper"
4
+ require "lib/arangoRB_1.2.0_helper"
@@ -1,14 +1,14 @@
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
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
@@ -1,64 +1,64 @@
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
+ 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 +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 "cannot create collection: 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 "cannot create collection: 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