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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17ff6a2f602dc4e7a849a437f26c3d67194da8508f17b093bb8b807b9832ad5e
4
- data.tar.gz: 45cb8059e7b6f004f4ae95db489cd203b1d97ba35840ae559a7185c8e493ca5c
3
+ metadata.gz: 401645183c5b387c8f7ebd914db2d8ff1014c03f86fb65b9d994153510f7482f
4
+ data.tar.gz: d660d41f97da18bd39e4306e131b4c19d70e809e8da17236f7a4251efa1cf177
5
5
  SHA512:
6
- metadata.gz: 7e7b6c9ad63929ec97f7513fd556d8a8860de99530fd67db5055bc169543dc9ae297a5998c325e9bee3f40a0d20eb4f92310fabf2b072e0c8b4a1723a5e35bbe
7
- data.tar.gz: d8a0eb87b94e31175ce1e409e6535a33825bd3789f4c4233706f9eed0e5a34ddefa52813aa1053e00af80f087161f58f30fe2f453f58cc1c4faab957ae54d649
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.2] - 2026-09-28
8
+ ## [0.1.3] - 2026-10-01
9
9
 
10
10
  ### Added
11
11
 
12
- - Document#diff(from_heads, to_heads = heads) returns Automerge's patches between two versions of a document, as Hashes (9c9bf6d)
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.1] - 2026-09-25
14
+ ## [0.1.2] - 2026-09-28
15
15
 
16
16
  ### Added
17
17
 
18
- - Document#load_incremental applies saved Automerge bytes into an existing document (d60a3eb)
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#includes_heads?(heads)` is true when every hash in `heads` is a change the document already contains, so `heads` is the same version or an older one.
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 # => ["9d434616e7af865757bad75cdebe4151bccf7e29214a71f2a65150846c2a4275"]
47
- doc.includes_heads?(heads) # => true when the document is at or past `heads`
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.includes_heads?(heads)`: whether every hex change hash in `heads` is a
197
- /// change this document already contains.
198
- pub fn includes_heads(ruby: &Ruby, rb_self: &Self, heads: Vec<String>) -> Result<bool, Error> {
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))
@@ -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("includes_heads?", method!(Document::includes_heads, 1))?;
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",
@@ -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, includes_heads?, diff, generate_sync_message,
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mechanomeld
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mechanomeld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay