y-rb 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 816615480d692a2f998ac5d420e4d64ee578a5d351a556ca9e3cf7f93ffaf83f
4
- data.tar.gz: dc86328ef38d28fd5320e5ccec4f437e56c0efe8be1e9d5ecd1a74f41eb74df7
3
+ metadata.gz: 8640afd442488a57ecdf9c2e84f1f8fb707f533aebdc537a7b6d647635e50000
4
+ data.tar.gz: 173e07d6489afc556269c7740a42c9b741a477b04c10996e6c1a0669e9f51597
5
5
  SHA512:
6
- metadata.gz: 34a045a974e65d8418c76beb9dafdab4c7adb21e48bdd5404b5191480bb62499b5a080b2bae51219b75445caf24bfa1e292576aec833f9f51832c66beae2b3e7
7
- data.tar.gz: fb0fc2e505c889bfb38a15acbdea44dc18c947f19887e453a993973b5ae523a8dac7dd94605b777b9a10da18350614734ec43f6fe877485c75247d3206c40935
6
+ metadata.gz: 51eb175d76d66ae8401e2f9f7384d2460e9e629a954ca3d8013374f7c89ac9c75f91830ce7286bb1942b0c3106901ed04f3051f37c6255ef1cb928566329864e
7
+ data.tar.gz: 6f426990929b829c1e39054bfbcb373c983e30e56c9de402c7ce8f14f67d5d302666c5fa0b0527b95b8b8ff98fcaedaed28235887ac1050329b6e777f44dec92
data/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "y-rb"
3
- version = "0.1.2"
3
+ version = "0.1.3"
4
4
  authors = ["Hannes Moser <box@hannesmoser.at>", "Hannes Moser <hmoser@gitlab.com>"]
5
5
  edition = "2021"
6
6
  homepage = "https://github.com/y-crdt/yrb"
@@ -12,6 +12,15 @@ rutie = "0.8.4"
12
12
  yrs = "0.10.1"
13
13
  lib0 = "0.10.1" # must match yrs version
14
14
 
15
+ [target.aarch64-unknown-linux-musl.dependencies]
16
+ rutie = {version="0.8.4", features=["no-link"]}
17
+
18
+ [target.x86_64-unknown-linux-musl.dependencies]
19
+ rutie = {version="0.8.4", features=["no-link"]}
20
+
21
+ [target.aarch64-unknown-linux-gnu.dependencies]
22
+ rutie = {version="0.8.4", features=["no-link"]}
23
+
15
24
  [lib]
16
25
  name = "y_rb"
17
26
  crate-type = ["cdylib"]
data/Cross.toml ADDED
@@ -0,0 +1,17 @@
1
+ [build]
2
+
3
+ [build.dockerfile]
4
+ file = "./build/Dockerfile"
5
+
6
+ [build.env]
7
+ passthrough = [
8
+ "RUBY_VERSION"
9
+ ]
10
+
11
+ [target.aarch64-apple-darwin]
12
+
13
+ [target.x86_64-apple-darwin]
14
+
15
+ [target.x86_64-unknown-linux-gnu]
16
+
17
+ [target.x86_64-unknown-linux-musl]
data/Gemfile CHANGED
@@ -8,6 +8,6 @@ gemspec
8
8
  gem "github-markup"
9
9
  gem "redcarpet"
10
10
  gem "rspec", "~> 3.11.0"
11
- gem "rubocop", "~> 1.21"
12
- gem "rubocop-rspec", "~> 2.10.0"
11
+ gem "rubocop", "~> 1.31"
12
+ gem "rubocop-rspec", "~> 2.12.1"
13
13
  gem "yard"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- y-rb (0.1.1)
4
+ y-rb (0.1.3)
5
5
  rake (~> 13.0)
6
6
  rutie (~> 0.0.4)
7
7
  thermite (~> 0)
