Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quash ruby 3.4 warnings #47

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/http/cookie.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# :markup: markdown
# frozen_string_literal: true
require 'http/cookie/version'
require 'http/cookie/uri_parser'
require 'time'
Expand Down Expand Up @@ -425,7 +426,7 @@ def domain= domain
# Returns the domain, with a dot prefixed only if the domain flag is
# on.
def dot_domain
@for_domain ? '.' << @domain : @domain
@for_domain ? (+'.') << @domain : @domain
end

# Returns the domain attribute value as a DomainName object.
Expand Down Expand Up @@ -595,7 +596,7 @@ def valid_for_uri?(uri)
# Returns a string for use in the Cookie header, i.e. `name=value`
# or `name="value"`.
def cookie_value
"#{@name}=#{Scanner.quote(@value)}"
+"#{@name}=#{Scanner.quote(@value)}"
end
alias to_s cookie_value

Expand Down
7 changes: 4 additions & 3 deletions lib/http/cookie/scanner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'http/cookie'
require 'strscan'
require 'time'
Expand All @@ -23,7 +24,7 @@ def initialize(string, logger = nil)
class << self
def quote(s)
return s unless s.match(RE_BAD_CHAR)
'"' << s.gsub(/([\\"])/, "\\\\\\1") << '"'
(+'"') << s.gsub(/([\\"])/, "\\\\\\1") << '"'
end
end

Expand All @@ -32,7 +33,7 @@ def skip_wsp
end

def scan_dquoted
''.tap { |s|
(+'').tap { |s|
case
when skip(/"/)
break
Expand All @@ -51,7 +52,7 @@ def scan_name
end

def scan_value(comma_as_separator = false)
''.tap { |s|
(+'').tap { |s|
case
when scan(/[^,;"]+/)
s << matched
Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Test
module Unit
module Assertions
def assert_warn(pattern, message = nil, &block)
class << (output = "")
class << (output = +"")
alias write <<
end
stderr, $stderr = $stderr, output
Expand Down
11 changes: 6 additions & 5 deletions test/test_http_cookie.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# frozen_string_literal: false
require File.expand_path('helper', File.dirname(__FILE__))
require 'psych' if !defined?(YAML) && RUBY_VERSION == "1.9.2"
require 'yaml'
Expand Down Expand Up @@ -757,7 +758,7 @@ def test_max_age=
assert_equal 12, cookie.max_age

cookie.max_age = -3
assert_equal -3, cookie.max_age
assert_equal(-3, cookie.max_age)
end

def test_session
Expand Down Expand Up @@ -1016,7 +1017,7 @@ def test_valid_for_uri?
'https://www.example.com/dir2/test.html',
]
},
HTTP::Cookie.parse('a4=b; domain=example.com; path=/dir2/',
HTTP::Cookie.parse('a3=b; domain=example.com; path=/dir2/',
URI('http://example.com/dir/file.html')).first => {
true => [
'https://example.com/dir2/test.html',
Expand Down Expand Up @@ -1044,7 +1045,7 @@ def test_valid_for_uri?
'file:///dir2/test.html',
]
},
HTTP::Cookie.parse('a4=b; secure',
HTTP::Cookie.parse('a5=b; secure',
URI('https://example.com/dir/file.html')).first => {
true => [
'https://example.com/dir/test.html',
Expand All @@ -1056,7 +1057,7 @@ def test_valid_for_uri?
'file:///dir2/test.html',
]
},
HTTP::Cookie.parse('a5=b',
HTTP::Cookie.parse('a6=b',
URI('https://example.com/')).first => {
true => [
'https://example.com',
Expand All @@ -1065,7 +1066,7 @@ def test_valid_for_uri?
'file:///',
]
},
HTTP::Cookie.parse('a6=b; path=/dir',
HTTP::Cookie.parse('a7=b; path=/dir',
'http://example.com/dir/file.html').first => {
true => [
'http://example.com/dir',
Expand Down
1 change: 1 addition & 0 deletions test/test_http_cookie_jar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: false
require File.expand_path('helper', File.dirname(__FILE__))
require 'tmpdir'

Expand Down