mechanomeld 0.1.2 → 0.1.3
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
- data/CHANGELOG.md +4 -13
- data/README.md +3 -3
- data/ext/mechanomeld/src/document.rs +4 -3
- data/ext/mechanomeld/src/lib.rs +1 -1
- data/lib/mechanomeld/document.rb +3 -1
- data/lib/mechanomeld/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 401645183c5b387c8f7ebd914db2d8ff1014c03f86fb65b9d994153510f7482f
|
|
4
|
+
data.tar.gz: d660d41f97da18bd39e4306e131b4c19d70e809e8da17236f7a4251efa1cf177
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3bb7618d943ad8c284dbc328fe2156599b8a2c39a5a7e218bc2650f076fc16468e7994cab92209c5bfb790e6248969a2616a94967f41ddcdbac03879f54ce9fa
|
|
7
|
+
data.tar.gz: 65bf168075b5a415b4bd582ab98f474913188106fdba093f5811d1b1d57b94a050dd1a1eff1e542cc566c35c9081da749a11ee3aa05997bdc8ced485fcd40672
|
data/CHANGELOG.md
CHANGED
|
@@ -5,23 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
7
|
|
|
8
|
-
## [0.1.
|
|
8
|
+
## [0.1.3] - 2026-10-01
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- Document#
|
|
12
|
+
- Document#up_to_date_with?(heads), the plain-language name for includes_heads?, which stays as an alias (9c1baa6)
|
|
13
13
|
|
|
14
|
-
## [0.1.
|
|
14
|
+
## [0.1.2] - 2026-09-28
|
|
15
15
|
|
|
16
16
|
### Added
|
|
17
17
|
|
|
18
|
-
- Document#
|
|
19
|
-
- Document.load_repo reads a document from automerge-repo's NodeFSStorageAdapter directory (d60a3eb)
|
|
20
|
-
- Document#heads returns the document's change hashes as hex, matching JavaScript's Automerge.getHeads (d60a3eb)
|
|
21
|
-
- Document#includes_heads?(heads) reports whether a document is at or past a set of heads (d60a3eb)
|
|
22
|
-
- Mechanomeld::SyncState, the per-peer sync state, with encode and decode for persistence (eea3a51)
|
|
23
|
-
- Document#generate_sync_message and #receive_sync_message, Automerge's per-document sync protocol (eea3a51)
|
|
24
|
-
|
|
25
|
-
### Changed
|
|
26
|
-
|
|
27
|
-
- releases also publish an x86_64-linux-musl platform gem (159dd59)
|
|
18
|
+
- Document#diff(from_heads, to_heads = heads) returns Automerge's patches between two versions of a document, as Hashes (9c9bf6d)
|
data/README.md
CHANGED
|
@@ -40,11 +40,11 @@ doc = Mechanomeld::Document.load_repo("automerge-repo-data", "4NtRZtd6yUtzf8qmEp
|
|
|
40
40
|
|
|
41
41
|
### Heads
|
|
42
42
|
|
|
43
|
-
`Document#heads` is the document's version: the change hashes JavaScript's `Automerge.getHeads(doc)` returns, as lowercase hex, so the two sides compare with `==`. `Document#
|
|
43
|
+
`Document#heads` is the document's version: the change hashes JavaScript's `Automerge.getHeads(doc)` returns, as lowercase hex, so the two sides compare with `==`. `Document#up_to_date_with?(heads)` is true when the document is at the version `heads` names, or a later one: every hash in `heads` is a change the document already contains. `includes_heads?` is the same method under its older name.
|
|
44
44
|
|
|
45
45
|
```ruby
|
|
46
|
-
doc.heads
|
|
47
|
-
doc.
|
|
46
|
+
doc.heads # => ["9d434616e7af865757bad75cdebe4151bccf7e29214a71f2a65150846c2a4275"]
|
|
47
|
+
doc.up_to_date_with?(heads) # => true when the document is at or past `heads`
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
Both take hex. automerge-repo's `handle.heads()` returns base58 URL heads, which are not accepted; send `Automerge.getHeads(handle.doc())` from JavaScript instead. A hash that is not 32 bytes of hex raises `Mechanomeld::Error`; a well-formed hash the document does not have is simply not included. Like `save`, both commit any pending change first.
|
|
@@ -193,9 +193,10 @@ impl Document {
|
|
|
193
193
|
Ok(ruby.ary_from_iter(heads.iter().map(ChangeHash::to_string)))
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
/// `doc.
|
|
197
|
-
/// change
|
|
198
|
-
|
|
196
|
+
/// `doc.up_to_date_with?(heads)`: whether this document is at the version `heads`
|
|
197
|
+
/// names, or a later one: every hex change hash in `heads` is a change it already
|
|
198
|
+
/// contains. Ruby also exposes it as `includes_heads?`.
|
|
199
|
+
pub fn up_to_date_with(ruby: &Ruby, rb_self: &Self, heads: Vec<String>) -> Result<bool, Error> {
|
|
199
200
|
let hashes = heads
|
|
200
201
|
.iter()
|
|
201
202
|
.map(|hex| change_hash(ruby, hex))
|
data/ext/mechanomeld/src/lib.rs
CHANGED
|
@@ -28,7 +28,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
28
28
|
class.define_method("rollback", method!(Document::rollback, 0))?;
|
|
29
29
|
class.define_method("save", method!(Document::save, 0))?;
|
|
30
30
|
class.define_method("heads", method!(Document::heads, 0))?;
|
|
31
|
-
class.define_method("
|
|
31
|
+
class.define_method("up_to_date_with?", method!(Document::up_to_date_with, 1))?;
|
|
32
32
|
class.define_method("diff", method!(Document::diff, -1))?;
|
|
33
33
|
class.define_method(
|
|
34
34
|
"generate_sync_message",
|
data/lib/mechanomeld/document.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Mechanomeld
|
|
4
4
|
# Native methods (new, load, load_incremental, get, keys, length, put, delete, commit,
|
|
5
|
-
# rollback, save, heads,
|
|
5
|
+
# rollback, save, heads, up_to_date_with?, diff, generate_sync_message,
|
|
6
6
|
# receive_sync_message) are defined in ext/mechanomeld/src/document.rs.
|
|
7
7
|
class Document
|
|
8
8
|
def self.from(hash, actor_id: nil)
|
|
@@ -40,6 +40,8 @@ module Mechanomeld
|
|
|
40
40
|
end
|
|
41
41
|
alias_method :to_hash, :to_h
|
|
42
42
|
|
|
43
|
+
alias_method :includes_heads?, :up_to_date_with?
|
|
44
|
+
|
|
43
45
|
def change(message: nil, timestamp: nil)
|
|
44
46
|
yield self
|
|
45
47
|
commit(message: message, timestamp: timestamp)
|
data/lib/mechanomeld/version.rb
CHANGED