@@ -9,10 +9,21 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
+ activesupport (6.1.6.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
12
18
  ast (2.4.2)
19
+ concurrent-ruby (1.1.10)
13
20
  diff-lcs (1.5.0)
14
21
  github-markup (4.0.1)
22
+ i18n (1.12.0)
23
+ concurrent-ruby (~> 1.0)
24
+ json (2.6.2)
15
25
  minitar (0.9)
26
+ minitest (5.16.2)
16
27
  parallel (1.22.1)
17
28
  parser (3.1.2.0)
18
29
  ast (~> 2.4.1)
@@ -34,7 +45,8 @@ GEM
34
45
  diff-lcs (>= 1.2.0, < 2.0)
35
46
  rspec-support (~> 3.11.0)
36
47
  rspec-support (3.11.0)
37
- rubocop (1.30.0)
48
+ rubocop (1.31.2)
49
+ json (~> 2.3)
38
50
  parallel (~> 1.10)
39
51
  parser (>= 3.1.0.0)
40
52
  rainbow (>= 2.2.2, < 4.0)
@@ -43,10 +55,10 @@ GEM
43
55
  rubocop-ast (>= 1.18.0, < 2.0)
44
56
  ruby-progressbar (~> 1.7)
45
57
  unicode-display_width (>= 1.4.0, < 3.0)
46
- rubocop-ast (1.18.0)
58
+ rubocop-ast (1.19.1)
47
59
  parser (>= 3.1.1.0)
48
- rubocop-rspec (2.10.0)
49
- rubocop (~> 1.19)
60
+ rubocop-rspec (2.12.1)
61
+ rubocop (~> 1.31)
50
62
  ruby-progressbar (1.11.0)
51
63
  rutie (0.0.4)
52
64
  thermite (0.13.0)
@@ -54,20 +66,26 @@ GEM
54
66
  rake (>= 10)
55
67
  tomlrb (~> 1.2)
56
68
  tomlrb (1.3.0)
57
- unicode-display_width (2.1.0)
69
+ tzinfo (2.0.4)
70
+ concurrent-ruby (~> 1.0)
71
+ unicode-display_width (2.2.0)
58
72
  webrick (1.7.0)
59
- yard (0.9.27)
73
+ yard (0.9.28)
60
74
  webrick (~> 1.7.0)
75
+ zeitwerk (2.6.0)
61
76
 
62
77
  PLATFORMS
63
78
  arm64-darwin-21
79
+ x86_64-linux
64
80
 
65
81
  DEPENDENCIES
82
+ activesupport (~> 6.1.6.1)
66
83
  github-markup
84
+ minitar (~> 0.9)
67
85
  redcarpet
68
86
  rspec (~> 3.11.0)
69
- rubocop (~> 1.21)
70
- rubocop-rspec (~> 2.10.0)
87
+ rubocop (~> 1.31)
88
+ rubocop-rspec (~> 2.12.1)
71
89
  y-rb!
72
90
  yard
73
91
 
data/README.md CHANGED
@@ -24,10 +24,14 @@ Or install it yourself as:
24
24
 
25
25
  $ gem install y-rb
26
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.
27
+ > **⚠ WARNING: Partial support for pre-built binaries.**
28
+ > `y-rb` comes with experimental pre-built binaries for a few platforms, but it
29
+ > is not possible to support all targets right now. Please make sure there is an
30
+ > archive that matches the OS, CPU architecture, and Ruby version. You can find
31
+ > the assets listed with each [release](https://github.com/y-crdt/yrb/releases).
32
+ >
33
+ > If the platform is not listed, you need to add the latest stable Rust + Cargo
34
+ > to your build dependencies in order for `y-rb` to install properly.
31
35
 
32
36
  ## Usage
33
37
 
@@ -39,7 +43,7 @@ local_text = local.get_text("my text")
39
43
  # add some data to the text structure
40
44
  local_text.push("hello")
41
45
 
42
- # create a remote doccument sharing the same text structure
46
+ # create a remote document sharing the same text structure
43
47
  remote = Y::Doc.new
44
48
  remote_text = remote.get_text("my text")
45
49
 
data/build/Dockerfile ADDED
@@ -0,0 +1,18 @@
1
+ ARG CROSS_BASE_IMAGE
2
+ FROM $CROSS_BASE_IMAGE
3
+
4
+ ENV RUBY_VERSION=3.1.2
5
+
6
+ RUN apt-get update -yq && apt-get install -yq build-essential gnupg2 openssl ruby ruby-dev
7
+ RUN curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
8
+ RUN curl -L https://get.rvm.io | bash -s stable
9
+ RUN /bin/bash -l -c "rvm requirements"
10
+ RUN /bin/bash -l -c "rvm install 3.1.2"
11
+ RUN /bin/bash -l -c "rvm install 3.0.4"
12
+ RUN /bin/bash -l -c "rvm install 2.7.6"
13
+ RUN /bin/bash -l -c "rvm install 2.6.10"
14
+
15
+ COPY build/entrypoint.sh /
16
+ RUN chmod +x "/entrypoint.sh"
17
+
18
+ ENTRYPOINT ["/entrypoint.sh"]
data/build/build.rb ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "active_support/core_ext/string"
5
+ require "fileutils"
6
+ require "minitar"
7
+ require "zlib"
8
+
9
+ require_relative "../lib/y/version"
10
+
11
+ RUBIES = %w[2.6.10 2.7.6 3.0.4 3.1.2].freeze
12
+
13
+ # darwin20 = mac os 11.x
14
+ # darwin21 = mac os 12.x
15
+ # darwin22 = mac os 13.x
16
+ TARGETS = {
17
+ "aarch64-apple-darwin": {
18
+ cpu: "arm64",
19
+ os: "darwin21"
20
+ },
21
+ "aarch64-unknown-linux-gnu": {
22
+ cpu: "arm64",
23
+ os: "linux"
24
+ },
25
+ "aarch64-unknown-linux-musl": {
26
+ cpu: "arm64",
27
+ os: "linux-musl",
28
+ env: {
29
+ "RUSTFLAGS" => "\"-C target-feature=-crt-static\""
30
+ }
31
+ },
32
+ "x86_64-unknown-linux-gnu": {
33
+ cpu: "x86_64",
34
+ os: "linux"
35
+ },
36
+ "x86_64-unknown-linux-musl": {
37
+ cpu: "x86_64",
38
+ os: "linux-musl",
39
+ env: {
40
+ "RUSTFLAGS" => "\"-C target-feature=-crt-static\""
41
+ }
42
+ }
43
+ }.freeze
44
+
45
+ def build_lib(target, options, ruby_version) # rubocop:disable Metrics/MethodLength
46
+ env_vars = if !options.nil? && options.key?(:env)
47
+ target_env = target.to_s.underscore.upcase
48
+ options[:env]
49
+ .map { |env, value| "CARGO_TARGET_#{target_env}_#{env}=#{value}" }
50
+ .join(" ")
51
+ else
52
+ ""
53
+ end
54
+
55
+ cmd = [
56
+ "cargo clean",
57
+ "#{env_vars} RUBY_VERSION=#{ruby_version} cross build --target=#{target} --release"
58
+ ].join(" && ")
59
+
60
+ `#{cmd}`
61
+ end
62
+
63
+ def copy_lib(target)
64
+ path = "#{__dir__}/../target/#{target}/release"
65
+
66
+ file = Dir["#{path}/*{dylib,so}"].first
67
+
68
+ extension = File.extname(file)
69
+ dest = "#{path}/y_rb#{extension}"
70
+
71
+ FileUtils.cp(file, dest)
72
+
73
+ dest
74
+ end
75
+
76
+ # Build
77
+
78
+ FileUtils.rm_rf "#{__dir__}/out"
79
+
80
+ TARGETS.each do |target, options|
81
+ RUBIES.each do |ruby_version|
82
+ puts "Build: target=#{target}, ruby=#{ruby_version}"
83
+
84
+ version = Gem::Version.new(ruby_version)
85
+ version_segments = version.canonical_segments
86
+ ruby_version_string = "#{version_segments[0]}#{version_segments[1]}"
87
+
88
+ build_lib(target, options, ruby_version)
89
+ file = copy_lib(target)
90
+
91
+ raise "Build failed" if file.nil?
92
+
93
+ extension = File.extname(file)
94
+ dir = "#{__dir__}/out/y_rb-#{Y::VERSION}-ruby#{ruby_version_string}-#{options[:os]}-#{options[:cpu]}"
95
+ FileUtils.mkdir_p(dir)
96
+ FileUtils.cp(file, "#{dir}/y_rb#{extension}")
97
+
98
+ archive = "#{dir}/y_rb-#{Y::VERSION}-ruby#{ruby_version_string}-#{options[:os]}-#{options[:cpu]}.tar.gz"
99
+ Zlib::GzipWriter.open(archive) do |tgz|
100
+ Dir.chdir(dir) do
101
+ Archive::Tar::Minitar.pack(".", tgz)
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ /bin/bash -l -c "rvm --default use $RUBY_VERSION" && exec "$@"
data/docs/release.md CHANGED
@@ -5,5 +5,32 @@
5
5
  1. Make sure CI is green
6
6
  2. Update version in `Cargo.toml`
7
7
  3. Update version in `lib/y/version.rb`
8
- 4. Create a tag matching the version `git tag -a v0.1.1 -m "Release version v0.1.1"`
9
- 5. Push tag to GitLab repo
8
+ 4. Create a tag matching the version `git tag -a vx.x.x -m "Release version vx.x.x"`
9
+ 5. Push tag to GitHub repo: `git push vx.x.x`
10
+ 6. Create a GitHub release (requires GitHub CLI): `gh release create vx.x.x ./build/out/*/*.gz`
11
+ 7. Package and upload gem: `gem build && gem push y-rb-x.x.x.gem`
12
+
13
+ ## Cross-compile binaries (to be released as assets on GitHub)
14
+
15
+ There is a script in `./build` that automates a fair chunk of work, but it is
16
+ not bulletproof. I mainly use it to compile for arm64 platforms on my machine,
17
+ and then upload manually. Most binaries (especially x86) should come from CI.
18
+
19
+ It also includes a workaround for Alpine (popular in Docker images) what usually
20
+ requires to be a static lib.
21
+
22
+ Run the following script. It produces a bunch of archives in `./build/out/`.
23
+ You need to upload the produced assets manually after the GitHub release was
24
+ created.
25
+
26
+ ```bash
27
+ ./build/build.rb
28
+ ```
29
+
30
+ ## Future work
31
+
32
+ With this [PR](https://github.com/rubygems/rubygems/pull/5175) merged into
33
+ rubygems, we will most likely be able to rely on the extension to manage builds
34
+ for us in the future.
35
+
36
+ Pre-build binaries are not verified, and are inherently a security concern.
data/lib/y/rb.rb CHANGED
@@ -10,7 +10,17 @@ require_relative "version"
10
10
  require_relative "xml"
11
11
 
12
12
  module Y
13
- Rutie.new(:y_rb).init(
13
+ # support pre-built and local built libraries
14
+ lib_path = if Dir.exist?(File.join(__dir__, "..", "..", "target", "release"))
15
+ nil
16
+ else
17
+ File.join(__dir__, "..", "..")
18
+ end
19
+
20
+ Rutie.new(
21
+ :y_rb,
22
+ lib_path: lib_path
23
+ ).init(
14
24
  "Init_yrb",
15
25
  File.join(__dir__, "..")
16
26
  )
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.1.2"
4
+ VERSION = "0.1.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.1.2
4
+ version: 0.1.3
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-07-05 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 6.1.6.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 6.1.6.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
55
83
  description: Ruby bindings for yrs. Yrs "wires" is a Rust port of the Yjs framework.
56
84
  email:
57
85
  - hmoser@gitlab.com
@@ -68,6 +96,7 @@ files:
68
96
  - ".rustfmt.toml"
69
97
  - ".yardopts"
70
98
  - Cargo.toml
99
+ - Cross.toml
71
100
  - Gemfile
72
101
  - Gemfile.lock
73
102
  - LICENSE.txt
@@ -75,6 +104,9 @@ files:
75
104
  - Rakefile
76
105
  - bin/console
77
106
  - bin/setup
107
+ - build/Dockerfile
108
+ - build/build.rb
109
+ - build/entrypoint.sh
78
110
  - docs/decisions.md
79
111
  - docs/examples.md
80
112
  - docs/release.md
@@ -96,7 +128,6 @@ files:
96
128
  - src/ytext.rs
97
129
  - src/ytransaction.rs
98
130
  - src/yxml.rs
99
- - y-rb.gemspec
100
131
  homepage: https://github.com/y-crdt/yrb
101
132
  licenses:
102
133
  - MIT
data/y-rb.gemspec DELETED
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/y/version"
4
-
5
- # rubocop:disable Metrics/BlockLength
6
- Gem::Specification.new do |spec|
7
- spec.name = "y-rb"
8
- spec.version = Y::VERSION
9
- spec.authors = ["Hannes Moser"]
10
- spec.email = %w[hmoser@gitlab.com box@hannesmoser.at]
11
-
12
- spec.summary = "Ruby bindings for yrs"
13
- spec.description = "Ruby bindings for yrs. Yrs \"wires\" is a Rust port of the Yjs framework."
14
- spec.homepage = "https://github.com/y-crdt/yrb"
15
- spec.license = "MIT"
16
- spec.required_ruby_version = ">= 2.6.0"
17
-
18
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
-
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = "https://github.com/y-crdt/yrb"
22
- spec.metadata["documentation_uri"] = "https://y-crdt.github.io/yrb/"
23
-
24
- # Specify which files should be added to the gem when it is released.
25
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
- `git ls-files -z`.split("\x0").reject do |f|
28
- (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
29
- end
30
- end
31
-
32
- spec.bindir = "exe"
33
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
- spec.require_paths = ["lib"]
35
-
36
- spec.metadata["rubygems_mfa_required"] = "true"
37
-
38
- spec.add_dependency "rake", "~> 13.0"
39
- spec.add_dependency "rutie", "~> 0.0.4"
40
- spec.add_dependency "thermite", "~> 0"
41
-
42
- spec.extensions << "ext/Rakefile"
43
- end
44
- # rubocop:enable Metrics/BlockLength