y-rb 0.5.2-x86_64-linux → 0.5.3-x86_64-linux

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: 4c36ec2ee90cc6540b5dd33bb266e3b3d836fb6fcfc0b1d84256ee5a49d0836a
4
- data.tar.gz: 297f433fdcd8275a9f4085d2739835351be045a6a373a8bafd83df6ae50d24d2
3
+ metadata.gz: 4844a224d563f4fccf5d3f294f3fadf26042b2a4b139cec6323e2f1d3aa8c529
4
+ data.tar.gz: c0b2325dced2795a91d85dd5f1b053325edbbd28341c486b8fa203f7b01d2d43
5
5
  SHA512:
6
- metadata.gz: 1477b1b46cce45892169dba8fbfa275b7298d74dd0898fc331b31a027cf6cf075933a39caad7033313fd986343d4d1d80a2ee63d1fca391810cc12fa114fe886
7
- data.tar.gz: b52cc424c1eb6a0020495dddf5955a630b13d2eb7bb7bfcd1c4c79a7bbd4afbc01e3deb530ce49dd39b84098d51e594666b59c7ef61456e095046070f4b7a77e
6
+ metadata.gz: 92227ea1c21e740aaba2d85f3beec6f080005a7091b9f609a55b97238fa52e9cbbe5ddf74aed366c81f8402e7b2b67efcd94843f4802d6470483681e62447cc0
7
+ data.tar.gz: 542e56af464cac866dbf6918e98a8ff86276ed75246fcfa039059d777ba15dd8dfcb6b87c0bc38af2e1570fcaa4632b59bde0cc55390d1adf24bde7f947a1a19
data/ext/yrb/Cargo.toml CHANGED
@@ -1,21 +1,21 @@
1
1
  [package]
2
2
  name = "yrb"
3
- version = "0.5.2"
4
- authors = ["Hannes Moser <box@hannesmoser.at>", "Hannes Moser <hmoser@gitlab.com>"]
3
+ version = "0.5.3"
4
+ authors = ["Hannes Moser <box@hannesmoser.at>"]
5
5
  edition = "2021"
6
6
  homepage = "https://github.com/y-crdt/yrb"
7
7
  repository = "https://github.com/y-crdt/yrb"
8
8
 
9
9
  [dependencies]
10
- lib0 = "0.16.9" # must match yrs version
11
- magnus = "0.5.4"
12
- thiserror = "1.0.41"
13
- yrs = "=0.16.9"
10
+ lib0 = "0.16.10" # must match yrs version
11
+ magnus = "0.6.2"
12
+ thiserror = "1.0.50"
13
+ yrs = "=0.16.10"
14
14
  y-sync = "=0.3.1"
15
- rb-sys = "0.9.79"
15
+ rb-sys = "0.9.82"
16
16
 
17
17
  [dev-dependencies]
18
- magnus = { version = "0.5.4", features = ["embed"] }
18
+ magnus = { version = "0.6.2", features = ["embed"] }
19
19
 
20
20
  [lib]
21
21
  name = "yrb"
data/ext/yrb/src/lib.rs CHANGED
@@ -9,7 +9,7 @@ use crate::ytransaction::YTransaction;
9
9
  use crate::yxml_element::YXmlElement;
10
10
  use crate::yxml_fragment::YXmlFragment;
11
11
  use crate::yxml_text::YXmlText;
12
- use magnus::{define_module, function, method, Error, Module, Object};
12
+ use magnus::{class, define_module, function, method, Error, Module, Object};
13
13
 
14
14
  mod utils;
15
15
  mod yany;
