diff options
author | Sam James <sam@gentoo.org> | 2023-03-31 02:37:51 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-03-31 18:59:32 +0100 |
commit | 1934e03b560e5b144fd42347e6362efb9c89c42b (patch) | |
tree | d9d77f42b1b2f4a24dce98a5bdb61514f5ff02ea /dev-ruby/websocket-driver | |
parent | app-emacs/flycheck: Keyword 32_p20230305-r1 arm64, #902873 (diff) | |
download | gentoo-1934e03b560e5b144fd42347e6362efb9c89c42b.tar.gz gentoo-1934e03b560e5b144fd42347e6362efb9c89c42b.tar.bz2 gentoo-1934e03b560e5b144fd42347e6362efb9c89c42b.zip |
dev-ruby/websocket-driver: EAPI 8, enable ruby32
Crank up to ruby32 by adding an upstream patch (now committed,
wasn't in the past when the each_ruby_test workaround was added
to 0.7.5). We could've just repeated the skip/quirk as was done
for ruby31, but no point if there's a fix we can pick up that's
been committed now.
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-ruby/websocket-driver')
-rw-r--r-- | dev-ruby/websocket-driver/files/websocket-driver-0.7.5-ruby32.patch | 125 | ||||
-rw-r--r-- | dev-ruby/websocket-driver/websocket-driver-0.7.5-r1.ebuild | 35 |
2 files changed, 160 insertions, 0 deletions
diff --git a/dev-ruby/websocket-driver/files/websocket-driver-0.7.5-ruby32.patch b/dev-ruby/websocket-driver/files/websocket-driver-0.7.5-ruby32.patch new file mode 100644 index 000000000000..e4f58e495cfd --- /dev/null +++ b/dev-ruby/websocket-driver/files/websocket-driver-0.7.5-ruby32.patch @@ -0,0 +1,125 @@ +https://github.com/faye/websocket-driver-ruby/commit/3a2931751c6893e312ee24d9c6392bd096a798fd + +From 3a2931751c6893e312ee24d9c6392bd096a798fd Mon Sep 17 00:00:00 2001 +From: James Coglan <jcoglan@gmail.com> +Date: Sat, 10 Sep 2022 15:37:55 +0100 +Subject: [PATCH] Fix handling of default ports on Ruby 3.1 + +--- a/lib/websocket/driver.rb ++++ b/lib/websocket/driver.rb +@@ -42,6 +42,7 @@ def Mask.mask(payload, mask) + end + + MAX_LENGTH = 0x3ffffff ++ PORTS = { 'ws' => 80, 'wss' => 443 } + STATES = [:connecting, :open, :closing, :closed] + + ConnectEvent = Struct.new(nil) +@@ -209,6 +210,14 @@ def self.encode(data, encoding = nil) + data.force_encoding(encoding) + end + ++ def self.host_header(uri) ++ host = uri.host ++ if uri.port and uri.port != PORTS[uri.scheme] ++ host += ":#{uri.port}" ++ end ++ host ++ end ++ + def self.validate_options(options, valid_keys) + options.keys.each do |key| + unless valid_keys.include?(key) +--- a/lib/websocket/driver/client.rb ++++ b/lib/websocket/driver/client.rb +@@ -23,11 +23,10 @@ def initialize(socket, options = {}) + raise URIError, "#{ socket.url } is not a valid WebSocket URL" + end + +- host = uri.host + (uri.port ? ":#{ uri.port }" : '') + path = (uri.path == '') ? '/' : uri.path + @pathname = path + (uri.query ? '?' + uri.query : '') + +- @headers['Host'] = host ++ @headers['Host'] = Driver.host_header(uri) + @headers['Upgrade'] = 'websocket' + @headers['Connection'] = 'Upgrade' + @headers['Sec-WebSocket-Key'] = @key +--- a/lib/websocket/driver/proxy.rb ++++ b/lib/websocket/driver/proxy.rb +@@ -4,8 +4,6 @@ class Driver + class Proxy + include EventEmitter + +- PORTS = { 'ws' => 80, 'wss' => 443 } +- + attr_reader :status, :headers + + def initialize(client, origin, options) +@@ -20,7 +18,7 @@ def initialize(client, origin, options) + @state = 0 + + @headers = Headers.new +- @headers['Host'] = @origin.host + (@origin.port ? ":#{ @origin.port }" : '') ++ @headers['Host'] = Driver.host_header(@origin) + @headers['Connection'] = 'keep-alive' + @headers['Proxy-Connection'] = 'keep-alive' + +--- a/spec/websocket/driver/client_spec.rb ++++ b/spec/websocket/driver/client_spec.rb +@@ -121,6 +121,54 @@ + end + end + ++ describe "with an explicit port" do ++ let(:url) { "ws://www.example.com:3000/socket" } ++ ++ it "includes the port in the Host header" do ++ expect(socket).to receive(:write).with( ++ "GET /socket HTTP/1.1\r\n" + ++ "Host: www.example.com:3000\r\n" + ++ "Upgrade: websocket\r\n" + ++ "Connection: Upgrade\r\n" + ++ "Sec-WebSocket-Key: 2vBVWg4Qyk3ZoM/5d3QD9Q==\r\n" + ++ "Sec-WebSocket-Version: 13\r\n" + ++ "\r\n") ++ driver.start ++ end ++ end ++ ++ describe "with a wss: URL" do ++ let(:url) { "wss://www.example.com/socket" } ++ ++ it "does not include the port in the Host header" do ++ expect(socket).to receive(:write).with( ++ "GET /socket HTTP/1.1\r\n" + ++ "Host: www.example.com\r\n" + ++ "Upgrade: websocket\r\n" + ++ "Connection: Upgrade\r\n" + ++ "Sec-WebSocket-Key: 2vBVWg4Qyk3ZoM/5d3QD9Q==\r\n" + ++ "Sec-WebSocket-Version: 13\r\n" + ++ "\r\n") ++ driver.start ++ end ++ end ++ ++ describe "with a wss: URL and explicit port" do ++ let(:url) { "wss://www.example.com:3000/socket" } ++ ++ it "includes the port in the Host header" do ++ expect(socket).to receive(:write).with( ++ "GET /socket HTTP/1.1\r\n" + ++ "Host: www.example.com:3000\r\n" + ++ "Upgrade: websocket\r\n" + ++ "Connection: Upgrade\r\n" + ++ "Sec-WebSocket-Key: 2vBVWg4Qyk3ZoM/5d3QD9Q==\r\n" + ++ "Sec-WebSocket-Version: 13\r\n" + ++ "\r\n") ++ driver.start ++ end ++ end ++ + describe "with custom headers" do + before do + driver.set_header "User-Agent", "Chrome" + diff --git a/dev-ruby/websocket-driver/websocket-driver-0.7.5-r1.ebuild b/dev-ruby/websocket-driver/websocket-driver-0.7.5-r1.ebuild new file mode 100644 index 000000000000..a9cd58bc570f --- /dev/null +++ b/dev-ruby/websocket-driver/websocket-driver-0.7.5-r1.ebuild @@ -0,0 +1,35 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +USE_RUBY="ruby27 ruby30 ruby31 ruby32" + +RUBY_FAKEGEM_RECIPE_TEST="rspec3" +RUBY_FAKEGEM_EXTRADOC="CHANGELOG.md README.md" + +RUBY_FAKEGEM_GEMSPEC="${PN}.gemspec" + +RUBY_FAKEGEM_EXTENSIONS=(ext/websocket-driver/extconf.rb) + +inherit ruby-fakegem + +DESCRIPTION="A complete implementation of the WebSocket protocols" +HOMEPAGE="https://github.com/faye/websocket-driver-ruby" +SRC_URI="https://github.com/faye/websocket-driver-ruby/archive/${PV}.tar.gz -> ${P}.tar.gz" +RUBY_S="${PN}-ruby-${PV}" + +LICENSE="Apache-2.0" +SLOT="0.7" +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86" +IUSE="" + +ruby_add_rdepend ">=dev-ruby/websocket-extensions-0.1.0" + +PATCHES=( + "${FILESDIR}"/${P}-ruby32.patch +) + +all_ruby_prepare() { + sed -i -e '/bundler/ s:^:#:' spec/spec_helper.rb || die +} |