Skip to content

Commit 5a9afbf

Browse files
rm155hsbt
authored andcommitted
Improve Ractor-compliance
1 parent ab8ee6f commit 5a9afbf

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

lib/uri/ftp.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class FTP < Generic
3939
# * "i" indicates a binary file (FTP command IMAGE)
4040
# * "d" indicates the contents of a directory should be displayed
4141
#
42-
TYPECODE = ['a', 'i', 'd'].freeze
42+
TYPECODE = ['a', 'i', 'd']
43+
Ractor.make_shareable(TYPECODE)
4344

4445
# Typecode prefix ";type=".
4546
TYPECODE_PREFIX = ';type='.freeze

lib/uri/ldap.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class LDAP < Generic
4747
SCOPE_ONE = 'one',
4848
SCOPE_SUB = 'sub',
4949
SCOPE_BASE = 'base',
50-
].freeze
50+
]
51+
Ractor.make_shareable(SCOPE) if defined?(Ractor)
5152

5253
#
5354
# == Description

lib/uri/rfc2396_parser.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,31 @@ module PATTERN
2525
# RFC 2373 (IPv6 Addressing Architecture)
2626

2727
# alpha = lowalpha | upalpha
28-
ALPHA = "a-zA-Z"
28+
ALPHA = "a-zA-Z".freeze
2929
# alphanum = alpha | digit
30-
ALNUM = "#{ALPHA}\\d"
30+
ALNUM = "#{ALPHA}\\d".freeze
3131

3232
# hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
3333
# "a" | "b" | "c" | "d" | "e" | "f"
34-
HEX = "a-fA-F\\d"
34+
HEX = "a-fA-F\\d".freeze
3535
# escaped = "%" hex hex
36-
ESCAPED = "%[#{HEX}]{2}"
36+
ESCAPED = "%[#{HEX}]{2}".freeze
3737
# mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
3838
# "(" | ")"
3939
# unreserved = alphanum | mark
40-
UNRESERVED = "\\-_.!~*'()#{ALNUM}"
40+
UNRESERVED = "\\-_.!~*'()#{ALNUM}".freeze
4141
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
4242
# "$" | ","
4343
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
4444
# "$" | "," | "[" | "]" (RFC 2732)
45-
RESERVED = ";/?:@&=+$,\\[\\]"
45+
RESERVED = ";/?:@&=+$,\\[\\]".freeze
4646

4747
# domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
48-
DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
48+
DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)".freeze
4949
# toplabel = alpha | alpha *( alphanum | "-" ) alphanum
50-
TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
50+
TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)".freeze
5151
# hostname = *( domainlabel "." ) toplabel [ "." ]
52-
HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?"
52+
HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?".freeze
5353

5454
# :startdoc:
5555
end # PATTERN
@@ -321,14 +321,13 @@ def unescape(str, escaped = @regexp[:ESCAPED])
321321
str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
322322
end
323323

324-
@@to_s = Kernel.instance_method(:to_s)
325-
if @@to_s.respond_to?(:bind_call)
324+
if UnboundMethod.method_defined?(:bind_call)
326325
def inspect
327-
@@to_s.bind_call(self)
326+
Kernel.instance_method(:to_s).bind_call(self)
328327
end
329328
else
330329
def inspect
331-
@@to_s.bind(self).call
330+
Kernel.instance_method(:to_s).bind(self).call
332331
end
333332
end
334333

lib/uri/rfc3986_parser.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,13 @@ def join(*uris) # :nodoc:
141141
uris.inject :merge
142142
end
143143

144-
@@to_s = Kernel.instance_method(:to_s)
145-
if @@to_s.respond_to?(:bind_call)
144+
if UnboundMethod.method_defined?(:bind_call)
146145
def inspect
147-
@@to_s.bind_call(self)
146+
Kernel.instance_method(:to_s).bind_call(self)
148147
end
149148
else
150149
def inspect
151-
@@to_s.bind(self).call
150+
Kernel.instance_method(:to_s).bind(self).call
152151
end
153152
end
154153

0 commit comments

Comments
 (0)