y-rb 0.1.2 → 0.1.4.alpha.1
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/ext/yrb/Cargo.lock +623 -0
- data/{Cargo.toml → ext/yrb/Cargo.toml} +7 -10
- data/ext/yrb/extconf.rb +6 -0
- data/ext/yrb/src/lib.rs +476 -0
- data/ext/yrb/src/utils.rs +36 -0
- data/ext/yrb/src/yany.rs +44 -0
- data/ext/yrb/src/yarray.rs +175 -0
- data/ext/yrb/src/yattrs.rs +48 -0
- data/ext/yrb/src/ydoc.rs +39 -0
- data/ext/yrb/src/ymap.rs +165 -0
- data/ext/yrb/src/ytext.rs +228 -0
- data/ext/yrb/src/ytransaction.rs +58 -0
- data/ext/yrb/src/yvalue.rs +235 -0
- data/ext/yrb/src/yxml_element.rs +225 -0
- data/ext/yrb/src/yxml_text.rs +154 -0
- data/lib/y/doc.rb +2 -2
- data/lib/y/text.rb +9 -7
- data/lib/y/version.rb +1 -1
- data/lib/y.rb +16 -0
- metadata +70 -41
- data/.dockerignore +0 -5
- data/.editorconfig +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -23
- data/.rustfmt.toml +0 -74
- data/.yardopts +0 -2
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -75
- data/LICENSE.txt +0 -21
- data/README.md +0 -98
- data/Rakefile +0 -39
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/docs/decisions.md +0 -64
- data/docs/examples.md +0 -16
- data/docs/release.md +0 -9
- data/ext/Rakefile +0 -9
- data/lib/y/rb.rb +0 -17
- data/src/lib.rs +0 -248
- data/src/util.rs +0 -146
- data/src/yarray.rs +0 -184
- data/src/ydoc.rs +0 -71
- data/src/ymap.rs +0 -199
- data/src/ytext.rs +0 -204
- data/src/ytransaction.rs +0 -102
- data/src/yxml.rs +0 -550
- data/y-rb.gemspec +0 -44
data/lib/y/text.rb
CHANGED
@@ -87,7 +87,7 @@ module Y
|
|
87
87
|
#
|
88
88
|
# text.empty? # true
|
89
89
|
#
|
90
|
-
# @return [
|
90
|
+
# @return [TrueClass,FalseClass]
|
91
91
|
def empty?
|
92
92
|
length.zero?
|
93
93
|
end
|
@@ -122,8 +122,7 @@ module Y
|
|
122
122
|
if value.is_a?(String)
|
123
123
|
ytext_insert(transaction, index, value) if attrs.nil?
|
124
124
|
unless attrs.nil?
|
125
|
-
|
126
|
-
attrs)
|
125
|
+
ytext_insert_with_attributes(transaction, index, value, attrs)
|
127
126
|
end
|
128
127
|
return nil
|
129
128
|
end
|
@@ -131,8 +130,7 @@ module Y
|
|
131
130
|
if can_insert?(value)
|
132
131
|
ytext_insert_embed(transaction, index, value) if attrs.nil?
|
133
132
|
unless attrs.nil?
|
134
|
-
|
135
|
-
attrs)
|
133
|
+
ytext_insert_embed_with_attributes(transaction, index, value, attrs)
|
136
134
|
end
|
137
135
|
return nil
|
138
136
|
end
|
@@ -279,6 +277,8 @@ module Y
|
|
279
277
|
value.is_a?(Hash)
|
280
278
|
end
|
281
279
|
|
280
|
+
# rubocop:disable Layout/LineLength
|
281
|
+
|
282
282
|
# @!method ytext_insert(transaction, index, chunk)
|
283
283
|
# Insert into text at position
|
284
284
|
#
|
@@ -295,7 +295,7 @@ module Y
|
|
295
295
|
# @param [Y::Text, Y::Array, Y::Map] content
|
296
296
|
# @return [nil]
|
297
297
|
|
298
|
-
# @!method
|
298
|
+
# @!method ytext_insert_embed_with_attributes(transaction, index, embed, attrs)
|
299
299
|
# Insert into text at position
|
300
300
|
#
|
301
301
|
# @param [Y::Transaction] transaction
|
@@ -304,7 +304,7 @@ module Y
|
|
304
304
|
# @param [Hash] attrs
|
305
305
|
# @return [nil]
|
306
306
|
|
307
|
-
# @!method
|
307
|
+
# @!method ytext_insert_with_attributes(transaction, index, chunk, attrs)
|
308
308
|
# Insert into text at position
|
309
309
|
#
|
310
310
|
# @param [Y::Transaction] transaction
|
@@ -359,6 +359,8 @@ module Y
|
|
359
359
|
# @param [Integer] subscription_id
|
360
360
|
# @return [void]
|
361
361
|
|
362
|
+
# rubocop:enable Layout/LineLength
|
363
|
+
|
362
364
|
# A reference to the current active transaction of the document this map
|
363
365
|
# belongs to.
|
364
366
|
#
|
data/lib/y/version.rb
CHANGED
data/lib/y.rb
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# load native extension
|
4
|
+
begin
|
5
|
+
ruby_version = /(\d+\.\d+)/.match(::RUBY_VERSION)
|
6
|
+
require_relative "#{ruby_version}/yrb"
|
7
|
+
rescue LoadError
|
8
|
+
require "yrb"
|
9
|
+
end
|
10
|
+
|
11
|
+
require_relative "y/array"
|
12
|
+
require_relative "y/doc"
|
13
|
+
require_relative "y/map"
|
14
|
+
require_relative "y/text"
|
15
|
+
require_relative "y/xml"
|
16
|
+
require_relative "y/transaction"
|
17
|
+
require_relative "y/version"
|
18
|
+
|
3
19
|
module Y
|
4
20
|
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.1.
|
4
|
+
version: 0.1.4.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hannes Moser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -25,78 +25,107 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '13.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rb_sys
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.9.30
|
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.
|
40
|
+
version: 0.9.30
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
47
|
+
version: 6.1.6.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 6.1.6.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitar
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake-compiler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.2.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.2.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake-compiler-dock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.2.2
|
90
|
+
type: :development
|
49
91
|
prerelease: false
|
50
92
|
version_requirements: !ruby/object:Gem::Requirement
|
51
93
|
requirements:
|
52
94
|
- - "~>"
|
53
95
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
96
|
+
version: 1.2.2
|
55
97
|
description: Ruby bindings for yrs. Yrs "wires" is a Rust port of the Yjs framework.
|
56
98
|
email:
|
57
99
|
- hmoser@gitlab.com
|
58
100
|
- box@hannesmoser.at
|
59
101
|
executables: []
|
60
102
|
extensions:
|
61
|
-
- ext/
|
103
|
+
- ext/yrb/extconf.rb
|
62
104
|
extra_rdoc_files: []
|
63
105
|
files:
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
- docs/examples.md
|
80
|
-
- docs/release.md
|
81
|
-
- ext/Rakefile
|
106
|
+
- ext/yrb/Cargo.lock
|
107
|
+
- ext/yrb/Cargo.toml
|
108
|
+
- ext/yrb/extconf.rb
|
109
|
+
- ext/yrb/src/lib.rs
|
110
|
+
- ext/yrb/src/utils.rs
|
111
|
+
- ext/yrb/src/yany.rs
|
112
|
+
- ext/yrb/src/yarray.rs
|
113
|
+
- ext/yrb/src/yattrs.rs
|
114
|
+
- ext/yrb/src/ydoc.rs
|
115
|
+
- ext/yrb/src/ymap.rs
|
116
|
+
- ext/yrb/src/ytext.rs
|
117
|
+
- ext/yrb/src/ytransaction.rs
|
118
|
+
- ext/yrb/src/yvalue.rs
|
119
|
+
- ext/yrb/src/yxml_element.rs
|
120
|
+
- ext/yrb/src/yxml_text.rs
|
82
121
|
- lib/y.rb
|
83
122
|
- lib/y/array.rb
|
84
123
|
- lib/y/doc.rb
|
85
124
|
- lib/y/map.rb
|
86
|
-
- lib/y/rb.rb
|
87
125
|
- lib/y/text.rb
|
88
126
|
- lib/y/transaction.rb
|
89
127
|
- lib/y/version.rb
|
90
128
|
- lib/y/xml.rb
|
91
|
-
- src/lib.rs
|
92
|
-
- src/util.rs
|
93
|
-
- src/yarray.rs
|
94
|
-
- src/ydoc.rs
|
95
|
-
- src/ymap.rs
|
96
|
-
- src/ytext.rs
|
97
|
-
- src/ytransaction.rs
|
98
|
-
- src/yxml.rs
|
99
|
-
- y-rb.gemspec
|
100
129
|
homepage: https://github.com/y-crdt/yrb
|
101
130
|
licenses:
|
102
131
|
- MIT
|
@@ -114,12 +143,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
143
|
requirements:
|
115
144
|
- - ">="
|
116
145
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
146
|
+
version: 2.7.0
|
118
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
148
|
requirements:
|
120
|
-
- - "
|
149
|
+
- - ">"
|
121
150
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
151
|
+
version: 1.3.1
|
123
152
|
requirements: []
|
124
153
|
rubygems_version: 3.2.32
|
125
154
|
signing_key:
|
data/.editorconfig
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# EditorConfig is awesome: https://EditorConfig.org
|
2
|
-
|
3
|
-
root = true
|
4
|
-
|
5
|
-
[*]
|
6
|
-
end_of_line = lf
|
7
|
-
insert_final_newline = true
|
8
|
-
charset = utf-8
|
9
|
-
|
10
|
-
[*.{rb,yml}]
|
11
|
-
indent_style = space
|
12
|
-
indent_size = 2
|
13
|
-
|
14
|
-
[*.rs]
|
15
|
-
indent_style = space
|
16
|
-
indent_size = 4
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
NewCops: enable
|
3
|
-
TargetRubyVersion: 2.6
|
4
|
-
|
5
|
-
Metrics/BlockLength:
|
6
|
-
Exclude:
|
7
|
-
- spec/y/*_spec.rb
|
8
|
-
|
9
|
-
Style/Documentation:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
Style/StringLiterals:
|
13
|
-
Enabled: true
|
14
|
-
EnforcedStyle: double_quotes
|
15
|
-
|
16
|
-
Style/StringLiteralsInInterpolation:
|
17
|
-
Enabled: true
|
18
|
-
EnforcedStyle: double_quotes
|
19
|
-
|
20
|
-
Layout/LineLength:
|
21
|
-
Max: 80
|
22
|
-
Exclude:
|
23
|
-
- y-rb.gemspec
|
data/.rustfmt.toml
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
max_width = 80
|
2
|
-
hard_tabs = false
|
3
|
-
tab_spaces = 4
|
4
|
-
newline_style = "Auto"
|
5
|
-
indent_style = "Block"
|
6
|
-
use_small_heuristics = "Default"
|
7
|
-
fn_call_width = 60
|
8
|
-
attr_fn_like_width = 70
|
9
|
-
struct_lit_width = 18
|
10
|
-
struct_variant_width = 35
|
11
|
-
array_width = 60
|
12
|
-
chain_width = 60
|
13
|
-
single_line_if_else_max_width = 50
|
14
|
-
wrap_comments = false
|
15
|
-
format_code_in_doc_comments = false
|
16
|
-
comment_width = 80
|
17
|
-
normalize_comments = false
|
18
|
-
normalize_doc_attributes = false
|
19
|
-
license_template_path = ""
|
20
|
-
format_strings = false
|
21
|
-
format_macro_matchers = false
|
22
|
-
format_macro_bodies = true
|
23
|
-
empty_item_single_line = true
|
24
|
-
struct_lit_single_line = true
|
25
|
-
fn_single_line = false
|
26
|
-
where_single_line = false
|
27
|
-
imports_indent = "Block"
|
28
|
-
imports_layout = "Mixed"
|
29
|
-
imports_granularity = "Preserve"
|
30
|
-
group_imports = "Preserve"
|
31
|
-
reorder_imports = true
|
32
|
-
reorder_modules = true
|
33
|
-
reorder_impl_items = false
|
34
|
-
type_punctuation_density = "Wide"
|
35
|
-
space_before_colon = false
|
36
|
-
space_after_colon = true
|
37
|
-
spaces_around_ranges = false
|
38
|
-
binop_separator = "Front"
|
39
|
-
remove_nested_parens = true
|
40
|
-
combine_control_expr = true
|
41
|
-
overflow_delimited_expr = false
|
42
|
-
struct_field_align_threshold = 0
|
43
|
-
enum_discrim_align_threshold = 0
|
44
|
-
match_arm_blocks = true
|
45
|
-
match_arm_leading_pipes = "Never"
|
46
|
-
force_multiline_blocks = false
|
47
|
-
fn_args_layout = "Tall"
|
48
|
-
brace_style = "SameLineWhere"
|
49
|
-
control_brace_style = "AlwaysSameLine"
|
50
|
-
trailing_semicolon = true
|
51
|
-
trailing_comma = "Never"
|
52
|
-
match_block_trailing_comma = false
|
53
|
-
blank_lines_upper_bound = 1
|
54
|
-
blank_lines_lower_bound = 0
|
55
|
-
edition = "2015"
|
56
|
-
version = "One"
|
57
|
-
inline_attribute_width = 0
|
58
|
-
merge_derives = true
|
59
|
-
use_try_shorthand = false
|
60
|
-
use_field_init_shorthand = false
|
61
|
-
force_explicit_abi = true
|
62
|
-
condense_wildcard_suffixes = false
|
63
|
-
color = "Auto"
|
64
|
-
unstable_features = false
|
65
|
-
disable_all_formatting = false
|
66
|
-
skip_children = false
|
67
|
-
hide_parse_errors = false
|
68
|
-
error_on_line_overflow = false
|
69
|
-
error_on_unformatted = false
|
70
|
-
report_todo = "Never"
|
71
|
-
report_fixme = "Never"
|
72
|
-
ignore = []
|
73
|
-
emit_mode = "Files"
|
74
|
-
make_backup = false
|
data/.yardopts
DELETED
data/Gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in y-rb.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem "github-markup"
|
9
|
-
gem "redcarpet"
|
10
|
-
gem "rspec", "~> 3.11.0"
|
11
|
-
gem "rubocop", "~> 1.21"
|
12
|
-
gem "rubocop-rspec", "~> 2.10.0"
|
13
|
-
gem "yard"
|
data/Gemfile.lock
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
y-rb (0.1.1)
|
5
|
-
rake (~> 13.0)
|
6
|
-
rutie (~> 0.0.4)
|
7
|
-
thermite (~> 0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
ast (2.4.2)
|
13
|
-
diff-lcs (1.5.0)
|
14
|
-
github-markup (4.0.1)
|
15
|
-
minitar (0.9)
|
16
|
-
parallel (1.22.1)
|
17
|
-
parser (3.1.2.0)
|
18
|
-
ast (~> 2.4.1)
|
19
|
-
rainbow (3.1.1)
|
20
|
-
rake (13.0.6)
|
21
|
-
redcarpet (3.5.1)
|
22
|
-
regexp_parser (2.5.0)
|
23
|
-
rexml (3.2.5)
|
24
|
-
rspec (3.11.0)
|
25
|
-
rspec-core (~> 3.11.0)
|
26
|
-
rspec-expectations (~> 3.11.0)
|
27
|
-
rspec-mocks (~> 3.11.0)
|
28
|
-
rspec-core (3.11.0)
|
29
|
-
rspec-support (~> 3.11.0)
|
30
|
-
rspec-expectations (3.11.0)
|
31
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.11.0)
|
33
|
-
rspec-mocks (3.11.1)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.11.0)
|
36
|
-
rspec-support (3.11.0)
|
37
|
-
rubocop (1.30.0)
|
38
|
-
parallel (~> 1.10)
|
39
|
-
parser (>= 3.1.0.0)
|
40
|
-
rainbow (>= 2.2.2, < 4.0)
|
41
|
-
regexp_parser (>= 1.8, < 3.0)
|
42
|
-
rexml (>= 3.2.5, < 4.0)
|
43
|
-
rubocop-ast (>= 1.18.0, < 2.0)
|
44
|
-
ruby-progressbar (~> 1.7)
|
45
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
46
|
-
rubocop-ast (1.18.0)
|
47
|
-
parser (>= 3.1.1.0)
|
48
|
-
rubocop-rspec (2.10.0)
|
49
|
-
rubocop (~> 1.19)
|
50
|
-
ruby-progressbar (1.11.0)
|
51
|
-
rutie (0.0.4)
|
52
|
-
thermite (0.13.0)
|
53
|
-
minitar (~> 0.5)
|
54
|
-
rake (>= 10)
|
55
|
-
tomlrb (~> 1.2)
|
56
|
-
tomlrb (1.3.0)
|
57
|
-
unicode-display_width (2.1.0)
|
58
|
-
webrick (1.7.0)
|
59
|
-
yard (0.9.27)
|
60
|
-
webrick (~> 1.7.0)
|
61
|
-
|
62
|
-
PLATFORMS
|
63
|
-
arm64-darwin-21
|
64
|
-
|
65
|
-
DEPENDENCIES
|
66
|
-
github-markup
|
67
|
-
redcarpet
|
68
|
-
rspec (~> 3.11.0)
|
69
|
-
rubocop (~> 1.21)
|
70
|
-
rubocop-rspec (~> 2.10.0)
|
71
|
-
y-rb!
|
72
|
-
yard
|
73
|
-
|
74
|
-
BUNDLED WITH
|
75
|
-
2.2.32
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2022 Hannes Moser <hmoser@gitlab.com>
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
# Yrb
|
2
|
-
|
3
|
-
Yrb is a Ruby binding for Y-CRDT. It provides distributed data types that enable
|
4
|
-
real-time collaboration between devices. Yrb can sync data with any other
|
5
|
-
platform that has a Y-CRDT binding, allowing for seamless cross-domain
|
6
|
-
communication.
|
7
|
-
|
8
|
-
The library is a thin wrapper around Yrs, taking advantage of the safety and
|
9
|
-
performance of Rust.
|
10
|
-
|
11
|
-
## Installation
|
12
|
-
|
13
|
-
Add this line to your application's Gemfile:
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
gem 'y-rb'
|
17
|
-
```
|
18
|
-
|
19
|
-
And then execute:
|
20
|
-
|
21
|
-
$ bundle install
|
22
|
-
|
23
|
-
Or install it yourself as:
|
24
|
-
|
25
|
-
$ gem install y-rb
|
26
|
-
|
27
|
-
> **⚠ WARNING: Binary dependencies are not pre-built.**
|
28
|
-
> In an upcoming version we will address the issue of binaries not being
|
29
|
-
> pre-built. Until then, you need to have the latest Rust + Cargo working on
|
30
|
-
> your machine in order to install y-rb.
|
31
|
-
|
32
|
-
## Usage
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
# creates a new document and text structure
|
36
|
-
local = Y::Doc.new
|
37
|
-
local_text = local.get_text("my text")
|
38
|
-
|
39
|
-
# add some data to the text structure
|
40
|
-
local_text.push("hello")
|
41
|
-
|
42
|
-
# create a remote doccument sharing the same text structure
|
43
|
-
remote = Y::Doc.new
|
44
|
-
remote_text = remote.get_text("my text")
|
45
|
-
|
46
|
-
# retrieve the current state of the remote document
|
47
|
-
remote_state = remote.state
|
48
|
-
|
49
|
-
# create an update for the remote document based on the current
|
50
|
-
# state of the remote document
|
51
|
-
update = local.diff(remote_state)
|
52
|
-
|
53
|
-
# apply update to remote document
|
54
|
-
remote.sync(update)
|
55
|
-
|
56
|
-
puts remote_text.to_s == local_text.to_s # true
|
57
|
-
```
|
58
|
-
|
59
|
-
More [examples](docs/examples.md).
|
60
|
-
|
61
|
-
## Development
|
62
|
-
|
63
|
-
Make sure you have `cargo` available (2021 edition). The gem needs the lib to
|
64
|
-
be built every time when there is a change.
|
65
|
-
|
66
|
-
```bash
|
67
|
-
cargo build --release
|
68
|
-
```
|
69
|
-
|
70
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
71
|
-
run `rake spec` to run the tests. You can also run `bin/console` for an
|
72
|
-
interactive prompt that will allow you to experiment.
|
73
|
-
|
74
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
75
|
-
To release a new version, update the version number in `version.rb`, and then
|
76
|
-
run `bundle exec rake release`, which will create a git tag for the version,
|
77
|
-
push git commits and the created tag, and push the `.gem` file to
|
78
|
-
[rubygems.org](https://rubygems.org).
|
79
|
-
|
80
|
-
## Docs
|
81
|
-
|
82
|
-
You can run `yard` locally and open the docs with:
|
83
|
-
|
84
|
-
```bash
|
85
|
-
yard server
|
86
|
-
open "http://0.0.0.0:8808/"
|
87
|
-
```
|
88
|
-
|
89
|
-
## Decision log
|
90
|
-
|
91
|
-
For this `gem`, we maintain a [decision log](docs/decisions.md). Please consult it
|
92
|
-
in case there is some ambiguity in terms of why certain implementation details
|
93
|
-
look as they are.
|
94
|
-
|
95
|
-
## License
|
96
|
-
|
97
|
-
The gem is available as open source under the terms of the
|
98
|
-
[MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
require "rspec/core/rake_task"
|
5
|
-
require "yard"
|
6
|
-
require "rubocop/rake_task"
|
7
|
-
require "thermite/tasks"
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new(:spec)
|
10
|
-
|
11
|
-
RuboCop::RakeTask.new
|
12
|
-
|
13
|
-
task default: %i[spec rubocop]
|
14
|
-
|
15
|
-
desc "Compile the y-rb crate"
|
16
|
-
task :compile do
|
17
|
-
# MacOS: ARM + x64
|
18
|
-
`cargo build --release --target=aarch64-apple-darwin`
|
19
|
-
`cargo build --release --target=x86_64-apple-darwin`
|
20
|
-
|
21
|
-
# Copy to target folder
|
22
|
-
`cp target/aarch64-apple-darwin/release/liby_rb.dylib target/release/`
|
23
|
-
end
|
24
|
-
|
25
|
-
task :clean do
|
26
|
-
`cargo clean`
|
27
|
-
end
|
28
|
-
|
29
|
-
task test: :spec
|
30
|
-
|
31
|
-
task :docs do
|
32
|
-
`yard server --reload`
|
33
|
-
end
|
34
|
-
|
35
|
-
RuboCop::RakeTask.new
|
36
|
-
|
37
|
-
YARD::Rake::YardocTask.new
|
38
|
-
|
39
|
-
Thermite::Tasks.new
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "y/rb"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|