123456789_123456789_123456789_123456789_123456789_

Class: Bundler::URI::RFC3986_Parser

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newRFC3986_Parser

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 73

def initialize
  @regexp = default_regexp.each_value(&:freeze).freeze
end

Instance Attribute Details

#regexp (readonly)

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 71

attr_reader :regexp

Instance Method Details

#convert_to_uri(uri) (private)

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 194

def convert_to_uri(uri)
  if uri.is_a?(Bundler::URI::Generic)
    uri
  elsif uri = String.try_convert(uri)
    parse(uri)
  else
    raise ArgumentError,
      "bad argument (expected Bundler::URI object or Bundler::URI string)"
  end
end

#default_regexp (private)

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 180

def default_regexp # :nodoc:
  {
    SCHEME: %r[\A#{SCHEME}\z]o,
    USERINFO: %r[\A#{USERINFO}\z]o,
    HOST: %r[\A#{HOST}\z]o,
    ABS_PATH: %r[\A/#{SEG}*+\z]o,
    REL_PATH: %r[\A(?!/)#{SEG}++\z]o,
    QUERY: %r[\A(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+\z],
    FRAGMENT: %r[\A#{FRAGMENT}\z]o,
    OPAQUE: %r[\A(?:[^/].*)?\z],
    PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
  }
end

#escape(str, unsafe = nil)

Compatibility for RFC2396 parser

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 156

def escape(str, unsafe = nil) # :nodoc:
  warn "Bundler::URI::RFC3986_PARSER.escape is obsoleted. Use Bundler::URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
  unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
end

#extract(str, schemes = nil, &block)

Compatibility for RFC2396 parser

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 144

def extract(str, schemes = nil, &block) # :nodoc:
  warn "Bundler::URI::RFC3986_PARSER.extract is obsoleted. Use Bundler::URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
  RFC2396_PARSER.extract(str, schemes, &block)
end

#inspect

See additional method definition at line 169.

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 173

def inspect
  @@to_s.bind_call(self)
end

#join(*uris)

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 138

def join(*uris) # :nodoc:
  uris[0] = convert_to_uri(uris[0])
  uris.inject :merge
end

#make_regexp(schemes = nil)

Compatibility for RFC2396 parser

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 150

def make_regexp(schemes = nil) # :nodoc:
  warn "Bundler::URI::RFC3986_PARSER.make_regexp is obsoleted. Use Bundler::URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
  RFC2396_PARSER.make_regexp(schemes)
end

#parse(uri)

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 134

def parse(uri) # :nodoc:
  Bundler::URI.for(*self.split(uri), self)
end

#split(uri)

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 77

def split(uri) #:nodoc:
  begin
    uri = uri.to_str
  rescue NoMethodError
    raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
  end
  uri.ascii_only? or
    raise InvalidURIError, "Bundler::URI must be ascii only #{uri.dump}"
  if m = RFC3986_URI.match(uri)
    query = m["query"]
    scheme = m["scheme"]
    opaque = m["path-rootless"]
    if opaque
      opaque << "?#{query}" if query
      [ scheme,
        nil, # userinfo
        nil, # host
        nil, # port
        nil, # registry
        nil, # path
        opaque,
        nil, # query
        m["fragment"]
      ]
    else # normal
      [ scheme,
        m["userinfo"],
        m["host"],
        m["port"],
        nil, # registry
        (m["path-abempty"] ||
         m["path-absolute"] ||
         m["path-empty"]),
        nil, # opaque
        query,
        m["fragment"]
      ]
    end
  elsif m = RFC3986_relative_ref.match(uri)
    [ nil, # scheme
      m["userinfo"],
      m["host"],
      m["port"],
      nil, # registry,
      (m["path-abempty"] ||
       m["path-absolute"] ||
       m["path-noscheme"] ||
       m["path-empty"]),
      nil, # opaque
      m["query"],
      m["fragment"]
    ]
  else
    raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
  end
end

#unescape(str, escaped = nil)

Compatibility for RFC2396 parser

[ GitHub ]

  
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 162

def unescape(str, escaped = nil) # :nodoc:
  warn "Bundler::URI::RFC3986_PARSER.unescape is obsoleted. Use Bundler::URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
  escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
end