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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a027f37d320054b6e6a138ea76b9582ce2e106bb79a84d1f4c2ab7341d3b246c
4
- data.tar.gz: bf137e98b7a3591715e29aa2aa7cc70f08f150676cc707b9c426c31f1fe9bc12
3
+ metadata.gz: b43e712b63b0f63807a9a0c99bfeb9aa25c7e775f1594ff08081c9fb3db52cc0
4
+ data.tar.gz: 1c48257495fbf410453e08a23d9d05cc2c1be3acb64d750253be9b6f33bab8f8
5
5
  SHA512:
6
- metadata.gz: fc8c1565cfd9bfa00e7518179f8142589135ab705c562bcb0b948804b817bc9d929d2ecff8c857ad59d36572b053a0f1340a33b0e8034aabd39ea5168c0b0eb5
7
- data.tar.gz: 30e95d123d262733674834c64a12d4cc60e4594598c76ccaf45789a44b82760c126e492117253552e7eae0279df0c02aee36654bd52debb16d060d8c5bc855d7
6
+ metadata.gz: 498bed1e58dd6577e988d1303c8b835fea6c95785563dbe812ce570870e94a4a01d42b5a775ab54ae4e2063fdf4d5151dc4343791864e6ef3f86bbba7e781e59
7
+ data.tar.gz: 47412c47d2828083cb40bca0785cce94bf3c0b14e023f1447b689272f0b63c2ac6e876a02af66ed338b4dc717cc14090d28ebc0aed3c157de5f0fcdb88a38f2c
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2012-2019, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
- require_relative 'dataset'
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,
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2012-2024, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
  # Copyright, 2017, by Huba Nagy.
6
6
 
7
- require 'rugged'
7
+ require "rugged"
8
8
 
9
- require_relative 'logger'
10
- require_relative 'dataset'
11
- require_relative 'changeset'
9
+ require_relative "logger"
10
+ require_relative "dataset"
11
+ require_relative "changeset"
12
12
 
13
13
  module Relaxo
14
- HEAD = 'HEAD'.freeze
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]
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2012-2019, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
- require 'rugged'
6
+ require "rugged"
7
7
 
8
- require_relative 'directory'
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 = '', &block)
43
+ def each(path = "", &block)
44
44
  return to_enum(:each, path) unless block_given?
45
45
 
46
46
  directory = fetch_directory(path)
@@ -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 'rugged'
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
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
- require 'console'
6
+ require "console"
7
7
 
8
8
  module Relaxo
9
9
  extend Console
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2012-2020, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
6
  module Relaxo
7
- VERSION = "1.7.0"
7
+ VERSION = "1.8.0"
8
8
  end
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-2024, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
- require 'relaxo/database'
6
+ require "relaxo/database"
7
7
 
8
- require 'etc'
9
- require 'socket'
8
+ require "etc"
9
+ require "socket"
10
10
 
11
11
  module Relaxo
12
- MASTER = 'master'.freeze
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 sync || ENV['RELAXO_SYNC']
19
- repository.config['core.fsyncObjectFiles'] = true
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 ||= MASTER
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['user.name']
35
+ unless config["user.name"]
29
36
  login = Etc.getpwuid
30
37
  hostname = Socket.gethostname
31
38
 
32
39
  if login
33
- config['user.name'] = login.name
34
- config['user.email'] = "#{login.name}@#{hostname}"
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
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2012-2024, by Samuel Williams.
3
+ Copyright, 2012-2025, by Samuel Williams.
4
4
  Copyright, 2017-2018, by Huba Nagy.
5
5
  Copyright, 2020, by Olle Jonsson.
6
6
 
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
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
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
- ### Contributor Covenant
151
+ ### Community Guidelines
152
152
 
153
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
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.7.0
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: 2024-05-08 00:00:00.000000000 Z
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.3
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