y-rb 0.4.1-aarch64-linux → 0.4.2-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/yrb/Cargo.toml +1 -1
- data/ext/yrb/src/lib.rs +3 -0
- data/ext/yrb/src/ydoc.rs +20 -2
- data/lib/2.7/yrb.so +0 -0
- data/lib/3.0/yrb.so +0 -0
- data/lib/3.1/yrb.so +0 -0
- data/lib/y/doc.rb +22 -0
- data/lib/y/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056e505a600c66e41085dc11496b24782a7d0850b650f746bd6e44848ef1a1a3
|
4
|
+
data.tar.gz: d8d60cacf066c460fa6e62ab5e92fe20d56e285e5b1bcc8b2f0be42714703fb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f6579c2ac58079f552609446e17ea9592305fb7517f5c1ce57c4ed86003f3d2b17c086b4bef5b695d8099d4635286e7bc2c03295de86850072dcfc69c1f0d5
|
7
|
+
data.tar.gz: 277ffc80d160289d5d51cf1d1150a9daa4097dc63a8ee699b45cdcbbfed13c400d77e930935acd6009fa30b14c9fb7a745b986168b6cdc8b08cd52d002e1c288
|
data/ext/yrb/Cargo.toml
CHANGED
data/ext/yrb/src/lib.rs
CHANGED
@@ -116,6 +116,9 @@ fn init() -> Result<(), Error> {
|
|
116
116
|
ydoc.define_private_method("ydoc_transact", method!(YDoc::ydoc_transact, 0))
|
117
117
|
.expect("cannot define private method: ydoc_transact");
|
118
118
|
|
119
|
+
ydoc.define_private_method("ydoc_observe_update", method!(YDoc::ydoc_observe_update, 1))
|
120
|
+
.expect("cannot define private method: ydoc_observe_update");
|
121
|
+
|
119
122
|
let ymap = module
|
120
123
|
.define_class("Map", Default::default())
|
121
124
|
.expect("cannot define class Y::Map");
|
data/ext/yrb/src/ydoc.rs
CHANGED
@@ -5,11 +5,13 @@ use crate::yxml_element::YXmlElement;
|
|
5
5
|
use crate::yxml_fragment::YXmlFragment;
|
6
6
|
use crate::yxml_text::YXmlText;
|
7
7
|
use crate::YTransaction;
|
8
|
-
use magnus::
|
8
|
+
use magnus::block::Proc;
|
9
|
+
use magnus::exception::runtime_error;
|
10
|
+
use magnus::{exception, Error, Integer, RArray, Value};
|
9
11
|
use std::borrow::Borrow;
|
10
12
|
use std::cell::RefCell;
|
11
13
|
use yrs::updates::decoder::Decode;
|
12
|
-
use yrs::{Doc, OffsetKind, Options, ReadTxn, StateVector, Transact};
|
14
|
+
use yrs::{Doc, OffsetKind, Options, ReadTxn, StateVector, SubscriptionId, Transact};
|
13
15
|
|
14
16
|
#[magnus::wrap(class = "Y::Doc")]
|
15
17
|
pub(crate) struct YDoc(pub(crate) RefCell<Doc>);
|
@@ -75,4 +77,20 @@ impl YDoc {
|
|
75
77
|
let transaction = doc.transact_mut();
|
76
78
|
YTransaction::from(transaction)
|
77
79
|
}
|
80
|
+
|
81
|
+
pub(crate) fn ydoc_observe_update(&self, block: Proc) -> Result<SubscriptionId, Error> {
|
82
|
+
self.0
|
83
|
+
.borrow()
|
84
|
+
.observe_update_v1(move |_tx, update_event| {
|
85
|
+
let update = update_event.update.to_vec();
|
86
|
+
let update = RArray::from_vec(update);
|
87
|
+
|
88
|
+
let args: (RArray,) = (update,);
|
89
|
+
block
|
90
|
+
.call::<(RArray,), Value>(args)
|
91
|
+
.expect("cannot call update block");
|
92
|
+
})
|
93
|
+
.map(|v| v.into())
|
94
|
+
.map_err(|err| Error::new(runtime_error(), err.to_string()))
|
95
|
+
}
|
78
96
|
}
|
data/lib/2.7/yrb.so
CHANGED
Binary file
|
data/lib/3.0/yrb.so
CHANGED
Binary file
|
data/lib/3.1/yrb.so
CHANGED
Binary file
|
data/lib/y/doc.rb
CHANGED
@@ -19,6 +19,22 @@ module Y
|
|
19
19
|
ZERO_STATE = [0].freeze
|
20
20
|
private_constant :ZERO_STATE
|
21
21
|
|
22
|
+
# Attach a listener to document changes. If one of the data structures is
|
23
|
+
# changes, the block is called with the update as its only argument.
|
24
|
+
#
|
25
|
+
# @yield [update] Called when document is updated
|
26
|
+
# @yieldparam [Array<Integer>] update The encoded document updates
|
27
|
+
|
28
|
+
# Example: Attach listener to document changes
|
29
|
+
# doc = described_class.new
|
30
|
+
# doc.attach { |update| pp update }
|
31
|
+
#
|
32
|
+
# text = doc.get_text("my text")
|
33
|
+
# text << "1"
|
34
|
+
def attach(&block)
|
35
|
+
ydoc_observe_update(block)
|
36
|
+
end
|
37
|
+
|
22
38
|
# Commit current transaction
|
23
39
|
#
|
24
40
|
# This is a convenience method that invokes {Y::Transaction#commit} on the
|
@@ -222,5 +238,11 @@ module Y
|
|
222
238
|
#
|
223
239
|
# @return [Y::XMLText]
|
224
240
|
# @!visibility private
|
241
|
+
|
242
|
+
# @!method ydoc_observe_update(block)
|
243
|
+
# Creates a subscription to observe changes to the document
|
244
|
+
# @param [Proc] block
|
245
|
+
# @return [Integer]
|
246
|
+
# @!visibility private
|
225
247
|
end
|
226
248
|
end
|
data/lib/y/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: y-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: aarch64-linux
|
6
6
|
authors:
|
7
7
|
- Hannes Moser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|