From 247e0e12164b495728c0e3deb41a82e32f28a9bc Mon Sep 17 00:00:00 2001 From: Florian Dejonckheere Date: Mon, 25 Mar 2024 08:41:38 +0200 Subject: [PATCH 1/5] Target Ruby 3.3 --- .github/workflows/test.yml | 2 +- .github/workflows/test_io_uring.yml | 2 +- .rubocop.yml | 4 ++-- README.md | 2 +- docs/advanced-io.md | 4 ++-- docs/readme.md | 2 +- test/helper.rb | 2 ++ 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf48e4b9..09c0b5e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - ruby: ['3.1', '3.2', 'head'] + ruby: ['3.1', '3.2', '3.3', 'head'] name: >- ${{matrix.os}}, ${{matrix.ruby}} diff --git a/.github/workflows/test_io_uring.yml b/.github/workflows/test_io_uring.yml index b7d3afcf..ec3fdc94 100644 --- a/.github/workflows/test_io_uring.yml +++ b/.github/workflows/test_io_uring.yml @@ -8,7 +8,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - ruby: ['3.1', '3.2', 'head'] + ruby: ['3.1', '3.2', '3.3', 'head'] name: >- ${{matrix.os}}, ${{matrix.ruby}} diff --git a/.rubocop.yml b/.rubocop.yml index c27956f9..13c77979 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 3.2 + TargetRubyVersion: 3.3 RubyInterpreters: - ruby Exclude: @@ -202,4 +202,4 @@ Style/SlicingWithRange: Style/RaiseArgs: Exclude: - - lib/polyphony/extensions/fiber.rb \ No newline at end of file + - lib/polyphony/extensions/fiber.rb diff --git a/README.md b/README.md index 4a6af0e9..cc3b68de 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ ## What is Polyphony? Polyphony is a library for building concurrent applications in Ruby. Polyphony -harnesses the power of [Ruby fibers](https://rubyapi.org/3.2/o/fiber) to provide +harnesses the power of [Ruby fibers](https://rubyapi.org/3.3/o/fiber) to provide a cooperative, sequential coroutine-based concurrency model. Under the hood, Polyphony uses [io_uring](https://unixism.net/loti/what_is_io_uring.html) or [libev](https://github.com/enki/libev) to maximize I/O performance. diff --git a/docs/advanced-io.md b/docs/advanced-io.md index 7de4d4d0..22919645 100644 --- a/docs/advanced-io.md +++ b/docs/advanced-io.md @@ -119,7 +119,7 @@ minimizing memory use and GC pressure. ## Compressing and decompressing in-flight data You might be familiar with Ruby's [zlib](https://github.com/ruby/zlib) gem (docs -[here](https://rubyapi.org/3.2/o/zlib)), which can be used to compress and +[here](https://rubyapi.org/3.3/o/zlib)), which can be used to compress and uncompress data using the popular gzip format. Imagine we want to implement an HTTP server that can serve files compressed using gzip: @@ -318,4 +318,4 @@ provided by Polyphony, which lets us write less code, have it run faster, have it run concurrently, and minimize memory allocations and pressure on the Ruby GC. Feel free to browse the [IO examples](https://github.com/digital-fabric/polyphony/tree/master/examples/io) -included in Polyphony. \ No newline at end of file +included in Polyphony. diff --git a/docs/readme.md b/docs/readme.md index ac8b8afb..47a6feb8 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -25,7 +25,7 @@ ## What is Polyphony? Polyphony is a library for building concurrent applications in Ruby. Polyphony -harnesses the power of [Ruby fibers](https://rubyapi.org/3.2/o/fiber) to provide +harnesses the power of [Ruby fibers](https://rubyapi.org/3.3/o/fiber) to provide a cooperative, sequential coroutine-based concurrency model. Under the hood, Polyphony uses [io_uring](https://unixism.net/loti/what_is_io_uring.html) or [libev](https://github.com/enki/libev) to maximize I/O performance. diff --git a/test/helper.rb b/test/helper.rb index 6d6ae3a8..0e58f820 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -46,6 +46,8 @@ def monotonic_clock end end +module MiniTest; end + class MiniTest::Test def setup # trace "* setup #{self.name}" From 23abc5ee94630b47d29a6deb8fd0239e7b2ccae3 Mon Sep 17 00:00:00 2001 From: Florian Dejonckheere Date: Mon, 25 Mar 2024 08:52:42 +0200 Subject: [PATCH 2/5] Update development dependencies --- .rubocop.yml | 1 + polyphony.gemspec | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 13c77979..cfcc79f5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,6 +9,7 @@ AllCops: - 'Gemfile*' - 'ext/**/*.rb' - lib/polyphony/adapters/irb.rb + NewCops: enable Style/LambdaCall: Enabled: false diff --git a/polyphony.gemspec b/polyphony.gemspec index 2a27afce..69b5ddc4 100644 --- a/polyphony.gemspec +++ b/polyphony.gemspec @@ -20,15 +20,15 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.required_ruby_version = '>= 3.1' - s.add_development_dependency 'rake-compiler', '1.2.1' - s.add_development_dependency 'minitest', '5.17.0' + s.add_development_dependency 'rake-compiler', '1.2.7' + s.add_development_dependency 'minitest', '5.22.3' s.add_development_dependency 'simplecov', '0.22.0' - s.add_development_dependency 'rubocop', '1.45.1' + s.add_development_dependency 'rubocop', '1.62.1' s.add_development_dependency 'pry', '0.14.2' - s.add_development_dependency 'msgpack', '1.6.0' + s.add_development_dependency 'msgpack', '1.7.2' s.add_development_dependency 'httparty', '0.21.0' - s.add_development_dependency 'localhost', '1.1.10' - s.add_development_dependency 'debug', '1.8.0' - s.add_development_dependency 'benchmark-ips', '2.10.0' + s.add_development_dependency 'localhost', '1.2.0' + s.add_development_dependency 'debug', '1.9.1' + s.add_development_dependency 'benchmark-ips', '2.13.0' end From b37a74fd60d1c7e3088de53985f882fd408e165a Mon Sep 17 00:00:00 2001 From: Florian Dejonckheere Date: Mon, 25 Mar 2024 09:01:03 +0200 Subject: [PATCH 3/5] Update Github actions --- .github/workflows/test.yml | 2 +- .github/workflows/test_io_uring.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09c0b5e3..7713db34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Setup machine - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/test_io_uring.yml b/.github/workflows/test_io_uring.yml index ec3fdc94..5b111cc2 100644 --- a/.github/workflows/test_io_uring.yml +++ b/.github/workflows/test_io_uring.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{matrix.os}} steps: - name: Checkout repository and submodules - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - name: Setup Ruby From 4c257f44eeb5ef950e04dd77a1bbdee5c40448c9 Mon Sep 17 00:00:00 2001 From: Florian Dejonckheere Date: Mon, 25 Mar 2024 08:38:42 +0200 Subject: [PATCH 4/5] Temporarily add bundled gems --- polyphony.gemspec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/polyphony.gemspec b/polyphony.gemspec index 69b5ddc4..2c851b4b 100644 --- a/polyphony.gemspec +++ b/polyphony.gemspec @@ -31,4 +31,10 @@ Gem::Specification.new do |s| s.add_development_dependency 'localhost', '1.2.0' s.add_development_dependency 'debug', '1.9.1' s.add_development_dependency 'benchmark-ips', '2.13.0' + + # FIXME: remove gems when all other dependencies have bundled them (not part of stdlib since Ruby 3.4) + s.add_development_dependency 'base64', '0.2.0' + s.add_development_dependency 'bigdecimal', '3.1.7' + s.add_development_dependency 'csv', '3.3.0' + s.add_development_dependency 'mutex_m', '0.2.0' end From c6cd182789dc0f6cc40f9755f698b72146bae568 Mon Sep 17 00:00:00 2001 From: Florian Dejonckheere Date: Mon, 25 Mar 2024 08:24:30 +0200 Subject: [PATCH 5/5] Support calling IO#readlines with chomp keyword argument --- lib/polyphony/extensions/io.rb | 4 ++-- test/test_io.rb | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/polyphony/extensions/io.rb b/lib/polyphony/extensions/io.rb index dbf315fb..f6a67e32 100644 --- a/lib/polyphony/extensions/io.rb +++ b/lib/polyphony/extensions/io.rb @@ -60,9 +60,9 @@ def read(name, length = nil, offset = nil, opt = EMPTY_HASH) end alias_method :orig_readlines, :readlines - def readlines(name, sep = $/, limit = nil, getline_args = EMPTY_HASH) + def readlines(name, sep = $/, limit = nil, getline_args = EMPTY_HASH, chomp: false) File.open(name, 'r') do |f| - f.readlines(sep, **getline_args) + f.readlines(sep, chomp: chomp, **getline_args) end end diff --git a/test/test_io.rb b/test/test_io.rb index 5b22471f..a7d7b730 100644 --- a/test/test_io.rb +++ b/test/test_io.rb @@ -642,6 +642,12 @@ def test_readlines assert_equal "end\n", lines[-1] end + def test_readlines_with_chomp + lines = IO.readlines(__FILE__, chomp: true) + assert_equal "# frozen_string_literal: true", lines[0] + assert_equal "end", lines[-1] + end + WRITE_DATA = "foo\nbar קוקו" def test_write_class_method