Skip to content
Open
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
3 changes: 2 additions & 1 deletion lib/uri/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class FTP < Generic
# * "i" indicates a binary file (FTP command IMAGE)
# * "d" indicates the contents of a directory should be displayed
#
TYPECODE = ['a', 'i', 'd'].freeze
TYPECODE = ['a', 'i', 'd']
Ractor.make_shareable(TYPECODE)

# Typecode prefix ";type=".
TYPECODE_PREFIX = ';type='.freeze
Expand Down
3 changes: 2 additions & 1 deletion lib/uri/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class LDAP < Generic
SCOPE_ONE = 'one',
SCOPE_SUB = 'sub',
SCOPE_BASE = 'base',
].freeze
]
Ractor.make_shareable(SCOPE) if defined?(Ractor)

#
# == Description
Expand Down
25 changes: 12 additions & 13 deletions lib/uri/rfc2396_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ module PATTERN
# RFC 2373 (IPv6 Addressing Architecture)

# alpha = lowalpha | upalpha
ALPHA = "a-zA-Z"
ALPHA = "a-zA-Z".freeze
# alphanum = alpha | digit
ALNUM = "#{ALPHA}\\d"
ALNUM = "#{ALPHA}\\d".freeze

# hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
# "a" | "b" | "c" | "d" | "e" | "f"
HEX = "a-fA-F\\d"
HEX = "a-fA-F\\d".freeze
# escaped = "%" hex hex
ESCAPED = "%[#{HEX}]{2}"
ESCAPED = "%[#{HEX}]{2}".freeze
# mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
# "(" | ")"
# unreserved = alphanum | mark
UNRESERVED = "\\-_.!~*'()#{ALNUM}"
UNRESERVED = "\\-_.!~*'()#{ALNUM}".freeze
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
# "$" | ","
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
# "$" | "," | "[" | "]" (RFC 2732)
RESERVED = ";/?:@&=+$,\\[\\]"
RESERVED = ";/?:@&=+$,\\[\\]".freeze

# domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)".freeze
# toplabel = alpha | alpha *( alphanum | "-" ) alphanum
TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)".freeze
# hostname = *( domainlabel "." ) toplabel [ "." ]
HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?"
HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?".freeze

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

@@to_s = Kernel.instance_method(:to_s)
if @@to_s.respond_to?(:bind_call)
if UnboundMethod.method_defined?(:bind_call)
def inspect
@@to_s.bind_call(self)
Kernel.instance_method(:to_s).bind_call(self)
end
else
def inspect
@@to_s.bind(self).call
Kernel.instance_method(:to_s).bind(self).call
end
end

Expand Down
7 changes: 3 additions & 4 deletions lib/uri/rfc3986_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@ def join(*uris) # :nodoc:
uris.inject :merge
end

@@to_s = Kernel.instance_method(:to_s)
if @@to_s.respond_to?(:bind_call)
if UnboundMethod.method_defined?(:bind_call)
def inspect
@@to_s.bind_call(self)
Kernel.instance_method(:to_s).bind_call(self)
end
else
def inspect
@@to_s.bind(self).call
Kernel.instance_method(:to_s).bind(self).call
end
end

Expand Down