y-rb 0.1.0
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 +7 -0
- data/.cargo/config.toml +5 -0
- data/.dockerignore +5 -0
- data/.editorconfig +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +23 -0
- data/.rustfmt.toml +75 -0
- data/.yardopts +2 -0
- data/Cargo.toml +21 -0
- data/Cross.toml +2 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +21 -0
- data/README.md +96 -0
- data/Rakefile +39 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docs/build.md +1 -0
- data/docs/decisions.md +64 -0
- data/docs/examples.md +16 -0
- data/ext/Rakefile +9 -0
- data/lib/y/array.rb +352 -0
- data/lib/y/doc.rb +217 -0
- data/lib/y/map.rb +200 -0
- data/lib/y/rb.rb +17 -0
- data/lib/y/text.rb +370 -0
- data/lib/y/transaction.rb +143 -0
- data/lib/y/version.rb +5 -0
- data/lib/y/xml.rb +846 -0
- data/lib/y.rb +4 -0
- data/lib/y_rb.so +0 -0
- data/src/lib.rs +248 -0
- data/src/util.rs +148 -0
- data/src/yarray.rs +184 -0
- data/src/ydoc.rs +65 -0
- data/src/ymap.rs +199 -0
- data/src/ytext.rs +204 -0
- data/src/ytransaction.rs +101 -0
- data/src/yxml.rs +550 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 10cd525c4f285fedd7ea5460790a0515bd15227d49606a8c283b313b9fdd233c
|
4
|
+
data.tar.gz: 8645608ebd5f936cb3eb11e16a1e8b6fde1874881990b7cd18eb1f1624d5f2af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b36dda334a509d2123430871c47f713852eea552f804db174c2ca2089b6184dacfe6c30641d0693bb4e58897c9659fc99279607498ffe3be44863b369d7080b
|
7
|
+
data.tar.gz: 3fe5990b463b06da580ada4705e011c84579e5b07eb5565bd15ca80b25a184ef6fac78db423a240521aa9c60313c08ef59e927ef3705897b84b4eacbce97b772
|
data/.cargo/config.toml
ADDED
data/.editorconfig
ADDED
@@ -0,0 +1,16 @@
|
|
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
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
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
ADDED
@@ -0,0 +1,75 @@
|
|
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
|
+
required_version = "1.4.37"
|
65
|
+
unstable_features = false
|
66
|
+
disable_all_formatting = false
|
67
|
+
skip_children = false
|
68
|
+
hide_parse_errors = false
|
69
|
+
error_on_line_overflow = false
|
70
|
+
error_on_unformatted = false
|
71
|
+
report_todo = "Never"
|
72
|
+
report_fixme = "Never"
|
73
|
+
ignore = []
|
74
|
+
emit_mode = "Files"
|
75
|
+
make_backup = false
|
data/.yardopts
ADDED
data/Cargo.toml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
[package]
|
2
|
+
name = "y-rb"
|
3
|
+
version = "0.1.0"
|
4
|
+
authors = ["Hannes Moser <box@hannesmoser.at>"]
|
5
|
+
edition = "2021"
|
6
|
+
homepage = "https://github.com/y-crdt/yrb"
|
7
|
+
repository = "https://github.com/y-crdt/yrb"
|
8
|
+
|
9
|
+
[dependencies]
|
10
|
+
lazy_static = "1.4.0"
|
11
|
+
rutie = "0.8.4"
|
12
|
+
yrs = "0.7.1"
|
13
|
+
lib0 = "0.7.1"
|
14
|
+
cross = "0.2.1"
|
15
|
+
|
16
|
+
[lib]
|
17
|
+
name = "y_rb"
|
18
|
+
crate-type = ["cdylib"]
|
19
|
+
|
20
|
+
[package.metadata.thermite]
|
21
|
+
github_releases = true
|
data/Cross.toml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
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
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
y-rb (0.1.0)
|
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.0)
|
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.3.1)
|
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.28.2)
|
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
|
43
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
44
|
+
ruby-progressbar (~> 1.7)
|
45
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
46
|
+
rubocop-ast (1.17.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
ADDED
@@ -0,0 +1,21 @@
|
|
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
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Yrb
|
2
|
+
|
3
|
+
> Attention: This gem isn't published yet, but you can play around with it.
|
4
|
+
> Feedback on the Ruby API is welcome 🙌.
|
5
|
+
|
6
|
+
Yrb is a Ruby binding for Y-CRDT. It provides distributed data types that enable
|
7
|
+
real-time collaboration between devices. Yrb can sync data with any other
|
8
|
+
platform that has a Y-CRDT binding, allowing for seamless cross-domain
|
9
|
+
communication.
|
10
|
+
|
11
|
+
The library is a thin wrapper around Yrs, taking advantage of the safety and
|
12
|
+
performance of Rust.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'y-rb'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle install
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install y-rb
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# creates a new document and text structure
|
34
|
+
local = Y::Doc.new
|
35
|
+
local_text = local.get_text("my text")
|
36
|
+
|
37
|
+
# add some data to the text structure
|
38
|
+
local_text.push("hello")
|
39
|
+
|
40
|
+
# create a remote doccument sharing the same text structure
|
41
|
+
remote = Y::Doc.new
|
42
|
+
remote_text = remote.get_text("my text")
|
43
|
+
|
44
|
+
# retrieve the current state of the remote document
|
45
|
+
remote_state = remote.state
|
46
|
+
|
47
|
+
# create an update for the remote document based on the current
|
48
|
+
# state of the remote document
|
49
|
+
update = local.diff(remote_state)
|
50
|
+
|
51
|
+
# apply update to remote document
|
52
|
+
remote.sync(update)
|
53
|
+
|
54
|
+
puts remote_text.to_s == local_text.to_s # true
|
55
|
+
```
|
56
|
+
|
57
|
+
More [examples](./docs/examples).
|
58
|
+
|
59
|
+
## Development
|
60
|
+
|
61
|
+
Make sure you have `cargo` available (2021 edition). The gem needs the lib to
|
62
|
+
be built every time when there is a change.
|
63
|
+
|
64
|
+
```bash
|
65
|
+
cargo build --release
|
66
|
+
```
|
67
|
+
|
68
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
69
|
+
run `rake spec` to run the tests. You can also run `bin/console` for an
|
70
|
+
interactive prompt that will allow you to experiment.
|
71
|
+
|
72
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
73
|
+
To release a new version, update the version number in `version.rb`, and then
|
74
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
75
|
+
push git commits and the created tag, and push the `.gem` file to
|
76
|
+
[rubygems.org](https://rubygems.org).
|
77
|
+
|
78
|
+
## Docs
|
79
|
+
|
80
|
+
You can run `yard` locally and open the docs with:
|
81
|
+
|
82
|
+
```bash
|
83
|
+
yard server
|
84
|
+
open "http://0.0.0.0:8808/"
|
85
|
+
```
|
86
|
+
|
87
|
+
## Decision log
|
88
|
+
|
89
|
+
For this `gem`, we maintain a [decision log](./docs/decisions.md). Please consult it
|
90
|
+
in case there is some ambiguity in terms of why certain implementation details
|
91
|
+
look as they are.
|
92
|
+
|
93
|
+
## License
|
94
|
+
|
95
|
+
The gem is available as open source under the terms of the
|
96
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
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
ADDED
@@ -0,0 +1,15 @@
|
|
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__)
|
data/bin/setup
ADDED
data/docs/build.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Build Instructions
|
data/docs/decisions.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Decision log
|
2
|
+
|
3
|
+
## 2022-05-12
|
4
|
+
|
5
|
+
### Transactions do not always commit automatically
|
6
|
+
|
7
|
+
In `yrs`, the lifetime of a transaction is determined automatically. This can
|
8
|
+
lead to an interesting situation in Ruby, where we attach a listener to receive
|
9
|
+
changes, never commit a transaction explicitly and where the transaction gets
|
10
|
+
dropped automatically. I believe we still maintain a pointer to the transaction
|
11
|
+
that no longer exists, and therefore we receive a segfault.
|
12
|
+
|
13
|
+
## 2022-05-12
|
14
|
+
|
15
|
+
### Add event-driven approach to receive changes
|
16
|
+
|
17
|
+
It is not clear if this ends up being the final API to receive changes, but
|
18
|
+
it is the one that is supported in one or the other way across all `yrs`
|
19
|
+
implementations. It might be beneficial to add a synchronous API in the future,
|
20
|
+
but this isn't supported right away. All common styles of closure like behavior
|
21
|
+
are supported: `Proc`, `Lambda` and `Block`.
|
22
|
+
|
23
|
+
## 2022-05-09
|
24
|
+
|
25
|
+
### Supported operations on data types are either read-only or mutable
|
26
|
+
|
27
|
+
In a meeting with the wider `y-crdt` group on May 6th, 2022, it became clear
|
28
|
+
that the cost of creating a new instance of a data type is common operation in
|
29
|
+
many languages (Python, Ruby, …), but it is not something we should to support.
|
30
|
+
This pattern leads to all sort of problems, mostly because it contradicts the
|
31
|
+
common usage pattern of replicating changes between two or more clients.
|
32
|
+
|
33
|
+
Instead, the API should be explicit about this fact and should not make it too
|
34
|
+
easy to do that.
|
35
|
+
|
36
|
+
## 2022-05-06
|
37
|
+
|
38
|
+
### Transactions are implicit by default
|
39
|
+
|
40
|
+
The developer should not be exposed to transactions until they need to
|
41
|
+
change the default logic in any way. If someone creates a structure and inserts,
|
42
|
+
removes, this should be part of the same transaction until stated otherwise.
|
43
|
+
|
44
|
+
### Synchronisation happens at the document level
|
45
|
+
|
46
|
+
It might be interesting to sync at a more granular level, but for the sake of
|
47
|
+
simplicity, the first iteration of this library will only support
|
48
|
+
synchronization of the complete document.
|
49
|
+
|
50
|
+
## 2022-05-05
|
51
|
+
|
52
|
+
### No direct exposure of internal API
|
53
|
+
|
54
|
+
The internal API (`y-crdt`) is subject to constant changes and does not
|
55
|
+
necessarily offer an idiomatic Ruby interface. Therefore, the public API of
|
56
|
+
`y-rb` does not follow the `y-crdt` API, but prefers familiar Ruby idioms when
|
57
|
+
possible and might even require libraries where it makes sense (e.g. `nokogiri` for XML).
|
58
|
+
|
59
|
+
### Rutie is a temporary dependency
|
60
|
+
|
61
|
+
The Ruby<->Rust binding feels immature. But it is not the goal of this project
|
62
|
+
to fix this immediately. The long-term vision is to replace this part by
|
63
|
+
something more lightweight and opinionated that could be part of the Rust
|
64
|
+
codebase of this project.
|
data/docs/examples.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Examples
|
2
|
+
|
3
|
+
> Usage patterns
|
4
|
+
|
5
|
+
## Send a full document update to a client
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
doc = Y::Doc.new
|
9
|
+
text = doc.get_text("about")
|
10
|
+
text << "My name is, my name is, my name is … Slim Shady"
|
11
|
+
|
12
|
+
zero = Y::Doc.new
|
13
|
+
update = doc.diff(zero.state)
|
14
|
+
|
15
|
+
transfer update
|
16
|
+
```
|