@@ -30,7 +30,7 @@ fn init() -> Result<(), Error> {
30
30
  let module = define_module("Y").expect("cannot define ::Y module");
31
31
 
32
32
  let yarray = module
33
- .define_class("Array", Default::default())
33
+ .define_class("Array", class::object())
34
34
  .expect("cannot find class Y::Array");
35
35
 
36
36
  yarray
@@ -77,7 +77,7 @@ fn init() -> Result<(), Error> {
77
77
  .expect("cannot define private method: yarray_unobserve");
78
78
 
79
79
  let ydoc = module
80
- .define_class("Doc", Default::default())
80
+ .define_class("Doc", class::object())
81
81
  .expect("cannot define class Y::Doc");
82
82
  ydoc.define_singleton_method("new", function!(YDoc::ydoc_new, -1))
83
83
  .expect("cannot define singleton method: ydoc_new");
@@ -122,7 +122,7 @@ fn init() -> Result<(), Error> {
122
122
  .expect("cannot define private method: ydoc_observe_update");
123
123
 
124
124
  let ymap = module
125
- .define_class("Map", Default::default())
125
+ .define_class("Map", class::object())
126
126
  .expect("cannot define class Y::Map");
127
127
 
128
128
  ymap.define_private_method("ymap_clear", method!(YMap::ymap_clear, 1))
@@ -147,7 +147,7 @@ fn init() -> Result<(), Error> {
147
147
  .expect("cannot define private method: ymap_unobserve");
148
148
 
149
149
  let ytransaction = module
150
- .define_class("Transaction", Default::default())
150
+ .define_class("Transaction", class::object())
151
151
  .expect("cannot define class Y::Transaction");
152
152
 
153
153
  ytransaction
@@ -221,7 +221,7 @@ fn init() -> Result<(), Error> {
221
221
  .expect("cannot define private method: ytransaction_state_vector_v2");
222
222
 
223
223
  let ytext = module
224
- .define_class("Text", Default::default())
224
+ .define_class("Text", class::object())
225
225
  .expect("cannot define class Y::Text");
226
226
 
227
227
  ytext
@@ -265,7 +265,7 @@ fn init() -> Result<(), Error> {
265
265
  .expect("cannot define private method: ytext_unobserve");
266
266
 
267
267
  let yxml_element = module
268
- .define_class("XMLElement", Default::default())
268
+ .define_class("XMLElement", class::object())
269
269
  .expect("cannot define class Y::XMLElement");
270
270
 
271
271
  yxml_element
@@ -408,7 +408,7 @@ fn init() -> Result<(), Error> {
408
408
  .expect("cannot define private method: yxml_element_unobserve");
409
409
 
410
410
  let yxml_fragment = module
411
- .define_class("XMLFragment", Default::default())
411
+ .define_class("XMLFragment", class::object())
412
412
  .expect("cannot define class: Y::XMLFragment");
413
413
 
414
414
  yxml_fragment
@@ -473,7 +473,7 @@ fn init() -> Result<(), Error> {
473
473
  .expect("cannot define private method: yxml_fragment_to_s");
474
474
 
475
475
  let yxml_text = module
476
- .define_class("XMLText", Default::default())
476
+ .define_class("XMLText", class::object())
477
477
  .expect("cannot define class Y::XMLText");
478
478
 
479
479
  yxml_text
@@ -550,7 +550,7 @@ fn init() -> Result<(), Error> {
550
550
  .expect("cannot define private method: yxml_text_to_s");
551
551
 
552
552
  let yawareness = module
553
- .define_class("Awareness", Default::default())
553
+ .define_class("Awareness", class::object())
554
554
  .expect("cannot define class Y::Awareness");
555
555
  yawareness
556
556
  .define_singleton_method("new", function!(YAwareness::yawareness_new, 0))
@@ -617,7 +617,7 @@ fn init() -> Result<(), Error> {
617
617
  .expect("cannot define private method: yawareness_update_with_clients");
618
618
 
619
619
  let yawareness_event = module
620
- .define_class("AwarenessEvent", Default::default())
620
+ .define_class("AwarenessEvent", class::object())
621
621
  .expect("cannot define class Y:AwarenessEvent");
622
622
  yawareness_event
623
623
  .define_method("added", method!(YAwarenessEvent::added, 0))
data/ext/yrb/src/utils.rs CHANGED
@@ -1,9 +1,10 @@
1
1
  use crate::yvalue::YValue;
2
2
  use lib0::any::Any;
3
3
  use magnus::r_hash::ForEach::Continue;
4
- use magnus::{exception, Error, RHash, RString, Symbol, Value};
4
+ use magnus::{exception, Error, RArray, RHash, RString, Symbol, Value};
5
5
  use std::sync::Arc;
6
- use yrs::types::Attrs;
6
+ use yrs::types::{Attrs, Value as YrsValue};
7
+ use yrs::{Array, Map, TransactionMut};
7
8
 
8
9
  #[derive(Debug, Clone)]
9
10
  pub(crate) struct TypeConversionError;
@@ -35,3 +36,30 @@ pub(crate) fn map_rhash_to_attrs(hash: RHash) -> Result<Attrs, Error> {
35
36
 
36
37
  Ok(a)
37
38
  }
39
+
40
+ pub(crate) fn convert_yvalue_to_ruby_value(value: YrsValue, tx: &TransactionMut) -> YValue {
41
+ match value {
42
+ YrsValue::Any(val) => YValue::from(val),
43
+ YrsValue::YText(text) => YValue::from(text),
44
+ YrsValue::YXmlElement(el) => YValue::from(el),
45
+ YrsValue::YXmlText(text) => YValue::from(text),
46
+ YrsValue::YArray(val) => {
47
+ let arr = RArray::new();
48
+ for item in val.iter(tx) {
49
+ let val = convert_yvalue_to_ruby_value(item.clone(), tx);
50
+ let val = *val.0.borrow();
51
+ arr.push(val).expect("cannot push item event to array");
52
+ }
53
+ YValue::from(arr)
54
+ }
55
+ YrsValue::YMap(val) => {
56
+ let iter = val.iter(tx).map(|(key, val)| {
57
+ let val = convert_yvalue_to_ruby_value(val.clone(), tx);
58
+ let val = val.0.into_inner();
59
+ (key, val)
60
+ });
61
+ YValue::from(RHash::from_iter(iter))
62
+ }
63
+ v => panic!("cannot map given yrs values to yvalue: {:?}", v),
64
+ }
65
+ }
data/ext/yrb/src/yany.rs CHANGED
@@ -1,6 +1,7 @@
1
1
  use lib0::any::Any;
2
2
  use magnus::r_string::IntoRString;
3
- use magnus::{RArray, RHash, RString, Value, QNIL};
3
+ use magnus::value::ReprValue;
4
+ use magnus::{value, IntoValue, RArray, RHash, RString, Value};
4
5
  use std::borrow::Borrow;
5
6
  use std::ops::{Deref, DerefMut};
6
7
 
@@ -27,19 +28,19 @@ impl TryInto<Value> for YAny {
27
28
  return match self.0 {
28
29
  Any::Array(_v) => {
29
30
  let arr = RArray::new();
30
- Ok(Value::from(arr))
31
+ Ok(arr.as_value())
31
32
  }
32
33
  Any::Map(_v) => {
33
34
  let hash = RHash::new();
34
- Ok(Value::from(hash))
35
+ Ok(hash.as_value())
35
36
  }
36
- Any::Null => Ok(Value::from(QNIL)),
37
- Any::Undefined => Ok(Value::from(QNIL)),
38
- Any::Bool(v) => Ok(Value::from(v)),
39
- Any::Number(v) => Ok(Value::from(v)),
40
- Any::BigInt(v) => Ok(Value::from(v)),
41
- Any::String(v) => Ok(Value::from(RString::from(v.into_r_string()))),
42
- Any::Buffer(v) => Ok(Value::from(RString::from_slice(v.borrow()))),
37
+ Any::Null => Ok(value::qnil().as_value()),
38
+ Any::Undefined => Ok(Value::from(value::qnil().as_value())),
39
+ Any::Bool(v) => Ok(v.into_value()),
40
+ Any::Number(v) => Ok(Value::from(v.into_value())),
41
+ Any::BigInt(v) => Ok(Value::from(v.into_value())),
42
+ Any::String(v) => Ok(RString::from(v.into_r_string()).as_value()),
43
+ Any::Buffer(v) => Ok(RString::from_slice(v.borrow()).as_value()),
43
44
  };
44
45
  }
45
46
  }
@@ -1,9 +1,10 @@
1
+ use crate::utils::convert_yvalue_to_ruby_value;
1
2
  use crate::ytransaction::YTransaction;
2
3
  use crate::yvalue::YValue;
3
4
  use lib0::any::Any;
4
5
  use magnus::block::Proc;
5
6
  use magnus::value::Qnil;
6
- use magnus::{Error, RArray, RHash, Symbol, Value};
7
+ use magnus::{Error, IntoValue, RArray, RHash, Symbol, Value};
7
8
  use std::borrow::Borrow;
8
9
  use std::cell::RefCell;
9
10
  use yrs::types::Change;
@@ -22,20 +23,21 @@ impl YArray {
22
23
 
23
24
  let arr = self.0.borrow();
24
25
  arr.iter(tx).for_each(|val| {
25
- let yvalue = YValue::from(val);
26
- let args = (yvalue.into(),);
26
+ let yvalue = *convert_yvalue_to_ruby_value(val, tx).0.borrow();
27
+ let args = (yvalue,);
27
28
  let _ = block.call::<(Value,), Qnil>(args);
28
29
  });
29
30
 
30
31
  Ok(())
31
32
  }
33
+
32
34
  pub(crate) fn yarray_get(&self, transaction: &YTransaction, index: u32) -> Value {
33
35
  let tx = transaction.transaction();
34
36
  let tx = tx.as_ref().unwrap();
35
37
 
36
38
  let arr = self.0.borrow();
37
39
  let v = arr.get(tx, index).unwrap();
38
- YValue::from(v).into()
40
+ *convert_yvalue_to_ruby_value(v, tx).0.borrow()
39
41
  }
40
42
  pub(crate) fn yarray_insert(&self, transaction: &YTransaction, index: u32, value: Value) {
41
43
  let yvalue = YValue::from(value);
@@ -98,10 +100,10 @@ impl YArray {
98
100
  payload.aset(change_added, values)
99
101
  }
100
102
  Change::Retain(position) => {
101
- payload.aset(change_retain, Value::from(*position))
103
+ payload.aset(change_retain, (*position).into_value())
102
104
  }
103
105
  Change::Removed(position) => {
104
- payload.aset(change_removed, Value::from(*position))
106
+ payload.aset(change_removed, (*position).into_value())
105
107
  }
106
108
  };
107
109
 
data/ext/yrb/src/ymap.rs CHANGED
@@ -1,4 +1,4 @@
1
- use crate::utils::indifferent_hash_key;
1
+ use crate::utils::{convert_yvalue_to_ruby_value, indifferent_hash_key};
2
2
  use crate::yvalue::YValue;
3
3
  use crate::YTransaction;
4
4
  use lib0::any::Any;
@@ -30,17 +30,18 @@ impl YMap {
30
30
  Some(k) => self.0.borrow().contains_key(tx, k.as_str()),
31
31
  }
32
32
  }
33
+
33
34
  pub(crate) fn ymap_each(&self, transaction: &YTransaction, proc: Proc) {
34
35
  let tx = transaction.transaction();
35
36
  let tx = tx.as_ref().unwrap();
36
-
37
37
  self.0.borrow().iter(tx).for_each(|(key, val)| {
38
38
  let k = key.to_string();
39
- let v = *YValue::from(val).0.borrow();
39
+ let v = *convert_yvalue_to_ruby_value(val, tx).0.borrow();
40
40
  proc.call::<(String, Value), Value>((k, v))
41
41
  .expect("cannot iterate map");
42
42
  })
43
43
  }
44
+
44
45
  pub(crate) fn ymap_get(&self, transaction: &YTransaction, key: Value) -> Option<Value> {
45
46
  let tx = transaction.transaction();
46
47
  let tx = tx.as_ref().unwrap();
@@ -48,7 +49,7 @@ impl YMap {
48
49
  indifferent_hash_key(key)
49
50
  .map(|k| self.0.borrow().get(tx, k.as_str()))
50
51
  .map(|v| v.unwrap_or(YrsValue::Any(Any::Undefined)))
51
- .map(|v| *YValue::from(v).0.borrow())
52
+ .map(|v| *convert_yvalue_to_ruby_value(v, tx).0.borrow())
52
53
  }
53
54
  pub(crate) fn ymap_insert(
54
55
  &self,
@@ -1,8 +1,8 @@
1
1
  use crate::{YText, YXmlElement, YXmlText};
2
2
  use lib0::any::Any;
3
3
  use magnus::r_hash::ForEach::Continue;
4
- use magnus::value::Qnil;
5
- use magnus::{class, Float, Integer, RArray, RHash, RString, Symbol, Value, QNIL};
4
+ use magnus::value::{Qnil, ReprValue};
5
+ use magnus::{class, value, Float, Integer, IntoValue, RArray, RHash, RString, Symbol, Value};
6
6
  use std::cell::RefCell;
7
7
  use std::collections::HashMap;
8
8
  use yrs::types::Value as YrsValue;
@@ -21,100 +21,100 @@ impl From<Value> for YValue {
21
21
 
22
22
  impl From<Qnil> for YValue {
23
23
  fn from(value: Qnil) -> Self {
24
- YValue(RefCell::from(Value::from(value)))
24
+ YValue(RefCell::from(value.into_value()))
25
25
  }
26
26
  }
27
27
 
28
28
  impl From<bool> for YValue {
29
29
  fn from(value: bool) -> Self {
30
- YValue(RefCell::from(Value::from(value)))
30
+ YValue(RefCell::from(value.into_value()))
31
31
  }
32
32
  }
33
33
 
34
34
  impl From<f64> for YValue {
35
35
  fn from(value: f64) -> Self {
36
- YValue(RefCell::from(Value::from(value)))
36
+ YValue(RefCell::from(value.into_value()))
37
37
  }
38
38
  }
39
39
 
40
40
  impl From<i64> for YValue {
41
41
  fn from(value: i64) -> Self {
42
- YValue(RefCell::from(Value::from(value)))
42
+ YValue(RefCell::from(value.into_value()))
43
43
  }
44
44
  }
45
45
 
46
46
  impl From<u32> for YValue {
47
47
  fn from(value: u32) -> Self {
48
- YValue(RefCell::from(Value::from(value)))
48
+ YValue(RefCell::from(value.into_value()))
49
49
  }
50
50
  }
51
51
 
52
52
  impl From<String> for YValue {
53
53
  fn from(value: String) -> Self {
54
- YValue(RefCell::from(Value::from(value)))
54
+ YValue(RefCell::from(value.into_value()))
55
55
  }
56
56
  }
57
57
 
58
58
  impl From<RArray> for YValue {
59
59
  fn from(value: RArray) -> Self {
60
- YValue(RefCell::from(Value::from(value)))
60
+ YValue(RefCell::from(value.into_value()))
61
61
  }
62
62
  }
63
63
 
64
64
  impl From<RHash> for YValue {
65
65
  fn from(value: RHash) -> Self {
66
- YValue(RefCell::from(Value::from(value)))
66
+ YValue(RefCell::from(value.into_value()))
67
67
  }
68
68
  }
69
69
 
70
70
  impl From<YrsText> for YValue {
71
71
  fn from(value: YrsText) -> Self {
72
- YValue(RefCell::from(Value::from(YText(RefCell::from(value)))))
72
+ YValue(RefCell::from(YText(RefCell::from(value)).into_value()))
73
73
  }
74
74
  }
75
75
 
76
76
  impl From<YrsXmlElement> for YValue {
77
77
  fn from(value: YrsXmlElement) -> Self {
78
- YValue(RefCell::from(Value::from(YXmlElement(RefCell::from(
79
- value,
80
- )))))
78
+ YValue(RefCell::from(
79
+ YXmlElement(RefCell::from(value)).into_value(),
80
+ ))
81
81
  }
82
82
  }
83
83
 
84
84
  impl From<YrsXmlText> for YValue {
85
85
  fn from(value: YrsXmlText) -> Self {
86
- YValue(RefCell::from(Value::from(YXmlText(RefCell::from(value)))))
86
+ YValue(RefCell::from(YXmlText(RefCell::from(value)).into_value()))
87
87
  }
88
88
  }
89
89
 
90
90
  impl From<YText> for YValue {
91
91
  fn from(value: YText) -> Self {
92
- YValue(RefCell::from(Value::from(value)))
92
+ YValue(RefCell::from(value.into_value()))
93
93
  }
94
94
  }
95
95
 
96
96
  impl From<YXmlElement> for YValue {
97
97
  fn from(value: YXmlElement) -> Self {
98
- YValue(RefCell::from(Value::from(value)))
98
+ YValue(RefCell::from(value.into_value()))
99
99
  }
100
100
  }
101
101
 
102
102
  impl From<YXmlText> for YValue {
103
103
  fn from(value: YXmlText) -> Self {
104
- YValue(RefCell::from(Value::from(value)))
104
+ YValue(RefCell::from(value.into_value()))
105
105
  }
106
106
  }
107
107
 
108
108
  impl From<Any> for YValue {
109
109
  fn from(value: Any) -> Self {
110
110
  match value {
111
- Any::Null => YValue::from(QNIL),
112
- Any::Undefined => YValue::from(QNIL),
111
+ Any::Null => YValue::from(value::qnil()),
112
+ Any::Undefined => YValue::from(value::qnil()),
113
113
  Any::Bool(v) => YValue::from(v),
114
114
  Any::Number(v) => YValue::from(v),
115
115
  Any::BigInt(v) => YValue::from(v),
116
116
  Any::String(v) => YValue::from(v.into_string()),
117
- Any::Buffer(v) => YValue::from(Value::from(v.into_vec())),
117
+ Any::Buffer(v) => YValue::from(v.into_vec().into_value()),
118
118
  Any::Array(v) => {
119
119
  let arr = RArray::new();
120
120
  for item in v.iter() {
@@ -146,16 +146,18 @@ impl From<YrsValue> for YValue {
146
146
  YrsValue::YXmlElement(el) => YValue::from(el),
147
147
  YrsValue::YXmlText(text) => YValue::from(text),
148
148
  YrsValue::YArray(val) => {
149
+ print!("try to acquire transaction");
149
150
  let tx = val.transact();
150
151
  let arr = RArray::new();
151
152
  for item in val.iter(&tx) {
152
153
  let val = YValue::from(item.clone());
153
- let val = val.0.borrow().clone();
154
+ let val = *val.0.borrow();
154
155
  arr.push(val).expect("cannot push item event to array");
155
156
  }
156
157
  YValue::from(arr)
157
158
  }
158
159
  YrsValue::YMap(val) => {
160
+ print!("try to acquire transaction");
159
161
  let tx = val.transact();
160
162
  let iter = val.iter(&tx).map(|(key, val)| {
161
163
  let val = YValue::from(val);
@@ -237,6 +239,7 @@ impl Into<Value> for YValue {
237
239
  mod tests {
238
240
  use crate::yvalue::YValue;
239
241
  use lib0::any::Any;
242
+ use magnus::value::ReprValue;
240
243
 
241
244
  #[test]
242
245
  fn convert_any_to_yvalue() {
@@ -3,7 +3,7 @@ use crate::yxml_fragment::YXmlFragment;
3
3
  use crate::yxml_text::YXmlText;
4
4
  use crate::YTransaction;
5
5
  use magnus::block::Proc;
6
- use magnus::{Error, RArray, RHash, Symbol, Value};
6
+ use magnus::{Error, IntoValue, RArray, RHash, Symbol, Value};
7
7
  use std::cell::RefCell;
8
8
  use yrs::types::Change;
9
9
  use yrs::{
@@ -32,9 +32,9 @@ impl YXmlElement {
32
32
  let tx = tx.as_ref().unwrap();
33
33
 
34
34
  self.0.borrow().get(tx, index).map(|node| match node {
35
- XmlNode::Element(element) => Value::from(YXmlElement::from(element)),
36
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
37
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
35
+ XmlNode::Element(element) => YXmlElement::from(element).into_value(),
36
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
37
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
38
38
  })
39
39
  }
40
40
  pub(crate) fn yxml_element_get_attribute(
@@ -93,9 +93,9 @@ impl YXmlElement {
93
93
  let tx = tx.as_ref().unwrap();
94
94
 
95
95
  self.0.borrow().siblings(tx).next().map(|item| match item {
96
- XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
97
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
98
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
96
+ XmlNode::Element(el) => YXmlElement::from(el).into_value(),
97
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
98
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
99
99
  })
100
100
  }
101
101
  pub(crate) fn yxml_element_observe(&self, block: Proc) -> Result<u32, Error> {
@@ -161,9 +161,9 @@ impl YXmlElement {
161
161
  }
162
162
  pub(crate) fn yxml_element_parent(&self) -> Option<Value> {
163
163
  self.0.borrow().parent().map(|item| match item {
164
- XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
165
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
166
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
164
+ XmlNode::Element(el) => YXmlElement::from(el).into_value(),
165
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
166
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
167
167
  })
168
168
  }
169
169
  pub(crate) fn yxml_element_prev_sibling(&self, transaction: &YTransaction) -> Option<Value> {
@@ -175,9 +175,9 @@ impl YXmlElement {
175
175
  .siblings(tx)
176
176
  .next_back()
177
177
  .map(|item| match item {
178
- XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
179
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
180
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
178
+ XmlNode::Element(el) => YXmlElement::from(el).into_value(),
179
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
180
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
181
181
  })
182
182
  }
183
183
  pub(crate) fn yxml_element_push_element_back(
@@ -246,9 +246,9 @@ impl YXmlElement {
246
246
  let tx = tx.as_ref().unwrap();
247
247
 
248
248
  let siblings = self.0.borrow().siblings(tx).map(|item| match item {
249
- XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
250
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
251
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
249
+ XmlNode::Element(el) => YXmlElement::from(el).into_value(),
250
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
251
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
252
252
  });
253
253
 
254
254
  RArray::from_iter(siblings)
@@ -1,7 +1,7 @@
1
1
  use crate::ytransaction::YTransaction;
2
2
  use crate::yxml_element::YXmlElement;
3
3
  use crate::yxml_text::YXmlText;
4
- use magnus::{RArray, Value};
4
+ use magnus::{IntoValue, RArray, Value};
5
5
  use std::cell::RefCell;
6
6
  use yrs::{GetString, XmlElementPrelim, XmlFragment, XmlFragmentRef, XmlNode};
7
7
 
@@ -14,9 +14,9 @@ unsafe impl Send for YXmlFragment {}
14
14
  impl YXmlFragment {
15
15
  pub(crate) fn yxml_fragment_first_child(&self) -> Option<Value> {
16
16
  self.0.borrow().first_child().map(|node| match node {
17
- XmlNode::Element(element) => Value::from(YXmlElement::from(element)),
18
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
19
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
17
+ XmlNode::Element(element) => YXmlElement::from(element).into_value(),
18
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
19
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
20
20
  })
21
21
  }
22
22
 
@@ -29,9 +29,9 @@ impl YXmlFragment {
29
29
  let tx = tx.as_ref().unwrap();
30
30
 
31
31
  self.0.borrow().get(tx, index).map(|node| match node {
32
- XmlNode::Element(element) => Value::from(YXmlElement::from(element)),
33
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
34
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
32
+ XmlNode::Element(element) => YXmlElement::from(element).into_value(),
33
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
34
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
35
35
  })
36
36
  }
37
37
 
@@ -57,9 +57,9 @@ impl YXmlFragment {
57
57
 
58
58
  pub(crate) fn yxml_fragment_parent(&self) -> Option<Value> {
59
59
  self.0.borrow().parent().map(|item| match item {
60
- XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
61
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
62
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
60
+ XmlNode::Element(el) => YXmlElement::from(el).into_value(),
61
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
62
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
63
63
  })
64
64
  }
65
65
 
@@ -106,9 +106,9 @@ impl YXmlFragment {
106
106
  let fragment = self.0.borrow();
107
107
 
108
108
  let result = fragment.successors(tx).map(|item| match item {
109
- XmlNode::Element(el) => Value::from(YXmlElement::from(el)),
110
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment::from(fragment)),
111
- XmlNode::Text(text) => Value::from(YXmlText::from(text)),
109
+ XmlNode::Element(el) => YXmlElement::from(el).into_value(),
110
+ XmlNode::Fragment(fragment) => YXmlFragment::from(fragment).into_value(),
111
+ XmlNode::Text(text) => YXmlText::from(text).into_value(),
112
112
  });
113
113
 
114
114
  RArray::from_iter(result)
@@ -3,7 +3,7 @@ use crate::yvalue::YValue;
3
3
  use crate::yxml_fragment::YXmlFragment;
4
4
  use crate::{YTransaction, YXmlElement};
5
5
  use lib0::any::Any;
6
- use magnus::{Error, RHash, Value};
6
+ use magnus::{Error, IntoValue, RHash, Value};
7
7
  use std::cell::RefCell;
8
8
  use yrs::{GetString, Text, Xml, XmlNode, XmlTextRef};
9
9
 
@@ -120,16 +120,16 @@ impl YXmlText {
120
120
  let tx = tx.as_ref().unwrap();
121
121
 
122
122
  self.0.borrow().siblings(tx).next().map(|item| match item {
123
- XmlNode::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
124
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment(RefCell::from(fragment))),
125
- XmlNode::Text(text) => Value::from(YXmlText(RefCell::from(text))),
123
+ XmlNode::Element(el) => YXmlElement(RefCell::from(el)).into_value(),
124
+ XmlNode::Fragment(fragment) => YXmlFragment(RefCell::from(fragment)).into_value(),
125
+ XmlNode::Text(text) => YXmlText(RefCell::from(text)).into_value(),
126
126
  })
127
127
  }
128
128
  pub(crate) fn yxml_text_parent(&self) -> Option<Value> {
129
129
  self.0.borrow().parent().map(|item| match item {
130
- XmlNode::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
131
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment(RefCell::from(fragment))),
132
- XmlNode::Text(text) => Value::from(YXmlText(RefCell::from(text))),
130
+ XmlNode::Element(el) => YXmlElement(RefCell::from(el)).into_value(),
131
+ XmlNode::Fragment(fragment) => YXmlFragment(RefCell::from(fragment)).into_value(),
132
+ XmlNode::Text(text) => YXmlText(RefCell::from(text)).into_value(),
133
133
  })
134
134
  }
135
135
  pub(crate) fn yxml_text_prev_sibling(&self, transaction: &YTransaction) -> Option<Value> {
@@ -141,9 +141,9 @@ impl YXmlText {
141
141
  .siblings(tx)
142
142
  .next_back()
143
143
  .map(|item| match item {
144
- XmlNode::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
145
- XmlNode::Fragment(fragment) => Value::from(YXmlFragment(RefCell::from(fragment))),
146
- XmlNode::Text(text) => Value::from(YXmlText(RefCell::from(text))),
144
+ XmlNode::Element(el) => YXmlElement(RefCell::from(el)).into_value(),
145
+ XmlNode::Fragment(fragment) => YXmlFragment(RefCell::from(fragment)).into_value(),
146
+ XmlNode::Text(text) => YXmlText(RefCell::from(text)).into_value(),
147
147
  })
148
148
  }
149
149
  pub(crate) fn yxml_text_push(&self, transaction: &YTransaction, content: String) {
data/lib/3.0/yrb.so CHANGED
Binary file
data/lib/3.1/yrb.so CHANGED
Binary file
data/lib/3.2/yrb.so CHANGED
Binary file
data/lib/y/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Y
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.3"
5
5
  end
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.5.2
4
+ version: 0.5.3
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Hannes Moser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2023-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake