relaxo 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/relaxo/changeset.rb +4 -4
- data/lib/relaxo/database.rb +9 -6
- data/lib/relaxo/dataset.rb +4 -4
- data/lib/relaxo/directory.rb +4 -4
- data/lib/relaxo/logger.rb +2 -2
- data/lib/relaxo/version.rb +2 -2
- data/lib/relaxo.rb +31 -11
- data/license.md +1 -1
- data/readme.md +3 -3
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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
CHANGED
Binary file
|
data/lib/relaxo/changeset.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "dataset"
|
7
7
|
|
8
8
|
module Relaxo
|
9
9
|
class Changeset < Dataset
|
@@ -38,7 +38,7 @@ module Relaxo
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def write(path, object, mode = 0100644)
|
41
|
-
root, _, name = path.rpartition(
|
41
|
+
root, _, name = path.rpartition("/")
|
42
42
|
|
43
43
|
entry = @changes[path] = {
|
44
44
|
action: :upsert,
|
@@ -58,7 +58,7 @@ module Relaxo
|
|
58
58
|
alias []= write
|
59
59
|
|
60
60
|
def delete(path)
|
61
|
-
root, _, name = path.rpartition(
|
61
|
+
root, _, name = path.rpartition("/")
|
62
62
|
|
63
63
|
entry = @changes[path] = {
|
64
64
|
action: :remove,
|
data/lib/relaxo/database.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
# Copyright, 2017, by Huba Nagy.
|
6
6
|
|
7
|
-
require
|
7
|
+
require "rugged"
|
8
8
|
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
9
|
+
require_relative "logger"
|
10
|
+
require_relative "dataset"
|
11
|
+
require_relative "changeset"
|
12
12
|
|
13
13
|
module Relaxo
|
14
|
-
HEAD =
|
14
|
+
HEAD = "HEAD".freeze
|
15
15
|
|
16
16
|
class Database
|
17
17
|
def initialize(path, branch, metadata = {})
|
@@ -32,6 +32,9 @@ module Relaxo
|
|
32
32
|
attr :metadata
|
33
33
|
attr :repository
|
34
34
|
|
35
|
+
# @attribute branch [String] The branch that this database is currently working with.
|
36
|
+
attr :branch
|
37
|
+
|
35
38
|
# Completely clear out the database.
|
36
39
|
def clear!
|
37
40
|
if head = @repository.branches[@branch]
|
data/lib/relaxo/dataset.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "rugged"
|
7
7
|
|
8
|
-
require_relative
|
8
|
+
require_relative "directory"
|
9
9
|
|
10
10
|
module Relaxo
|
11
11
|
class Dataset
|
@@ -40,7 +40,7 @@ module Relaxo
|
|
40
40
|
return false
|
41
41
|
end
|
42
42
|
|
43
|
-
def each(path =
|
43
|
+
def each(path = "", &block)
|
44
44
|
return to_enum(:each, path) unless block_given?
|
45
45
|
|
46
46
|
directory = fetch_directory(path)
|
data/lib/relaxo/directory.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2017, by Samuel Williams.
|
4
|
+
# Copyright, 2017-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "rugged"
|
7
7
|
|
8
8
|
module Relaxo
|
9
9
|
class Directory
|
@@ -50,7 +50,7 @@ module Relaxo
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def insert(entry)
|
53
|
-
_, _, name = entry[:name].rpartition(
|
53
|
+
_, _, name = entry[:name].rpartition("/")
|
54
54
|
|
55
55
|
@changes[name] = entry
|
56
56
|
|
@@ -59,7 +59,7 @@ module Relaxo
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def delete(entry)
|
62
|
-
_, _, name = entry[:name].rpartition(
|
62
|
+
_, _, name = entry[:name].rpartition("/")
|
63
63
|
|
64
64
|
@changes[name] = nil
|
65
65
|
|
data/lib/relaxo/logger.rb
CHANGED
data/lib/relaxo/version.rb
CHANGED
data/lib/relaxo.rb
CHANGED
@@ -1,41 +1,61 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "relaxo/database"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "etc"
|
9
|
+
require "socket"
|
10
10
|
|
11
11
|
module Relaxo
|
12
|
-
|
12
|
+
DEFAULT_BRANCH = "main".freeze
|
13
13
|
|
14
14
|
def self.connect(path, branch: nil, sync: nil, create: true, **metadata)
|
15
15
|
if !File.exist?(path) || create
|
16
16
|
repository = Rugged::Repository.init_at(path, true)
|
17
17
|
|
18
|
-
if
|
19
|
-
repository.
|
18
|
+
if branch
|
19
|
+
repository.head = "refs/heads/#{branch}"
|
20
20
|
end
|
21
|
+
|
22
|
+
if sync || ENV["RELAXO_SYNC"]
|
23
|
+
repository.config["core.fsyncObjectFiles"] = true
|
24
|
+
end
|
25
|
+
else
|
26
|
+
repository = Rugged::Repository.new(path)
|
21
27
|
end
|
22
28
|
|
23
|
-
branch
|
29
|
+
# Automatically detect the current branch if `branch` is not provided:
|
30
|
+
branch ||= self.default_branch(repository)
|
24
31
|
|
25
32
|
database = Database.new(path, branch, metadata)
|
26
33
|
|
27
34
|
if config = database.config
|
28
|
-
unless config[
|
35
|
+
unless config["user.name"]
|
29
36
|
login = Etc.getpwuid
|
30
37
|
hostname = Socket.gethostname
|
31
38
|
|
32
39
|
if login
|
33
|
-
config[
|
34
|
-
config[
|
40
|
+
config["user.name"] = login.name
|
41
|
+
config["user.email"] = "#{login.name}@#{hostname}"
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
|
39
46
|
return database
|
40
47
|
end
|
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
|
41
61
|
end
|
data/license.md
CHANGED
data/readme.md
CHANGED
@@ -146,8 +146,8 @@ We welcome contributions to this project.
|
|
146
146
|
|
147
147
|
### Developer Certificate of Origin
|
148
148
|
|
149
|
-
|
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
150
|
|
151
|
-
###
|
151
|
+
### Community Guidelines
|
152
152
|
|
153
|
-
This project is
|
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
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
40
40
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
41
41
|
-----END CERTIFICATE-----
|
42
|
-
date:
|
42
|
+
date: 2025-01-11 00:00:00.000000000 Z
|
43
43
|
dependencies:
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: console
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.5.
|
108
|
+
rubygems_version: 3.5.22
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Relaxo is versioned document database built on top of git.
|
metadata.gz.sig
CHANGED
Binary file
|