relaxo 1.6.2 → 1.8.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -0
- data/lib/relaxo/changeset.rb +7 -22
- data/lib/relaxo/database.rb +14 -25
- data/lib/relaxo/dataset.rb +7 -22
- data/lib/relaxo/directory.rb +7 -22
- data/lib/relaxo/logger.rb +5 -20
- data/lib/relaxo/version.rb +5 -20
- data/lib/relaxo.rb +37 -32
- data/license.md +23 -0
- data/readme.md +153 -0
- data.tar.gz.sig +0 -0
- metadata +44 -108
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b43e712b63b0f63807a9a0c99bfeb9aa25c7e775f1594ff08081c9fb3db52cc0
|
4
|
+
data.tar.gz: 1c48257495fbf410453e08a23d9d05cc2c1be3acb64d750253be9b6f33bab8f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 498bed1e58dd6577e988d1303c8b835fea6c95785563dbe812ce570870e94a4a01d42b5a775ab54ae4e2063fdf4d5151dc4343791864e6ef3f86bbba7e781e59
|
7
|
+
data.tar.gz: 47412c47d2828083cb40bca0785cce94bf3c0b14e023f1447b689272f0b63c2ac6e876a02af66ed338b4dc717cc14090d28ebc0aed3c157de5f0fcdb88a38f2c
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�-=��B��n�U������4/E�J'�c���� ��S%`l&=0�[��>"����ݼ�����7tO�"�}�NrU����<dL�7��"[�9�PZP�>����r���#����z����� �9n:�Kz���5Me�X�8���e���}�-4�K��e��$\��@�p��cXò0YaiԶ<<�!V:����h�KG�U��ܫ�ٌ~��y<q�opr�v弭m�Wf�wvy�s�t�a\B��6�F��&q�>b)�����4������Ƴ!7�Ri���i]���.i�;5���:��D�|���>����yr�Ů�HJ�o�S�@�\;u�@c^������ױac�K/�K�Ha��I��
|
data/lib/relaxo/changeset.rb
CHANGED
@@ -1,24 +1,9 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "dataset"
|
22
7
|
|
23
8
|
module Relaxo
|
24
9
|
class Changeset < Dataset
|
@@ -53,7 +38,7 @@ module Relaxo
|
|
53
38
|
end
|
54
39
|
|
55
40
|
def write(path, object, mode = 0100644)
|
56
|
-
root, _, name = path.rpartition(
|
41
|
+
root, _, name = path.rpartition("/")
|
57
42
|
|
58
43
|
entry = @changes[path] = {
|
59
44
|
action: :upsert,
|
@@ -73,7 +58,7 @@ module Relaxo
|
|
73
58
|
alias []= write
|
74
59
|
|
75
60
|
def delete(path)
|
76
|
-
root, _, name = path.rpartition(
|
61
|
+
root, _, name = path.rpartition("/")
|
77
62
|
|
78
63
|
entry = @changes[path] = {
|
79
64
|
action: :remove,
|
data/lib/relaxo/database.rb
CHANGED
@@ -1,31 +1,17 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
|
+
# Copyright, 2017, by Huba Nagy.
|
22
6
|
|
23
|
-
|
24
|
-
|
25
|
-
require_relative
|
7
|
+
require "rugged"
|
8
|
+
|
9
|
+
require_relative "logger"
|
10
|
+
require_relative "dataset"
|
11
|
+
require_relative "changeset"
|
26
12
|
|
27
13
|
module Relaxo
|
28
|
-
HEAD =
|
14
|
+
HEAD = "HEAD".freeze
|
29
15
|
|
30
16
|
class Database
|
31
17
|
def initialize(path, branch, metadata = {})
|
@@ -46,6 +32,9 @@ module Relaxo
|
|
46
32
|
attr :metadata
|
47
33
|
attr :repository
|
48
34
|
|
35
|
+
# @attribute branch [String] The branch that this database is currently working with.
|
36
|
+
attr :branch
|
37
|
+
|
49
38
|
# Completely clear out the database.
|
50
39
|
def clear!
|
51
40
|
if head = @repository.branches[@branch]
|
@@ -134,7 +123,7 @@ module Relaxo
|
|
134
123
|
end_time = Time.now
|
135
124
|
elapsed_time = end_time - start_time
|
136
125
|
|
137
|
-
|
126
|
+
Console.debug(self) {"#{message.inspect}: %0.3fs" % elapsed_time}
|
138
127
|
end
|
139
128
|
|
140
129
|
def apply(parent, changeset, **options)
|
data/lib/relaxo/dataset.rb
CHANGED
@@ -1,26 +1,11 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
22
5
|
|
23
|
-
|
6
|
+
require "rugged"
|
7
|
+
|
8
|
+
require_relative "directory"
|
24
9
|
|
25
10
|
module Relaxo
|
26
11
|
class Dataset
|
@@ -55,7 +40,7 @@ module Relaxo
|
|
55
40
|
return false
|
56
41
|
end
|
57
42
|
|
58
|
-
def each(path =
|
43
|
+
def each(path = "", &block)
|
59
44
|
return to_enum(:each, path) unless block_given?
|
60
45
|
|
61
46
|
directory = fetch_directory(path)
|
data/lib/relaxo/directory.rb
CHANGED
@@ -1,24 +1,9 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2017-2025, by Samuel Williams.
|
5
|
+
|
6
|
+
require "rugged"
|
22
7
|
|
23
8
|
module Relaxo
|
24
9
|
class Directory
|
@@ -65,7 +50,7 @@ module Relaxo
|
|
65
50
|
end
|
66
51
|
|
67
52
|
def insert(entry)
|
68
|
-
_, _, name = entry[:name].rpartition(
|
53
|
+
_, _, name = entry[:name].rpartition("/")
|
69
54
|
|
70
55
|
@changes[name] = entry
|
71
56
|
|
@@ -74,7 +59,7 @@ module Relaxo
|
|
74
59
|
end
|
75
60
|
|
76
61
|
def delete(entry)
|
77
|
-
_, _, name = entry[:name].rpartition(
|
62
|
+
_, _, name = entry[:name].rpartition("/")
|
78
63
|
|
79
64
|
@changes[name] = nil
|
80
65
|
|
data/lib/relaxo/logger.rb
CHANGED
@@ -1,24 +1,9 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2019-2025, by Samuel Williams.
|
5
|
+
|
6
|
+
require "console"
|
22
7
|
|
23
8
|
module Relaxo
|
24
9
|
extend Console
|
data/lib/relaxo/version.rb
CHANGED
@@ -1,23 +1,8 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
20
5
|
|
21
6
|
module Relaxo
|
22
|
-
VERSION = "1.
|
7
|
+
VERSION = "1.8.0"
|
23
8
|
end
|
data/lib/relaxo.rb
CHANGED
@@ -1,56 +1,61 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
22
5
|
|
23
|
-
require
|
24
|
-
|
6
|
+
require "relaxo/database"
|
7
|
+
|
8
|
+
require "etc"
|
9
|
+
require "socket"
|
25
10
|
|
26
11
|
module Relaxo
|
27
|
-
|
12
|
+
DEFAULT_BRANCH = "main".freeze
|
28
13
|
|
29
|
-
def self.connect(path, branch: nil, sync: nil, **metadata)
|
30
|
-
|
14
|
+
def self.connect(path, branch: nil, sync: nil, create: true, **metadata)
|
15
|
+
if !File.exist?(path) || create
|
31
16
|
repository = Rugged::Repository.init_at(path, true)
|
32
17
|
|
33
|
-
if
|
34
|
-
repository.
|
18
|
+
if branch
|
19
|
+
repository.head = "refs/heads/#{branch}"
|
20
|
+
end
|
21
|
+
|
22
|
+
if sync || ENV["RELAXO_SYNC"]
|
23
|
+
repository.config["core.fsyncObjectFiles"] = true
|
35
24
|
end
|
25
|
+
else
|
26
|
+
repository = Rugged::Repository.new(path)
|
36
27
|
end
|
37
28
|
|
38
|
-
branch
|
29
|
+
# Automatically detect the current branch if `branch` is not provided:
|
30
|
+
branch ||= self.default_branch(repository)
|
39
31
|
|
40
32
|
database = Database.new(path, branch, metadata)
|
41
33
|
|
42
34
|
if config = database.config
|
43
|
-
unless config[
|
35
|
+
unless config["user.name"]
|
44
36
|
login = Etc.getpwuid
|
45
37
|
hostname = Socket.gethostname
|
46
38
|
|
47
39
|
if login
|
48
|
-
config[
|
49
|
-
config[
|
40
|
+
config["user.name"] = login.name
|
41
|
+
config["user.email"] = "#{login.name}@#{hostname}"
|
50
42
|
end
|
51
43
|
end
|
52
44
|
end
|
53
45
|
|
54
46
|
return database
|
55
47
|
end
|
56
|
-
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# Detect the default branch of the repository, taking into account unborn branches.
|
52
|
+
def self.default_branch(repository)
|
53
|
+
if head = repository.references["HEAD"]
|
54
|
+
if target_id = head.target_id
|
55
|
+
return target_id.sub(/^refs\/heads\//, "")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
return DEFAULT_BRANCH
|
60
|
+
end
|
61
|
+
end
|
data/license.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2012-2025, by Samuel Williams.
|
4
|
+
Copyright, 2017-2018, by Huba Nagy.
|
5
|
+
Copyright, 2020, by Olle Jonsson.
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
15
|
+
copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
# 
|
2
|
+
|
3
|
+
Relaxo is a transactional database built on top of git. It's aim is to provide a robust interface for document storage and sorted indexes. If you prefer a higher level interface, you can try [relaxo-model](https://github.com/ioquatix/relaxo-model).
|
4
|
+
|
5
|
+
[](https://github.com/ioquatix/relaxo/actions?workflow=Test)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
gem 'relaxo'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install relaxo
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Connect to a local database and manipulate some documents.
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
require 'relaxo'
|
29
|
+
require 'msgpack'
|
30
|
+
|
31
|
+
DB = Relaxo.connect("test")
|
32
|
+
|
33
|
+
DB.commit(message: "Create test data") do |dataset|
|
34
|
+
object = dataset.append(MessagePack.dump({bob: 'dole'}))
|
35
|
+
dataset.write("doc1.msgpack", object)
|
36
|
+
end
|
37
|
+
|
38
|
+
DB.commit(message: "Update test data") do |dataset|
|
39
|
+
doc = MessagePack.load dataset.read('doc1.msgpack').data
|
40
|
+
doc[:foo] = 'bar'
|
41
|
+
|
42
|
+
object = dataset.append(MessagePack.dump(doc))
|
43
|
+
dataset.write("doc2.msgpack", object)
|
44
|
+
end
|
45
|
+
|
46
|
+
doc = MessagePack.load DB.current['doc2.msgpack'].data
|
47
|
+
puts doc
|
48
|
+
# => {"bob"=>"dole", "foo"=>"bar"}
|
49
|
+
```
|
50
|
+
|
51
|
+
### Document Storage
|
52
|
+
|
53
|
+
Relaxo uses the git persistent data structure for storing documents. This data structure exposes a file-system like interface, which stores any kind of data. This means that you are free to use JSON, or BSON, or MessagePack, or JPEG, or XML, or any combination of those.
|
54
|
+
|
55
|
+
Relaxo has a transactional model for both reading and writing.
|
56
|
+
|
57
|
+
#### Authors
|
58
|
+
|
59
|
+
By default, Relaxo sets up the repository author using the login name and hostname of the current session. You can explicitly change this by modifying `database.config`. Additionally, you can set this per-commit:
|
60
|
+
|
61
|
+
``` ruby
|
62
|
+
database.commit(message: "Testing Enumeration", author: {user: "Alice", email: "alice@localhost"}) do |dataset|
|
63
|
+
object = dataset.append("Hello World!")
|
64
|
+
dataset.write("hello.txt", object)
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
#### Reading Files
|
69
|
+
|
70
|
+
``` ruby
|
71
|
+
path = "path/to/document"
|
72
|
+
|
73
|
+
DB.current do |dataset|
|
74
|
+
object = dataset.read(path)
|
75
|
+
|
76
|
+
puts "The object id: #{object.oid}"
|
77
|
+
puts "The object data size: #{object.size}"
|
78
|
+
puts "The object data: #{object.data.inspect}"
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Writing Files
|
83
|
+
|
84
|
+
``` ruby
|
85
|
+
path = "path/to/document"
|
86
|
+
data = MessagePack.dump(document)
|
87
|
+
|
88
|
+
DB.commit(message: "Adding document") do |changeset|
|
89
|
+
object = changeset.append(data)
|
90
|
+
changeset.write(path, object)
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
94
|
+
### Datasets and Transactions
|
95
|
+
|
96
|
+
`Dataset`s and `Changeset`s are important concepts. Relaxo doesn't allow arbitrary access to data, but instead exposes the git persistent model for both reading and writing. The implications of this are that when reading or writing, you always see a consistent snapshot of the data store.
|
97
|
+
|
98
|
+
### Suitability
|
99
|
+
|
100
|
+
Relaxo is designed to scale to the hundreds of thousands of documents. It's designed around the git persistent data store, and therefore has some performance and concurrency limitations due to the underlying implementation.
|
101
|
+
|
102
|
+
Because it maintains a full history of all changes, the repository would continue to grow over time by default, but there are mechanisms to deal with that.
|
103
|
+
|
104
|
+
#### Performance
|
105
|
+
|
106
|
+
Relaxo can do anywhere from 1000-10,000 inserts per second depending on how you structure the workload.
|
107
|
+
|
108
|
+
Relaxo Performance
|
109
|
+
Warming up --------------------------------------
|
110
|
+
single 129.000 i/100ms
|
111
|
+
Calculating -------------------------------------
|
112
|
+
single 6.224k (±14.7%) i/s - 114.036k in 20.000025s
|
113
|
+
single transaction should be fast
|
114
|
+
Warming up --------------------------------------
|
115
|
+
multiple 152.000 i/100ms
|
116
|
+
Calculating -------------------------------------
|
117
|
+
multiple 1.452k (±15.2%) i/s - 28.120k in 20.101831s
|
118
|
+
multiple transactions should be fast
|
119
|
+
|
120
|
+
Reading data is lighting fast as it's loaded directly from disk and cached.
|
121
|
+
|
122
|
+
### Loading Data
|
123
|
+
|
124
|
+
As Relaxo is unapologetically based on git, you can use git directly with a non-bare working directory to add any files you like. You can even point Relaxo at an existing git repository.
|
125
|
+
|
126
|
+
### Durability
|
127
|
+
|
128
|
+
Relaxo is based on `libgit2` and asserts that it is a transactional database. We base this assertion on:
|
129
|
+
|
130
|
+
- All writes into the object store using `libgit2` are atomic and synchronized to disk.
|
131
|
+
- All updates to refs are atomic and synchronized to disk.
|
132
|
+
|
133
|
+
Provided these two invariants are maintained, the operation of Relaxo will be safe, even if there are unexpected interruptions to the program.
|
134
|
+
|
135
|
+
The durability guarantees of Relaxo depend on [`libgit2` calling `fsync`](https://github.com/libgit2/libgit2/pull/4030), and [this being respected by the underlying hardware](http://www.evanjones.ca/intel-ssd-durability.html). Otherwise, durability cannot be guaranteed.
|
136
|
+
|
137
|
+
## Contributing
|
138
|
+
|
139
|
+
We welcome contributions to this project.
|
140
|
+
|
141
|
+
1. Fork it.
|
142
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
143
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
144
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
145
|
+
5. Create new Pull Request.
|
146
|
+
|
147
|
+
### Developer Certificate of Origin
|
148
|
+
|
149
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
150
|
+
|
151
|
+
### Community Guidelines
|
152
|
+
|
153
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaxo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
|
8
|
+
- Huba Nagy
|
9
|
+
- Olle Jonsson
|
10
|
+
autorequire:
|
9
11
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
12
|
+
cert_chain:
|
13
|
+
- |
|
14
|
+
-----BEGIN CERTIFICATE-----
|
15
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
16
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
17
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
18
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
19
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
20
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
21
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
22
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
23
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
24
|
+
e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
|
25
|
+
XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
|
26
|
+
RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
|
27
|
+
tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
|
28
|
+
zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
|
29
|
+
xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
30
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
31
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
32
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
|
33
|
+
cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
|
34
|
+
xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
|
35
|
+
c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
|
36
|
+
8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
|
37
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
38
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
39
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
40
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
41
|
+
-----END CERTIFICATE-----
|
42
|
+
date: 2025-01-11 00:00:00.000000000 Z
|
12
43
|
dependencies:
|
13
44
|
- !ruby/object:Gem::Dependency
|
14
45
|
name: console
|
@@ -38,106 +69,8 @@ dependencies:
|
|
38
69
|
- - ">="
|
39
70
|
- !ruby/object:Gem::Version
|
40
71
|
version: '0'
|
41
|
-
|
42
|
-
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bake-bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bake-modernize
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: bundler
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: covered
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: msgpack
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rspec
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '3.6'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '3.6'
|
139
|
-
description:
|
140
|
-
email:
|
72
|
+
description:
|
73
|
+
email:
|
141
74
|
executables: []
|
142
75
|
extensions: []
|
143
76
|
extra_rdoc_files: []
|
@@ -149,12 +82,15 @@ files:
|
|
149
82
|
- lib/relaxo/directory.rb
|
150
83
|
- lib/relaxo/logger.rb
|
151
84
|
- lib/relaxo/version.rb
|
85
|
+
- license.md
|
86
|
+
- readme.md
|
152
87
|
homepage: https://github.com/ioquatix/relaxo
|
153
88
|
licenses:
|
154
89
|
- MIT
|
155
90
|
metadata:
|
156
91
|
funding_uri: https://github.com/sponsors/ioquatix/
|
157
|
-
|
92
|
+
source_code_uri: https://github.com/ioquatix/relaxo.git
|
93
|
+
post_install_message:
|
158
94
|
rdoc_options: []
|
159
95
|
require_paths:
|
160
96
|
- lib
|
@@ -162,15 +98,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
98
|
requirements:
|
163
99
|
- - ">="
|
164
100
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
101
|
+
version: '3.1'
|
166
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
103
|
requirements:
|
168
104
|
- - ">="
|
169
105
|
- !ruby/object:Gem::Version
|
170
106
|
version: '0'
|
171
107
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
173
|
-
signing_key:
|
108
|
+
rubygems_version: 3.5.22
|
109
|
+
signing_key:
|
174
110
|
specification_version: 4
|
175
111
|
summary: Relaxo is versioned document database built on top of git.
|
176
112
|
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|