Skip to content

Commit 340c965

Browse files
authored
Merge pull request #175 from nobu/doc-uri_parser
Update documents that used `URI::Parser`
2 parents 32a59fd + d2a79c6 commit 340c965

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

.rdoc_options

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ main_page: README.md
22
op_dir: _site
33
warn_missing_rdoc_ref: true
44
title: URI Documentation
5+
visibility: :private

lib/uri/common.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@ def self.scheme_list
159159
Schemes.list
160160
end
161161

162+
# :stopdoc:
162163
INITIAL_SCHEMES = scheme_list
163164
private_constant :INITIAL_SCHEMES
164165
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
166+
# :startdoc:
165167

166168
# Returns a new object constructed from the given +scheme+, +arguments+,
167169
# and +default+:
@@ -437,6 +439,8 @@ def self.decode_uri_component(str, enc=Encoding::UTF_8)
437439
_decode_uri_component(/%\h\h/, str, enc)
438440
end
439441

442+
# Returns a string derived from the given string +str+ with
443+
# URI-encoded characters matching +regexp+ according to +table+.
440444
def self._encode_uri_component(regexp, table, str, enc)
441445
str = str.to_s.dup
442446
if str.encoding != Encoding::ASCII_8BIT
@@ -451,6 +455,8 @@ def self._encode_uri_component(regexp, table, str, enc)
451455
end
452456
private_class_method :_encode_uri_component
453457

458+
# Returns a string decoding characters matching +regexp+ from the
459+
# given \URL-encoded string +str+.
454460
def self._decode_uri_component(regexp, str, enc)
455461
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
456462
str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)

lib/uri/generic.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def registry # :nodoc:
284284

285285
# Returns the parser to be used.
286286
#
287-
# Unless a URI::Parser is defined, DEFAULT_PARSER is used.
287+
# Unless the +parser+ is defined, DEFAULT_PARSER is used.
288288
#
289289
def parser
290290
if !defined?(@parser) || !@parser
@@ -315,7 +315,7 @@ def component
315315
end
316316

317317
#
318-
# Checks the scheme +v+ component against the URI::Parser Regexp for :SCHEME.
318+
# Checks the scheme +v+ component against the +parser+ Regexp for :SCHEME.
319319
#
320320
def check_scheme(v)
321321
if v && parser.regexp[:SCHEME] !~ v
@@ -385,7 +385,7 @@ def check_userinfo(user, password = nil)
385385

386386
#
387387
# Checks the user +v+ component for RFC2396 compliance
388-
# and against the URI::Parser Regexp for :USERINFO.
388+
# and against the +parser+ Regexp for :USERINFO.
389389
#
390390
# Can not have a registry or opaque component defined,
391391
# with a user component defined.
@@ -409,7 +409,7 @@ def check_user(v)
409409

410410
#
411411
# Checks the password +v+ component for RFC2396 compliance
412-
# and against the URI::Parser Regexp for :USERINFO.
412+
# and against the +parser+ Regexp for :USERINFO.
413413
#
414414
# Can not have a registry or opaque component defined,
415415
# with a user component defined.
@@ -586,7 +586,7 @@ def decoded_password
586586

587587
#
588588
# Checks the host +v+ component for RFC2396 compliance
589-
# and against the URI::Parser Regexp for :HOST.
589+
# and against the +parser+ Regexp for :HOST.
590590
#
591591
# Can not have a registry or opaque component defined,
592592
# with a host component defined.
@@ -675,7 +675,7 @@ def hostname=(v)
675675

676676
#
677677
# Checks the port +v+ component for RFC2396 compliance
678-
# and against the URI::Parser Regexp for :PORT.
678+
# and against the +parser+ Regexp for :PORT.
679679
#
680680
# Can not have a registry or opaque component defined,
681681
# with a port component defined.
@@ -748,7 +748,7 @@ def registry=(v) # :nodoc:
748748

749749
#
750750
# Checks the path +v+ component for RFC2396 compliance
751-
# and against the URI::Parser Regexp
751+
# and against the +parser+ Regexp
752752
# for :ABS_PATH and :REL_PATH.
753753
#
754754
# Can not have a opaque component defined,
@@ -853,7 +853,7 @@ def query=(v)
853853

854854
#
855855
# Checks the opaque +v+ component for RFC2396 compliance and
856-
# against the URI::Parser Regexp for :OPAQUE.
856+
# against the +parser+ Regexp for :OPAQUE.
857857
#
858858
# Can not have a host, port, user, or path component defined,
859859
# with an opaque component defined.
@@ -905,7 +905,7 @@ def opaque=(v)
905905
end
906906

907907
#
908-
# Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT.
908+
# Checks the fragment +v+ component against the +parser+ Regexp for :FRAGMENT.
909909
#
910910
#
911911
# == Args

lib/uri/rfc2396_parser.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class RFC2396_Parser
6767
#
6868
# == Synopsis
6969
#
70-
# URI::Parser.new([opts])
70+
# URI::RFC2396_Parser.new([opts])
7171
#
7272
# == Args
7373
#
@@ -86,7 +86,7 @@ class RFC2396_Parser
8686
#
8787
# == Examples
8888
#
89-
# p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
89+
# p = URI::RFC2396_Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
9090
# u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD>
9191
# URI.parse(u.to_s) #=> raises URI::InvalidURIError
9292
#
@@ -108,12 +108,12 @@ def initialize(opts = {})
108108

109109
# The Hash of patterns.
110110
#
111-
# See also URI::Parser.initialize_pattern.
111+
# See also #initialize_pattern.
112112
attr_reader :pattern
113113

114114
# The Hash of Regexp.
115115
#
116-
# See also URI::Parser.initialize_regexp.
116+
# See also #initialize_regexp.
117117
attr_reader :regexp
118118

119119
# Returns a split URI against +regexp[:ABS_URI]+.
@@ -202,8 +202,7 @@ def split(uri)
202202
#
203203
# == Usage
204204
#
205-
# p = URI::Parser.new
206-
# p.parse("ldap://ldap.example.com/dc=example?user=john")
205+
# URI::RFC2396_PARSER.parse("ldap://ldap.example.com/dc=example?user=john")
207206
# #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
208207
#
209208
def parse(uri)
@@ -244,7 +243,7 @@ def join(*uris)
244243
# If no +block+ given, then returns the result,
245244
# else it calls +block+ for each element in result.
246245
#
247-
# See also URI::Parser.make_regexp.
246+
# See also #make_regexp.
248247
#
249248
def extract(str, schemes = nil)
250249
if block_given?
@@ -524,6 +523,8 @@ def initialize_regexp(pattern)
524523
ret
525524
end
526525

526+
# Returns +uri+ as-is if it is URI, or convert it to URI if it is
527+
# a String.
527528
def convert_to_uri(uri)
528529
if uri.is_a?(URI::Generic)
529530
uri

0 commit comments

Comments
 (0)