relaxo 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 814525baa6f655dc170eec88ee0878abf080f10c
4
- data.tar.gz: 8c530c78c0b059db275418b4db7bfc521b562663
3
+ metadata.gz: 801d2413ec4ce9a0befc4ad46726900c09453cb8
4
+ data.tar.gz: e9b179cd2f9a6da4083848c3197f69b328dc455e
5
5
  SHA512:
6
- metadata.gz: e5f3dbc6500971bf4ece1cea1369f8f4b0d1e3ffa5055163a89da3a4c9f2ff796eea4b7031c82231bda3694f65f77a7620312966490124ff5d0ec4d9611aa5d8
7
- data.tar.gz: 1322de675206c9ce30f8f088d85ba0646155e9ae54f0e974274fdeae23bd80b9287526a91f8c6554c81536a3c67c8c244fba00487c7b216bc004ba50fb98106d
6
+ metadata.gz: 6f5c211fdb870371d30dd6555b556771a78a12408004db4bc1be125bcced2daa64bf05c989a8a8045b0456a64cc277d9fc1d132af9f26ed6a76c7ede4c3714af
7
+ data.tar.gz: 9f6a3c721c120a000666fb192fc2d779ff62a3d0ab714cc24f75284bfa6ca1bfe72cd5e32be469c241af28a43b6a3309f683dda823a76ecd74dd638eba176c68
data/README.md CHANGED
@@ -106,6 +106,17 @@ Reading data is lighting fast as it's loaded directly from disk and cached.
106
106
 
107
107
  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.
108
108
 
109
+ ### Durability
110
+
111
+ Relaxo is based on `libgit2` and asserts that it is a transactional database. We base this assertion on:
112
+
113
+ - All writes into the object store using `libgit2` are atomic and synchronized to disk.
114
+ - All updates to refs are atomic and synchronized to disk.
115
+
116
+ Provided these two invariants are maintained, the operation of Relaxo will be safe, even if there are unexpected interruptions to the program.
117
+
118
+ 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.
119
+
109
120
  ## Contributing
110
121
 
111
122
  1. Fork it
@@ -49,7 +49,7 @@ module Relaxo
49
49
  def append(data, type = :blob)
50
50
  oid = @repository.write(data, type)
51
51
 
52
- return Rugged::Object.new(@repository, oid)
52
+ return @repository.read(oid)
53
53
  end
54
54
 
55
55
  def write(path, object, mode = 0100644)
@@ -75,6 +75,34 @@ module Relaxo
75
75
  return dataset
76
76
  end
77
77
 
78
+ # revision history of given object
79
+ def history(path)
80
+ head, _ = latest_commit
81
+
82
+ walker = Rugged::Walker.new(@repository) # Sounds like 'Walker, Texas Ranger'...
83
+ walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
84
+ walker.push(head.oid)
85
+
86
+ commits = []
87
+
88
+ old_oid = nil
89
+
90
+ walker.each do |commit|
91
+ dataset = Dataset.new(@repository, commit.tree)
92
+ oid = dataset.read(path).oid
93
+
94
+ if oid != old_oid # modified
95
+ yield commit if block_given?
96
+ commits << commit
97
+ old_oid = oid
98
+ end
99
+
100
+ break if oid.nil? && !old_oid.nil? # deleted or moved
101
+ end
102
+
103
+ return commits
104
+ end
105
+
78
106
  private
79
107
 
80
108
  def track_time(message)
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Relaxo
22
- VERSION = "1.0.0"
22
+ VERSION = "1.0.1"
23
23
  end
@@ -84,4 +84,20 @@ RSpec.describe Relaxo::Database do
84
84
  expect(dataset.each('test').count).to be == 10
85
85
  end
86
86
  end
87
+
88
+ it "can enumerate commit history of a document" do
89
+ 10.times do |id|
90
+ database.commit(message: "revising the document #{id}") do |changeset|
91
+ oid = changeset.append("revision \##{id} of this document")
92
+ changeset.write('test/doot.txt', oid)
93
+ end
94
+ end
95
+
96
+ database.commit(message: "unrelated commit") do |changeset|
97
+ oid = changeset.append("unrelated document")
98
+ changeset.write('test/unrelated.txt', oid)
99
+ end
100
+
101
+ expect(database.history('test/doot.txt').count).to be == 10
102
+ end
87
103
  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.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-12 00:00:00.000000000 Z
11
+ date: 2017-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged