y-rb 0.2.0-aarch64-linux → 0.3.0-aarch64-linux

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.
@@ -23,45 +23,39 @@ impl YXmlElement {
23
23
  pub(crate) fn yxml_element_get(&self, index: u32) -> Option<Value> {
24
24
  self.0.borrow().get(index).map(|node| match node {
25
25
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
26
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
26
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
27
27
  })
28
28
  }
29
- pub(crate) fn yxml_element_get_attribute(
30
- &self,
31
- name: String
32
- ) -> Option<String> {
29
+ pub(crate) fn yxml_element_get_attribute(&self, name: String) -> Option<String> {
33
30
  self.0.borrow().get_attribute(&*name)
34
31
  }
35
32
  pub(crate) fn yxml_element_insert_attribute(
36
33
  &self,
37
34
  transaction: &YTransaction,
38
35
  name: String,
39
- value: String
36
+ value: String,
40
37
  ) {
41
- self.0.borrow_mut().insert_attribute(
42
- &mut *transaction.0.borrow_mut(),
43
- name,
44
- value
45
- );
38
+ self.0
39
+ .borrow_mut()
40
+ .insert_attribute(&mut *transaction.0.borrow_mut(), name, value);
46
41
  }
47
42
  pub(crate) fn yxml_element_insert_element(
48
43
  &self,
49
44
  transaction: &YTransaction,
50
45
  index: u32,
51
- name: String
46
+ name: String,
52
47
  ) -> YXmlElement {
53
- let element = self.0.borrow_mut().insert_elem(
54
- &mut *transaction.0.borrow_mut(),
55
- index,
56
- name
57
- );
48
+ let element =
49
+ self.0
50
+ .borrow_mut()
51
+ .insert_elem(&mut *transaction.0.borrow_mut(), index, name);
58
52
 
59
53
  YXmlElement(RefCell::from(element))
60
54
  }
61
55
  pub(crate) fn yxml_element_insert_text(
62
56
  &self,
63
57
  transaction: &YTransaction,
64
- index: u32
58
+ index: u32,
65
59
  ) -> YXmlText {
66
60
  let text = self
67
61
  .0
@@ -73,19 +67,18 @@ impl YXmlElement {
73
67
  pub(crate) fn yxml_element_next_sibling(&self) -> Option<Value> {
74
68
  self.0.borrow().next_sibling().map(|item| match item {
75
69
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
76
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
70
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
77
71
  })
78
72
  }
79
- pub(crate) fn yxml_element_observe(
80
- &self,
81
- block: Proc
82
- ) -> Result<u32, Error> {
73
+ pub(crate) fn yxml_element_observe(&self, block: Proc) -> Result<u32, Error> {
83
74
  let change_added = Symbol::new("added").to_static();
84
75
  let change_retain = Symbol::new("retain").to_static();
85
76
  let change_removed = Symbol::new("removed").to_static();
86
77
 
87
- let subscription_id = self.0.borrow_mut().observe(
88
- move |transaction, xml_element_event| {
78
+ let subscription_id = self
79
+ .0
80
+ .borrow_mut()
81
+ .observe(move |transaction, xml_element_event| {
89
82
  let delta = xml_element_event.delta(transaction);
90
83
  let changes = RArray::with_capacity(delta.len());
91
84
 
@@ -103,9 +96,9 @@ impl YXmlElement {
103
96
  .aset(change_added, RArray::from_vec(values))
104
97
  .expect("cannot create change::added payload");
105
98
 
106
- changes.push(payload).expect(
107
- "cannot push payload to list of changes"
108
- );
99
+ changes
100
+ .push(payload)
101
+ .expect("cannot push payload to list of changes");
109
102
  }
110
103
  Change::Retain(position) => {
111
104
  let payload = RHash::new();
@@ -113,19 +106,19 @@ impl YXmlElement {
113
106
  .aset(change_retain, *position)
114
107
  .expect("cannot create change::retain payload");
115
108
 
116
- changes.push(payload).expect(
117
- "cannot push payload to list of changes"
118
- );
109
+ changes
110
+ .push(payload)
111
+ .expect("cannot push payload to list of changes");
119
112
  }
120
113
  Change::Removed(position) => {
121
114
  let payload = RHash::new();
122
- payload.aset(change_removed, *position).expect(
123
- "cannot create change::removed payload"
124
- );
115
+ payload
116
+ .aset(change_removed, *position)
117
+ .expect("cannot create change::removed payload");
125
118
 
126
- changes.push(payload).expect(
127
- "cannot push payload to list of changes"
128
- );
119
+ changes
120
+ .push(payload)
121
+ .expect("cannot push payload to list of changes");
129
122
  }
130
123
  }
131
124
  }
@@ -133,8 +126,7 @@ impl YXmlElement {
133
126
  block
134
127
  .call::<(RArray,), Value>((changes,))
135
128
  .expect("cannot call block");
136
- }
137
- );
129
+ });
138
130
 
139
131
  Ok(subscription_id.into())
140
132
  }
@@ -147,13 +139,13 @@ impl YXmlElement {
147
139
  pub(crate) fn yxml_element_prev_sibling(&self) -> Option<Value> {
148
140
  self.0.borrow().prev_sibling().map(|item| match item {
149
141
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
150
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
142
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
151
143
  })
152
144
  }
153
145
  pub(crate) fn yxml_element_push_element_back(
154
146
  &self,
155
147
  transaction: &YTransaction,
156
- name: String
148
+ name: String,
157
149
  ) -> YXmlElement {
158
150
  let xml_element = self
159
151
  .0
@@ -165,7 +157,7 @@ impl YXmlElement {
165
157
  pub(crate) fn yxml_element_push_element_front(
166
158
  &self,
167
159
  transaction: &YTransaction,
168
- name: String
160
+ name: String,
169
161
  ) -> YXmlElement {
170
162
  let xml_element = self
171
163
  .0
@@ -174,10 +166,7 @@ impl YXmlElement {
174
166
 
175
167
  YXmlElement(RefCell::from(xml_element))
176
168
  }
177
- pub(crate) fn yxml_element_push_text_back(
178
- &self,
179
- transaction: &YTransaction
180
- ) -> YXmlText {
169
+ pub(crate) fn yxml_element_push_text_back(&self, transaction: &YTransaction) -> YXmlText {
181
170
  let xml_text = self
182
171
  .0
183
172
  .borrow_mut()
@@ -185,10 +174,7 @@ impl YXmlElement {
185
174
 
186
175
  YXmlText(RefCell::from(xml_text))
187
176
  }
188
- pub(crate) fn yxml_element_push_text_front(
189
- &self,
190
- transaction: &YTransaction
191
- ) -> YXmlText {
177
+ pub(crate) fn yxml_element_push_text_front(&self, transaction: &YTransaction) -> YXmlText {
192
178
  let xml_text = self
193
179
  .0
194
180
  .borrow_mut()
@@ -196,27 +182,20 @@ impl YXmlElement {
196
182
 
197
183
  YXmlText(RefCell::from(xml_text))
198
184
  }
199
- pub(crate) fn yxml_element_remove_attribute(
200
- &self,
201
- transaction: &YTransaction,
202
- name: String
203
- ) {
204
- self.0.borrow_mut().remove_attribute::<&str>(
205
- &mut *transaction.0.borrow_mut(),
206
- &name.as_str()
207
- );
185
+ pub(crate) fn yxml_element_remove_attribute(&self, transaction: &YTransaction, name: String) {
186
+ self.0
187
+ .borrow_mut()
188
+ .remove_attribute::<&str>(&mut *transaction.0.borrow_mut(), &name.as_str());
208
189
  }
209
190
  pub(crate) fn yxml_element_remove_range(
210
191
  &self,
211
192
  transaction: &YTransaction,
212
193
  index: u32,
213
- length: u32
194
+ length: u32,
214
195
  ) {
215
- self.0.borrow_mut().remove_range(
216
- &mut *transaction.0.borrow_mut(),
217
- index,
218
- length
219
- );
196
+ self.0
197
+ .borrow_mut()
198
+ .remove_range(&mut *transaction.0.borrow_mut(), index, length);
220
199
  }
221
200
  pub(crate) fn yxml_element_size(&self) -> u32 {
222
201
  self.0.borrow().len()
@@ -21,53 +21,38 @@ impl YXmlText {
21
21
  transaction: &YTransaction,
22
22
  index: u32,
23
23
  length: u32,
24
- attrs: RHash
24
+ attrs: RHash,
25
25
  ) -> Result<(), Error> {
26
26
  map_rhash_to_attrs(attrs).map(|a| {
27
- self.0.borrow_mut().format(
28
- &mut *transaction.0.borrow_mut(),
29
- index,
30
- length,
31
- a
32
- );
27
+ self.0
28
+ .borrow_mut()
29
+ .format(&mut *transaction.0.borrow_mut(), index, length, a);
33
30
  })
34
31
  }
35
- pub(crate) fn yxml_text_get_attribute(
36
- &self,
37
- name: String
38
- ) -> Option<String> {
32
+ pub(crate) fn yxml_text_get_attribute(&self, name: String) -> Option<String> {
39
33
  self.0.borrow().get_attribute(&*name)
40
34
  }
41
- pub(crate) fn yxml_text_insert(
42
- &self,
43
- transaction: &YTransaction,
44
- index: u32,
45
- content: String
46
- ) {
47
- self.0.borrow_mut().insert(
48
- &mut *transaction.0.borrow_mut(),
49
- index,
50
- &*content
51
- )
35
+ pub(crate) fn yxml_text_insert(&self, transaction: &YTransaction, index: u32, content: String) {
36
+ self.0
37
+ .borrow_mut()
38
+ .insert(&mut *transaction.0.borrow_mut(), index, &*content)
52
39
  }
53
40
  pub(crate) fn yxml_text_insert_attribute(
54
41
  &self,
55
42
  transaction: &YTransaction,
56
43
  name: String,
57
- value: String
44
+ value: String,
58
45
  ) {
59
- self.0.borrow_mut().insert_attribute(
60
- &mut *transaction.0.borrow_mut(),
61
- name,
62
- value
63
- )
46
+ self.0
47
+ .borrow_mut()
48
+ .insert_attribute(&mut *transaction.0.borrow_mut(), name, value)
64
49
  }
65
50
  pub(crate) fn yxml_text_insert_embed_with_attributes(
66
51
  &self,
67
52
  transaction: &YTransaction,
68
53
  index: u32,
69
54
  content: Value,
70
- attrs: RHash
55
+ attrs: RHash,
71
56
  ) -> Result<(), Error> {
72
57
  let yvalue = YValue::from(content);
73
58
  let avalue = Any::from(yvalue);
@@ -77,7 +62,7 @@ impl YXmlText {
77
62
  &mut *transaction.0.borrow_mut(),
78
63
  index,
79
64
  avalue,
80
- a
65
+ a,
81
66
  );
82
67
  })
83
68
  }
@@ -85,12 +70,12 @@ impl YXmlText {
85
70
  &self,
86
71
  transaction: &YTransaction,
87
72
  index: u32,
88
- embed: Value
73
+ embed: Value,
89
74
  ) {
90
75
  self.0.borrow_mut().insert_embed(
91
76
  &mut *transaction.0.borrow_mut(),
92
77
  index,
93
- Any::from(YValue::from(embed))
78
+ Any::from(YValue::from(embed)),
94
79
  )
95
80
  }
96
81
  pub(crate) fn yxml_text_insert_with_attributes(
@@ -98,14 +83,14 @@ impl YXmlText {
98
83
  transaction: &YTransaction,
99
84
  index: u32,
100
85
  content: String,
101
- attrs: RHash
86
+ attrs: RHash,
102
87
  ) -> Result<(), Error> {
103
88
  map_rhash_to_attrs(attrs).map(|a| {
104
89
  self.0.borrow_mut().insert_with_attributes(
105
90
  &mut *transaction.0.borrow_mut(),
106
91
  index,
107
92
  &*content,
108
- a
93
+ a,
109
94
  );
110
95
  })
111
96
  }
@@ -115,7 +100,7 @@ impl YXmlText {
115
100
  pub(crate) fn yxml_text_next_sibling(&self) -> Option<Value> {
116
101
  self.0.borrow().next_sibling().map(|item| match item {
117
102
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
118
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
103
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
119
104
  })
120
105
  }
121
106
  pub(crate) fn yxml_text_parent(&self) -> Option<Value> {
@@ -127,14 +112,10 @@ impl YXmlText {
127
112
  pub(crate) fn yxml_text_prev_sibling(&self) -> Option<Value> {
128
113
  self.0.borrow().prev_sibling().map(|item| match item {
129
114
  Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
130
- Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
115
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text))),
131
116
  })
132
117
  }
133
- pub(crate) fn yxml_text_push(
134
- &self,
135
- transaction: &YTransaction,
136
- content: String
137
- ) {
118
+ pub(crate) fn yxml_text_push(&self, transaction: &YTransaction, content: String) {
138
119
  self.0
139
120
  .borrow_mut()
140
121
  .push(&mut *transaction.0.borrow_mut(), &*content)
@@ -143,13 +124,11 @@ impl YXmlText {
143
124
  &self,
144
125
  transaction: &YTransaction,
145
126
  index: u32,
146
- length: u32
127
+ length: u32,
147
128
  ) {
148
- self.0.borrow_mut().remove_range(
149
- &mut *transaction.0.borrow_mut(),
150
- index,
151
- length
152
- );
129
+ self.0
130
+ .borrow_mut()
131
+ .remove_range(&mut *transaction.0.borrow_mut(), index, length);
153
132
  }
154
133
  pub(crate) fn yxml_text_to_s(&self) -> String {
155
134
  self.0.borrow().to_string()
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/array.rb CHANGED
@@ -20,6 +20,8 @@ module Y
20
20
  #
21
21
  # array.to_a == [1, 2, 3, 4, 5] # true
22
22
  class Array
23
+ include Enumerable
24
+
23
25
  # @!attribute [r] document
24
26
  #
25
27
  # @return [Y::Doc] The document this array belongs to
data/lib/y/awareness.rb CHANGED
@@ -48,6 +48,7 @@ module Y
48
48
  yawareness_update_with_clients(clients)
49
49
  end
50
50
 
51
+ # rubocop:disable Lint/UselessAccessModifier
51
52
  private
52
53
 
53
54
  # @!method yawareness_apply_update(update)
@@ -120,9 +121,11 @@ module Y
120
121
  #
121
122
  # @param [Array<Integer>]
122
123
  # @return [Y::AwarenessUpdate] The update object
124
+
125
+ # rubocop:enable Lint/UselessAccessModifier
123
126
  end
124
127
 
125
- # rubocop:disable Lint/EmptyClass
128
+ # rubocop:disable Lint/UselessAccessModifier
126
129
  class AwarenessEvent
127
130
  private
128
131
 
@@ -135,8 +138,9 @@ module Y
135
138
  # @!method removed
136
139
  # @return [Array<Integer>] Removed clients
137
140
  end
138
- # rubocop:enable Lint/EmptyClass
141
+ # rubocop:enable Lint/UselessAccessModifier
139
142
 
143
+ # rubocop:disable Lint/UselessAccessModifier
140
144
  class AwarenessUpdate
141
145
  def encode
142
146
  yawareness_update_encode
@@ -149,4 +153,5 @@ module Y
149
153
  #
150
154
  # @return [Array<Integer>] Encoded update
151
155
  end
156
+ # rubocop:enable Lint/UselessAccessModifier
152
157
  end
data/lib/y/doc.rb CHANGED
@@ -113,7 +113,7 @@ module Y
113
113
  # @return [Y::XMLElement]
114
114
  def get_xml_element(name)
115
115
  xml_element = current_transaction.get_xml_element(name)
116
- xml_element.document = self
116
+ xml_element&.document = self
117
117
  xml_element
118
118
  end
119
119
 
data/lib/y/map.rb CHANGED
@@ -18,6 +18,8 @@ module Y
18
18
  # map[:hello] = "world"
19
19
  # puts map[:hello]
20
20
  class Map
21
+ include Enumerable
22
+
21
23
  # @!attribute [r] document
22
24
  #
23
25
  # @return [Y::Doc] The document this map belongs to
data/lib/y/text.rb CHANGED
@@ -115,7 +115,7 @@ module Y
115
115
  # - Hash (where the the types of key and values must be supported)
116
116
  #
117
117
  # @param [Integer] index
118
- # @param [String, Float, Array, Hash] value
118
+ # @param [String, Numeric, Array, Hash] value
119
119
  # @param [Hash|nil] attrs
120
120
  # @return [void]
121
121
  def insert(index, value, attrs = nil)
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.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/y/xml.rb CHANGED
@@ -43,11 +43,13 @@ module Y
43
43
  # @param [Integer] index
44
44
  # @param [String] name Name of node, e.g. `<p />`
45
45
  # @return [Y::XMLElement]
46
+ # rubocop:disable Lint/Void
46
47
  def []=(index, name)
47
48
  node = yxml_element_insert_element(transaction, index, name)
48
49
  node.document = document
49
50
  node
50
51
  end
52
+ # rubocop:enable Lint/Void
51
53
 
52
54
  # Returns first child in list or nil if no child exists
53
55
  #
@@ -294,7 +296,7 @@ module Y
294
296
  setter = method_name
295
297
  setter += "=" unless is_setter
296
298
  getter = method_name
297
- getter = getter.to_s.slice(0...-1).to_sym if is_setter
299
+ getter = getter.to_s.slice(0...-1)&.to_sym if is_setter
298
300
 
299
301
  define_singleton_method(setter.to_sym) do |new_val|
300
302
  yxml_element_insert_attribute(transaction,
@@ -352,7 +354,8 @@ module Y
352
354
  # @return [String|nil]
353
355
 
354
356
  # @!method yxml_element_insert_element(transaction, index, name)
355
- #
357
+ # Insert XML element into this XML element
358
+ # @!visibility private
356
359
  # @param [Y::Transaction] transaction
357
360
  # @param [Integer] index
358
361
  # @param [String] name
data/lib/y-rb.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Naming/FileName
1
2
  # frozen_string_literal: true
2
3
 
3
4
  # load native extension
@@ -19,3 +20,4 @@ require_relative "y/version"
19
20
 
20
21
  module Y
21
22
  end
23
+ # rubocop:enable Naming/FileName
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.2.0
4
+ version: 0.3.0
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: 2022-10-14 00:00:00.000000000 Z
11
+ date: 2022-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.31
33
+ version: 0.9.32
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.9.31
40
+ version: 0.9.32
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake-compiler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: 3.3.21
132
132
  requirements: []
133
- rubygems_version: 3.4.0.dev
133
+ rubygems_version: 3.3.22
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Ruby bindings for yrs