Class: Bundler::URI::RFC3986_Parser
- Inherits:
-
Object
- Object
- Bundler::URI::RFC3986_Parser
- Defined in:
- lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
Overview
:nodoc:
Constant Summary collapse
- RFC3986_URI =
Bundler::URI defined in RFC3986 this regexp is modified not to host is not empty string
/\A(?<Bundler::URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
- RFC3986_relative_ref =
/\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+)\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
- @@to_s =
Kernel.instance_method(:to_s)
Instance Attribute Summary collapse
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
-
#initialize ⇒ RFC3986_Parser
constructor
A new instance of RFC3986_Parser.
- #inspect ⇒ Object
-
#join(*uris) ⇒ Object
:nodoc:.
-
#parse(uri) ⇒ Object
:nodoc:.
-
#split(uri) ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ RFC3986_Parser
Returns a new instance of RFC3986_Parser.
10 11 12 |
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 10 def initialize @regexp = default_regexp.each_value(&:freeze).freeze end |
Instance Attribute Details
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
8 9 10 |
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 8 def regexp @regexp end |
Instance Method Details
#inspect ⇒ Object
93 94 95 |
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 93 def inspect @@to_s.bind_call(self) end |
#join(*uris) ⇒ Object
:nodoc:
87 88 89 90 |
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 87 def join(*uris) # :nodoc: uris[0] = convert_to_uri(uris[0]) uris.inject :merge end |
#parse(uri) ⇒ Object
:nodoc:
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 71 def parse(uri) # :nodoc: scheme, userinfo, host, port, registry, path, opaque, query, fragment = self.split(uri) scheme_list = Bundler::URI.scheme_list if scheme && scheme_list.include?(uc = scheme.upcase) scheme_list[uc].new(scheme, userinfo, host, port, registry, path, opaque, query, fragment, self) else Generic.new(scheme, userinfo, host, port, registry, path, opaque, query, fragment, self) end end |
#split(uri) ⇒ Object
:nodoc:
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb', line 14 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".freeze] scheme = m["scheme".freeze] opaque = m["path-rootless".freeze] if opaque opaque << "?#{query}" if query [ scheme, nil, # userinfo nil, # host nil, # port nil, # registry nil, # path opaque, nil, # query m["fragment".freeze] ] else # normal [ scheme, m["userinfo".freeze], m["host".freeze], m["port".freeze], nil, # registry (m["path-abempty".freeze] || m["path-absolute".freeze] || m["path-empty".freeze]), nil, # opaque query, m["fragment".freeze] ] end elsif m = RFC3986_relative_ref.match(uri) [ nil, # scheme m["userinfo".freeze], m["host".freeze], m["port".freeze], nil, # registry, (m["path-abempty".freeze] || m["path-absolute".freeze] || m["path-noscheme".freeze] || m["path-empty".freeze]), nil, # opaque m["query".freeze], m["fragment".freeze] ] else raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}" end end |