relaxo 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaxo/database.rb +11 -1
- data/lib/relaxo/version.rb +1 -1
- data/spec/relaxo/changeset_spec.rb +2 -4
- data/spec/relaxo/database_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 426efa86735d93046dbd4d55532954c7a99ea27e
|
4
|
+
data.tar.gz: 26d8624fe4d3277e91fb2565d1c068b3a39ff121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d504a18d7a283d7160ffb0a94d8e99bcbded19b3e408675c2d87a8dc582c28935b493cad5a1acd67d9ee984ef07243b55b8c636c6253d0dfbfdb981f26bab7b
|
7
|
+
data.tar.gz: 4824e4933d9b090385e42c3a825ff01978fe132ccddf2efee1eb342dfab7df8682aafbf11f6ab416be89f1a5a34db4fbae55bd3021b5a94cd8d7e347d2d40606
|
data/lib/relaxo/database.rb
CHANGED
@@ -41,6 +41,11 @@ module Relaxo
|
|
41
41
|
attr :metadata
|
42
42
|
attr :repository
|
43
43
|
|
44
|
+
# Completely clear out the database.
|
45
|
+
def clear!
|
46
|
+
@repository.references.delete(@repository.head)
|
47
|
+
end
|
48
|
+
|
44
49
|
def empty?
|
45
50
|
@repository.empty?
|
46
51
|
end
|
@@ -50,7 +55,10 @@ module Relaxo
|
|
50
55
|
end
|
51
56
|
|
52
57
|
# During the execution of the block, changes don't get stored immediately, so reading from the dataset (from outside the block) will continue to return the values that were stored in the configuration when the transaction was started.
|
58
|
+
# @return the result of the block.
|
53
59
|
def commit(**options)
|
60
|
+
result = nil
|
61
|
+
|
54
62
|
track_time(options[:message]) do
|
55
63
|
catch(:abort) do
|
56
64
|
begin
|
@@ -58,10 +66,12 @@ module Relaxo
|
|
58
66
|
|
59
67
|
changeset = Changeset.new(@repository, tree)
|
60
68
|
|
61
|
-
yield changeset
|
69
|
+
result = yield changeset
|
62
70
|
end until apply(parent, changeset, **options)
|
63
71
|
end
|
64
72
|
end
|
73
|
+
|
74
|
+
return result
|
65
75
|
end
|
66
76
|
|
67
77
|
# Efficient point-in-time read-only access.
|
data/lib/relaxo/version.rb
CHANGED
@@ -22,16 +22,14 @@ RSpec.describe Relaxo::Changeset do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should enumerate all documents excluding deletes" do
|
25
|
-
records =
|
26
|
-
|
27
|
-
database.commit(message: "Testing Enumeration") do |dataset|
|
25
|
+
records = database.commit(message: "Testing Enumeration") do |dataset|
|
28
26
|
5.times do |i|
|
29
27
|
dataset.delete("#{prefix}/#{i}")
|
30
28
|
end
|
31
29
|
|
32
30
|
expect(dataset.exist?("#{prefix}/0")).to be_falsey
|
33
31
|
|
34
|
-
|
32
|
+
dataset.each(prefix).to_a
|
35
33
|
end
|
36
34
|
|
37
35
|
expect(records.count).to be 15
|
@@ -24,6 +24,19 @@ RSpec.describe Relaxo::Database do
|
|
24
24
|
expect(database).to_not be_empty
|
25
25
|
end
|
26
26
|
|
27
|
+
it "should be able to clear the database" do
|
28
|
+
database.commit(message: "Create test document") do |dataset|
|
29
|
+
oid = dataset.append(sample_json)
|
30
|
+
dataset.write(document_path, oid)
|
31
|
+
end
|
32
|
+
|
33
|
+
expect(database).to_not be_empty
|
34
|
+
|
35
|
+
database.clear!
|
36
|
+
|
37
|
+
expect(database).to be_empty
|
38
|
+
end
|
39
|
+
|
27
40
|
it "should have metadata" do
|
28
41
|
expect(database[:test_key]).to be == "test_value"
|
29
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaxo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|