uri 0.13.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f4eaea3d45b9a860a4a1765dfa211d195929e01ea90e2ff25405fea90948098
4
- data.tar.gz: 5f962ae3a2b0c56f589df823edf89560420d8c2dced50ac7332e5a6322a772bc
3
+ metadata.gz: 4d3b082505394be3f41eaa0d3a91a22ddf30e9064dc72c228fb46fb5131f2900
4
+ data.tar.gz: df272886d408cd1999654d23b1e3e7f6c9466e4e04b784bc462ed7d8ac609ba9
5
5
  SHA512:
6
- metadata.gz: 8fb0be9745374a552f34d58d834e206adabc9a81bfc15bc7179c4143b639f0f62dd73ab46637023147e10be72b61ffdb2b18ac32a697d185244026a51560dc54
7
- data.tar.gz: 6961a3339bfa178cd339a14828cbb4be6d79249fc1d262da0ea7d68095435efe801ef71642866ab0de2e7a5edc759a168e8b54a006f038e446d755c9781dbf49
6
+ metadata.gz: 5e6e478e4ea13c8436c8b51a3a67755de842ab718835ff8b3fcaa5520d77bbfdac83f7092b8d22dfe7e54ac33d1f21b8a1ab7c2dce0f8e73dde4f3fa7667dee2
7
+ data.tar.gz: 1cea8abe746b7ad37355e785ca627d6ddb86adbb565d3c6cd59ab44102d7dfa5c9efb75f9ca46fe8e3d9d400194f9571c259064f8828601f942054cdebd34f91
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ BSDL
2
+ COPYING
3
+ README.md
4
+ docs/
5
+ lib/
data/.rdoc_options ADDED
@@ -0,0 +1,5 @@
1
+ main_page: README.md
2
+ op_dir: _site
3
+ warn_missing_rdoc_ref: true
4
+ title: URI Documentation
5
+ visibility: :private
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
5
5
  are met:
6
6
  1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
7
+ notice, this list of conditions and the following disclaimer.
8
8
  2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
13
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![CI](https://github.com/ruby/uri/actions/workflows/test.yml/badge.svg)](https://github.com/ruby/uri/actions/workflows/test.yml)
4
4
  [![Yard Docs](https://img.shields.io/badge/docs-exist-blue.svg)](https://ruby.github.io/uri/)
5
5
 
6
- URI is a module providing classes to handle Uniform Resource Identifiers [RFC2396](http://tools.ietf.org/html/rfc2396).
6
+ URI is a module providing classes to handle Uniform Resource Identifiers [RFC3986](http://tools.ietf.org/html/rfc3986).
7
7
 
8
8
  ## Features
9
9
 
data/docs/kernel.rb ADDED
@@ -0,0 +1,2 @@
1
+ # :stopdoc:
2
+ module Kernel end
data/lib/uri/common.rb CHANGED
@@ -13,24 +13,54 @@ require_relative "rfc2396_parser"
13
13
  require_relative "rfc3986_parser"
14
14
 
15
15
  module URI
16
- include RFC2396_REGEXP
16
+ # The default parser instance for RFC 2396.
17
+ RFC2396_PARSER = RFC2396_Parser.new
18
+ Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
17
19
 
18
- REGEXP = RFC2396_REGEXP
19
- Parser = RFC2396_Parser
20
+ # The default parser instance for RFC 3986.
20
21
  RFC3986_PARSER = RFC3986_Parser.new
21
22
  Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
22
23
 
23
- # URI::Parser.new
24
- DEFAULT_PARSER = Parser.new
25
- DEFAULT_PARSER.pattern.each_pair do |sym, str|
26
- unless REGEXP::PATTERN.const_defined?(sym)
27
- REGEXP::PATTERN.const_set(sym, str)
24
+ # The default parser instance.
25
+ DEFAULT_PARSER = RFC3986_PARSER
26
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
27
+
28
+ # Set the default parser instance.
29
+ def self.parser=(parser = RFC3986_PARSER)
30
+ remove_const(:Parser) if defined?(::URI::Parser)
31
+ const_set("Parser", parser.class)
32
+
33
+ remove_const(:PARSER) if defined?(::URI::PARSER)
34
+ const_set("PARSER", parser)
35
+
36
+ remove_const(:REGEXP) if defined?(::URI::REGEXP)
37
+ remove_const(:PATTERN) if defined?(::URI::PATTERN)
38
+ if Parser == RFC2396_Parser
39
+ const_set("REGEXP", URI::RFC2396_REGEXP)
40
+ const_set("PATTERN", URI::RFC2396_REGEXP::PATTERN)
41
+ end
42
+
43
+ Parser.new.regexp.each_pair do |sym, str|
44
+ remove_const(sym) if const_defined?(sym, false)
45
+ const_set(sym, str)
28
46
  end
29
47
  end
30
- DEFAULT_PARSER.regexp.each_pair do |sym, str|
31
- const_set(sym, str)
48
+ self.parser = RFC3986_PARSER
49
+
50
+ def self.const_missing(const) # :nodoc:
51
+ if const == :REGEXP
52
+ warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
53
+ URI::RFC2396_REGEXP
54
+ elsif value = RFC2396_PARSER.regexp[const]
55
+ warn "URI::#{const} is obsolete. Use URI::RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
56
+ value
57
+ elsif value = RFC2396_Parser.const_get(const)
58
+ warn "URI::#{const} is obsolete. Use URI::RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
59
+ value
60
+ else
61
+ super
62
+ end
32
63
  end
33
- Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
34
64
 
35
65
  module Util # :nodoc:
36
66
  def make_components_hash(klass, array_hash)
@@ -64,7 +94,41 @@ module URI
64
94
  module_function :make_components_hash
65
95
  end
66
96
 
67
- module Schemes
97
+ module Schemes # :nodoc:
98
+ class << self
99
+ ReservedChars = ".+-"
100
+ EscapedChars = "\u01C0\u01C1\u01C2"
101
+ # Use Lo category chars as escaped chars for TruffleRuby, which
102
+ # does not allow Symbol categories as identifiers.
103
+
104
+ def escape(name)
105
+ unless name and name.ascii_only?
106
+ return nil
107
+ end
108
+ name.upcase.tr(ReservedChars, EscapedChars)
109
+ end
110
+
111
+ def unescape(name)
112
+ name.tr(EscapedChars, ReservedChars).encode(Encoding::US_ASCII).upcase
113
+ end
114
+
115
+ def find(name)
116
+ const_get(name, false) if name and const_defined?(name, false)
117
+ end
118
+
119
+ def register(name, klass)
120
+ unless scheme = escape(name)
121
+ raise ArgumentError, "invalid character as scheme - #{name}"
122
+ end
123
+ const_set(scheme, klass)
124
+ end
125
+
126
+ def list
127
+ constants.map { |name|
128
+ [unescape(name.to_s), const_get(name)]
129
+ }.to_h
130
+ end
131
+ end
68
132
  end
69
133
  private_constant :Schemes
70
134
 
@@ -77,7 +141,7 @@ module URI
77
141
  # Note that after calling String#upcase on +scheme+, it must be a valid
78
142
  # constant name.
79
143
  def self.register_scheme(scheme, klass)
80
- Schemes.const_set(scheme.to_s.upcase, klass)
144
+ Schemes.register(scheme, klass)
81
145
  end
82
146
 
83
147
  # Returns a hash of the defined schemes:
@@ -95,14 +159,14 @@ module URI
95
159
  #
96
160
  # Related: URI.register_scheme.
97
161
  def self.scheme_list
98
- Schemes.constants.map { |name|
99
- [name.to_s.upcase, Schemes.const_get(name)]
100
- }.to_h
162
+ Schemes.list
101
163
  end
102
164
 
165
+ # :stopdoc:
103
166
  INITIAL_SCHEMES = scheme_list
104
167
  private_constant :INITIAL_SCHEMES
105
168
  Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
169
+ # :startdoc:
106
170
 
107
171
  # Returns a new object constructed from the given +scheme+, +arguments+,
108
172
  # and +default+:
@@ -121,12 +185,10 @@ module URI
121
185
  # # => #<URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
122
186
  #
123
187
  def self.for(scheme, *arguments, default: Generic)
124
- const_name = scheme.to_s.upcase
188
+ const_name = Schemes.escape(scheme)
125
189
 
126
190
  uri_class = INITIAL_SCHEMES[const_name]
127
- uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
128
- Schemes.const_get(const_name, false)
129
- end
191
+ uri_class ||= Schemes.find(const_name)
130
192
  uri_class ||= default
131
193
 
132
194
  return uri_class.new(scheme, *arguments)
@@ -168,7 +230,7 @@ module URI
168
230
  # ["fragment", "top"]]
169
231
  #
170
232
  def self.split(uri)
171
- RFC3986_PARSER.split(uri)
233
+ PARSER.split(uri)
172
234
  end
173
235
 
174
236
  # Returns a new \URI object constructed from the given string +uri+:
@@ -178,11 +240,11 @@ module URI
178
240
  # URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
179
241
  # # => #<URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
180
242
  #
181
- # It's recommended to first ::escape string +uri+
243
+ # It's recommended to first URI::RFC2396_PARSER.escape string +uri+
182
244
  # if it may contain invalid URI characters.
183
245
  #
184
246
  def self.parse(uri)
185
- RFC3986_PARSER.parse(uri)
247
+ PARSER.parse(uri)
186
248
  end
187
249
 
188
250
  # Merges the given URI strings +str+
@@ -209,7 +271,7 @@ module URI
209
271
  # # => #<URI::HTTP http://example.com/foo/bar>
210
272
  #
211
273
  def self.join(*str)
212
- RFC3986_PARSER.join(*str)
274
+ DEFAULT_PARSER.join(*str)
213
275
  end
214
276
 
215
277
  #
@@ -238,7 +300,7 @@ module URI
238
300
  #
239
301
  def self.extract(str, schemes = nil, &block) # :nodoc:
240
302
  warn "URI.extract is obsolete", uplevel: 1 if $VERBOSE
241
- DEFAULT_PARSER.extract(str, schemes, &block)
303
+ PARSER.extract(str, schemes, &block)
242
304
  end
243
305
 
244
306
  #
@@ -275,14 +337,14 @@ module URI
275
337
  #
276
338
  def self.regexp(schemes = nil)# :nodoc:
277
339
  warn "URI.regexp is obsolete", uplevel: 1 if $VERBOSE
278
- DEFAULT_PARSER.make_regexp(schemes)
340
+ PARSER.make_regexp(schemes)
279
341
  end
280
342
 
281
343
  TBLENCWWWCOMP_ = {} # :nodoc:
282
344
  256.times do |i|
283
345
  TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
284
346
  end
285
- TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
347
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze # :nodoc:
286
348
  TBLENCWWWCOMP_[' '] = '+'
287
349
  TBLENCWWWCOMP_.freeze
288
350
  TBLDECWWWCOMP_ = {} # :nodoc:
@@ -380,6 +442,8 @@ module URI
380
442
  _decode_uri_component(/%\h\h/, str, enc)
381
443
  end
382
444
 
445
+ # Returns a string derived from the given string +str+ with
446
+ # URI-encoded characters matching +regexp+ according to +table+.
383
447
  def self._encode_uri_component(regexp, table, str, enc)
384
448
  str = str.to_s.dup
385
449
  if str.encoding != Encoding::ASCII_8BIT
@@ -394,6 +458,8 @@ module URI
394
458
  end
395
459
  private_class_method :_encode_uri_component
396
460
 
461
+ # Returns a string decoding characters matching +regexp+ from the
462
+ # given \URL-encoded string +str+.
397
463
  def self._decode_uri_component(regexp, str, enc)
398
464
  raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
399
465
  str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
@@ -832,6 +898,7 @@ module Kernel
832
898
  # Returns a \URI object derived from the given +uri+,
833
899
  # which may be a \URI string or an existing \URI object:
834
900
  #
901
+ # require 'uri'
835
902
  # # Returns a new URI.
836
903
  # uri = URI('http://github.com/ruby/ruby')
837
904
  # # => #<URI::HTTP http://github.com/ruby/ruby>
@@ -839,6 +906,8 @@ module Kernel
839
906
  # URI(uri)
840
907
  # # => #<URI::HTTP http://github.com/ruby/ruby>
841
908
  #
909
+ # You must require 'uri' to use this method.
910
+ #
842
911
  def URI(uri)
843
912
  if uri.is_a?(URI::Generic)
844
913
  uri
data/lib/uri/file.rb CHANGED
@@ -47,7 +47,7 @@ module URI
47
47
  # :path => '/ruby/src'})
48
48
  # uri2.to_s # => "file://host.example.com/ruby/src"
49
49
  #
50
- # uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')})
50
+ # uri3 = URI::File.build({:path => URI::RFC2396_PARSER.escape('/path/my file.txt')})
51
51
  # uri3.to_s # => "file:///path/my%20file.txt"
52
52
  #
53
53
  def self.build(args)
@@ -70,17 +70,17 @@ module URI
70
70
 
71
71
  # raise InvalidURIError
72
72
  def check_userinfo(user)
73
- raise URI::InvalidURIError, "can not set userinfo for file URI"
73
+ raise URI::InvalidURIError, "cannot set userinfo for file URI"
74
74
  end
75
75
 
76
76
  # raise InvalidURIError
77
77
  def check_user(user)
78
- raise URI::InvalidURIError, "can not set user for file URI"
78
+ raise URI::InvalidURIError, "cannot set user for file URI"
79
79
  end
80
80
 
81
81
  # raise InvalidURIError
82
82
  def check_password(user)
83
- raise URI::InvalidURIError, "can not set password for file URI"
83
+ raise URI::InvalidURIError, "cannot set password for file URI"
84
84
  end
85
85
 
86
86
  # do nothing
data/lib/uri/ftp.rb CHANGED
@@ -17,7 +17,7 @@ module URI
17
17
  # This class will be redesigned because of difference of implementations;
18
18
  # the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
19
19
  # is a good summary about the de facto spec.
20
- # http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
20
+ # https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04
21
21
  #
22
22
  class FTP < Generic
23
23
  # A Default port of 21 for URI::FTP.
data/lib/uri/generic.rb CHANGED
@@ -73,7 +73,7 @@ module URI
73
73
  #
74
74
  # At first, tries to create a new URI::Generic instance using
75
75
  # URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
76
- # then it does URI::Escape.escape all URI components and tries again.
76
+ # then it does URI::RFC2396_PARSER.escape all URI components and tries again.
77
77
  #
78
78
  def self.build2(args)
79
79
  begin
@@ -82,7 +82,7 @@ module URI
82
82
  if args.kind_of?(Array)
83
83
  return self.build(args.collect{|x|
84
84
  if x.is_a?(String)
85
- DEFAULT_PARSER.escape(x)
85
+ URI::RFC2396_PARSER.escape(x)
86
86
  else
87
87
  x
88
88
  end
@@ -91,7 +91,7 @@ module URI
91
91
  tmp = {}
92
92
  args.each do |key, value|
93
93
  tmp[key] = if value
94
- DEFAULT_PARSER.escape(value)
94
+ URI::RFC2396_PARSER.escape(value)
95
95
  else
96
96
  value
97
97
  end
@@ -126,9 +126,9 @@ module URI
126
126
  end
127
127
  end
128
128
  else
129
- component = self.class.component rescue ::URI::Generic::COMPONENT
129
+ component = self.component rescue ::URI::Generic::COMPONENT
130
130
  raise ArgumentError,
131
- "expected Array of or Hash of components of #{self.class} (#{component.join(', ')})"
131
+ "expected Array of or Hash of components of #{self} (#{component.join(', ')})"
132
132
  end
133
133
 
134
134
  tmp << nil
@@ -186,18 +186,18 @@ module URI
186
186
 
187
187
  if arg_check
188
188
  self.scheme = scheme
189
- self.userinfo = userinfo
190
189
  self.hostname = host
191
190
  self.port = port
191
+ self.userinfo = userinfo
192
192
  self.path = path
193
193
  self.query = query
194
194
  self.opaque = opaque
195
195
  self.fragment = fragment
196
196
  else
197
197
  self.set_scheme(scheme)
198
- self.set_userinfo(userinfo)
199
198
  self.set_host(host)
200
199
  self.set_port(port)
200
+ self.set_userinfo(userinfo)
201
201
  self.set_path(path)
202
202
  self.query = query
203
203
  self.set_opaque(opaque)
@@ -284,7 +284,7 @@ module URI
284
284
 
285
285
  # Returns the parser to be used.
286
286
  #
287
- # Unless a URI::Parser is defined, DEFAULT_PARSER is used.
287
+ # Unless the +parser+ is defined, DEFAULT_PARSER is used.
288
288
  #
289
289
  def parser
290
290
  if !defined?(@parser) || !@parser
@@ -315,7 +315,7 @@ module URI
315
315
  end
316
316
 
317
317
  #
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.
319
319
  #
320
320
  def check_scheme(v)
321
321
  if v && parser.regexp[:SCHEME] !~ v
@@ -385,7 +385,7 @@ module URI
385
385
 
386
386
  #
387
387
  # 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.
389
389
  #
390
390
  # Can not have a registry or opaque component defined,
391
391
  # with a user component defined.
@@ -393,7 +393,7 @@ module URI
393
393
  def check_user(v)
394
394
  if @opaque
395
395
  raise InvalidURIError,
396
- "can not set user with opaque"
396
+ "cannot set user with opaque"
397
397
  end
398
398
 
399
399
  return v unless v
@@ -409,7 +409,7 @@ module URI
409
409
 
410
410
  #
411
411
  # 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.
413
413
  #
414
414
  # Can not have a registry or opaque component defined,
415
415
  # with a user component defined.
@@ -417,7 +417,7 @@ module URI
417
417
  def check_password(v, user = @user)
418
418
  if @opaque
419
419
  raise InvalidURIError,
420
- "can not set password with opaque"
420
+ "cannot set password with opaque"
421
421
  end
422
422
  return v unless v
423
423
 
@@ -511,7 +511,7 @@ module URI
511
511
  user, password = split_userinfo(user)
512
512
  end
513
513
  @user = user
514
- @password = password if password
514
+ @password = password
515
515
 
516
516
  [@user, @password]
517
517
  end
@@ -522,7 +522,7 @@ module URI
522
522
  # See also URI::Generic.user=.
523
523
  #
524
524
  def set_user(v)
525
- set_userinfo(v, @password)
525
+ set_userinfo(v, nil)
526
526
  v
527
527
  end
528
528
  protected :set_user
@@ -574,6 +574,12 @@ module URI
574
574
  @password
575
575
  end
576
576
 
577
+ # Returns the authority info (array of user, password, host and
578
+ # port), if any is set. Or returns +nil+.
579
+ def authority
580
+ return @user, @password, @host, @port if @user || @password || @host || @port
581
+ end
582
+
577
583
  # Returns the user component after URI decoding.
578
584
  def decoded_user
579
585
  URI.decode_uri_component(@user) if @user
@@ -586,7 +592,7 @@ module URI
586
592
 
587
593
  #
588
594
  # Checks the host +v+ component for RFC2396 compliance
589
- # and against the URI::Parser Regexp for :HOST.
595
+ # and against the +parser+ Regexp for :HOST.
590
596
  #
591
597
  # Can not have a registry or opaque component defined,
592
598
  # with a host component defined.
@@ -596,7 +602,7 @@ module URI
596
602
 
597
603
  if @opaque
598
604
  raise InvalidURIError,
599
- "can not set host with registry or opaque"
605
+ "cannot set host with registry or opaque"
600
606
  elsif parser.regexp[:HOST] !~ v
601
607
  raise InvalidComponentError,
602
608
  "bad component(expected host component): #{v}"
@@ -615,6 +621,13 @@ module URI
615
621
  end
616
622
  protected :set_host
617
623
 
624
+ # Protected setter for the authority info (+user+, +password+, +host+
625
+ # and +port+). If +port+ is +nil+, +default_port+ will be set.
626
+ #
627
+ protected def set_authority(user, password, host, port = nil)
628
+ @user, @password, @host, @port = user, password, host, port || self.default_port
629
+ end
630
+
618
631
  #
619
632
  # == Args
620
633
  #
@@ -639,6 +652,7 @@ module URI
639
652
  def host=(v)
640
653
  check_host(v)
641
654
  set_host(v)
655
+ set_userinfo(nil)
642
656
  v
643
657
  end
644
658
 
@@ -675,7 +689,7 @@ module URI
675
689
 
676
690
  #
677
691
  # Checks the port +v+ component for RFC2396 compliance
678
- # and against the URI::Parser Regexp for :PORT.
692
+ # and against the +parser+ Regexp for :PORT.
679
693
  #
680
694
  # Can not have a registry or opaque component defined,
681
695
  # with a port component defined.
@@ -685,7 +699,7 @@ module URI
685
699
 
686
700
  if @opaque
687
701
  raise InvalidURIError,
688
- "can not set port with registry or opaque"
702
+ "cannot set port with registry or opaque"
689
703
  elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
690
704
  raise InvalidComponentError,
691
705
  "bad component(expected port component): #{v.inspect}"
@@ -729,26 +743,27 @@ module URI
729
743
  def port=(v)
730
744
  check_port(v)
731
745
  set_port(v)
746
+ set_userinfo(nil)
732
747
  port
733
748
  end
734
749
 
735
750
  def check_registry(v) # :nodoc:
736
- raise InvalidURIError, "can not set registry"
751
+ raise InvalidURIError, "cannot set registry"
737
752
  end
738
753
  private :check_registry
739
754
 
740
- def set_registry(v) #:nodoc:
741
- raise InvalidURIError, "can not set registry"
755
+ def set_registry(v) # :nodoc:
756
+ raise InvalidURIError, "cannot set registry"
742
757
  end
743
758
  protected :set_registry
744
759
 
745
- def registry=(v)
746
- raise InvalidURIError, "can not set registry"
760
+ def registry=(v) # :nodoc:
761
+ raise InvalidURIError, "cannot set registry"
747
762
  end
748
763
 
749
764
  #
750
765
  # Checks the path +v+ component for RFC2396 compliance
751
- # and against the URI::Parser Regexp
766
+ # and against the +parser+ Regexp
752
767
  # for :ABS_PATH and :REL_PATH.
753
768
  #
754
769
  # Can not have a opaque component defined,
@@ -853,7 +868,7 @@ module URI
853
868
 
854
869
  #
855
870
  # Checks the opaque +v+ component for RFC2396 compliance and
856
- # against the URI::Parser Regexp for :OPAQUE.
871
+ # against the +parser+ Regexp for :OPAQUE.
857
872
  #
858
873
  # Can not have a host, port, user, or path component defined,
859
874
  # with an opaque component defined.
@@ -866,7 +881,7 @@ module URI
866
881
  # hier_part = ( net_path | abs_path ) [ "?" query ]
867
882
  if @host || @port || @user || @path # userinfo = @user + ':' + @password
868
883
  raise InvalidURIError,
869
- "can not set opaque with host, port, userinfo or path"
884
+ "cannot set opaque with host, port, userinfo or path"
870
885
  elsif v && parser.regexp[:OPAQUE] !~ v
871
886
  raise InvalidComponentError,
872
887
  "bad component(expected opaque component): #{v}"
@@ -905,7 +920,7 @@ module URI
905
920
  end
906
921
 
907
922
  #
908
- # Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT.
923
+ # Checks the fragment +v+ component against the +parser+ Regexp for :FRAGMENT.
909
924
  #
910
925
  #
911
926
  # == Args
@@ -945,7 +960,7 @@ module URI
945
960
  # == Description
946
961
  #
947
962
  # URI has components listed in order of decreasing significance from left to right,
948
- # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
963
+ # see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3.
949
964
  #
950
965
  # == Usage
951
966
  #
@@ -1121,7 +1136,7 @@ module URI
1121
1136
 
1122
1137
  base = self.dup
1123
1138
 
1124
- authority = rel.userinfo || rel.host || rel.port
1139
+ authority = rel.authority
1125
1140
 
1126
1141
  # RFC2396, Section 5.2, 2)
1127
1142
  if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@@ -1133,17 +1148,14 @@ module URI
1133
1148
  base.fragment=(nil)
1134
1149
 
1135
1150
  # RFC2396, Section 5.2, 4)
1136
- if !authority
1137
- base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
1138
- else
1139
- # RFC2396, Section 5.2, 4)
1140
- base.set_path(rel.path) if rel.path
1151
+ if authority
1152
+ base.set_authority(*authority)
1153
+ base.set_path(rel.path)
1154
+ elsif base.path && rel.path
1155
+ base.set_path(merge_path(base.path, rel.path))
1141
1156
  end
1142
1157
 
1143
1158
  # RFC2396, Section 5.2, 7)
1144
- base.set_userinfo(rel.userinfo) if rel.userinfo
1145
- base.set_host(rel.host) if rel.host
1146
- base.set_port(rel.port) if rel.port
1147
1159
  base.query = rel.query if rel.query
1148
1160
  base.fragment=(rel.fragment) if rel.fragment
1149
1161
 
@@ -1235,7 +1247,7 @@ module URI
1235
1247
  return rel, rel
1236
1248
  end
1237
1249
 
1238
- # you can modify `rel', but can not `oth'.
1250
+ # you can modify `rel', but cannot `oth'.
1239
1251
  return oth, rel
1240
1252
  end
1241
1253
  private :route_from0
@@ -1260,7 +1272,7 @@ module URI
1260
1272
  # #=> #<URI::Generic /main.rbx?page=1>
1261
1273
  #
1262
1274
  def route_from(oth)
1263
- # you can modify `rel', but can not `oth'.
1275
+ # you can modify `rel', but cannot `oth'.
1264
1276
  begin
1265
1277
  oth, rel = route_from0(oth)
1266
1278
  rescue
@@ -1364,6 +1376,9 @@ module URI
1364
1376
  str << ':'
1365
1377
  str << @port.to_s
1366
1378
  end
1379
+ if (@host || @port) && !@path.empty? && !@path.start_with?('/')
1380
+ str << '/'
1381
+ end
1367
1382
  str << @path
1368
1383
  if @query
1369
1384
  str << '?'
@@ -1389,29 +1404,18 @@ module URI
1389
1404
  end
1390
1405
  end
1391
1406
 
1407
+ # Returns the hash value.
1392
1408
  def hash
1393
1409
  self.component_ary.hash
1394
1410
  end
1395
1411
 
1412
+ # Compares with _oth_ for Hash.
1396
1413
  def eql?(oth)
1397
1414
  self.class == oth.class &&
1398
1415
  parser == oth.parser &&
1399
1416
  self.component_ary.eql?(oth.component_ary)
1400
1417
  end
1401
1418
 
1402
- =begin
1403
-
1404
- --- URI::Generic#===(oth)
1405
-
1406
- =end
1407
- # def ===(oth)
1408
- # raise NotImplementedError
1409
- # end
1410
-
1411
- =begin
1412
- =end
1413
-
1414
-
1415
1419
  # Returns an Array of the components defined from the COMPONENT Array.
1416
1420
  def component_ary
1417
1421
  component.collect do |x|
@@ -1448,7 +1452,7 @@ module URI
1448
1452
  end
1449
1453
  end
1450
1454
 
1451
- def inspect
1455
+ def inspect # :nodoc:
1452
1456
  "#<#{self.class} #{self}>"
1453
1457
  end
1454
1458
 
@@ -1536,7 +1540,7 @@ module URI
1536
1540
  else
1537
1541
  unless proxy_uri = env[name]
1538
1542
  if proxy_uri = env[name.upcase]
1539
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
1543
+ warn 'The environment variable HTTP_PROXY is discouraged. Please use http_proxy instead.', uplevel: 1
1540
1544
  end
1541
1545
  end
1542
1546
  end
data/lib/uri/http.rb CHANGED
@@ -61,6 +61,18 @@ module URI
61
61
  super(tmp)
62
62
  end
63
63
 
64
+ # Do not allow empty host names, as they are not allowed by RFC 3986.
65
+ def check_host(v)
66
+ ret = super
67
+
68
+ if ret && v.empty?
69
+ raise InvalidComponentError,
70
+ "bad component(expected host component): #{v}"
71
+ end
72
+
73
+ ret
74
+ end
75
+
64
76
  #
65
77
  # == Description
66
78
  #
@@ -85,7 +97,7 @@ module URI
85
97
  # == Description
86
98
  #
87
99
  # Returns the authority for an HTTP uri, as defined in
88
- # https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
100
+ # https://www.rfc-editor.org/rfc/rfc3986#section-3.2.
89
101
  #
90
102
  #
91
103
  # Example:
@@ -106,7 +118,7 @@ module URI
106
118
  # == Description
107
119
  #
108
120
  # Returns the origin for an HTTP uri, as defined in
109
- # https://datatracker.ietf.org/doc/html/rfc6454.
121
+ # https://www.rfc-editor.org/rfc/rfc6454.
110
122
  #
111
123
  #
112
124
  # Example:
@@ -67,7 +67,7 @@ module URI
67
67
  #
68
68
  # == Synopsis
69
69
  #
70
- # URI::Parser.new([opts])
70
+ # URI::RFC2396_Parser.new([opts])
71
71
  #
72
72
  # == Args
73
73
  #
@@ -86,7 +86,7 @@ module URI
86
86
  #
87
87
  # == Examples
88
88
  #
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})")
90
90
  # u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD>
91
91
  # URI.parse(u.to_s) #=> raises URI::InvalidURIError
92
92
  #
@@ -108,12 +108,12 @@ module URI
108
108
 
109
109
  # The Hash of patterns.
110
110
  #
111
- # See also URI::Parser.initialize_pattern.
111
+ # See also #initialize_pattern.
112
112
  attr_reader :pattern
113
113
 
114
114
  # The Hash of Regexp.
115
115
  #
116
- # See also URI::Parser.initialize_regexp.
116
+ # See also #initialize_regexp.
117
117
  attr_reader :regexp
118
118
 
119
119
  # Returns a split URI against +regexp[:ABS_URI]+.
@@ -140,11 +140,11 @@ module URI
140
140
 
141
141
  if !scheme
142
142
  raise InvalidURIError,
143
- "bad URI(absolute but no scheme): #{uri}"
143
+ "bad URI (absolute but no scheme): #{uri}"
144
144
  end
145
145
  if !opaque && (!path && (!host && !registry))
146
146
  raise InvalidURIError,
147
- "bad URI(absolute but no path): #{uri}"
147
+ "bad URI (absolute but no path): #{uri}"
148
148
  end
149
149
 
150
150
  when @regexp[:REL_URI]
@@ -173,7 +173,7 @@ module URI
173
173
  # server = [ [ userinfo "@" ] hostport ]
174
174
 
175
175
  else
176
- raise InvalidURIError, "bad URI(is not URI?): #{uri}"
176
+ raise InvalidURIError, "bad URI (is not URI?): #{uri}"
177
177
  end
178
178
 
179
179
  path = '' if !path && !opaque # (see RFC2396 Section 5.2)
@@ -202,8 +202,7 @@ module URI
202
202
  #
203
203
  # == Usage
204
204
  #
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")
207
206
  # #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
208
207
  #
209
208
  def parse(uri)
@@ -244,7 +243,7 @@ module URI
244
243
  # If no +block+ given, then returns the result,
245
244
  # else it calls +block+ for each element in result.
246
245
  #
247
- # See also URI::Parser.make_regexp.
246
+ # See also #make_regexp.
248
247
  #
249
248
  def extract(str, schemes = nil)
250
249
  if block_given?
@@ -263,7 +262,7 @@ module URI
263
262
  unless schemes
264
263
  @regexp[:ABS_URI_REF]
265
264
  else
266
- /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
265
+ /(?=(?i:#{Regexp.union(*schemes).source}):)#{@pattern[:X_ABS_URI]}/x
267
266
  end
268
267
  end
269
268
 
@@ -321,14 +320,14 @@ module URI
321
320
  str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
322
321
  end
323
322
 
324
- @@to_s = Kernel.instance_method(:to_s)
325
- if @@to_s.respond_to?(:bind_call)
326
- def inspect
327
- @@to_s.bind_call(self)
323
+ TO_S = Kernel.instance_method(:to_s) # :nodoc:
324
+ if TO_S.respond_to?(:bind_call)
325
+ def inspect # :nodoc:
326
+ TO_S.bind_call(self)
328
327
  end
329
328
  else
330
- def inspect
331
- @@to_s.bind(self).call
329
+ def inspect # :nodoc:
330
+ TO_S.bind(self).call
332
331
  end
333
332
  end
334
333
 
@@ -524,6 +523,8 @@ module URI
524
523
  ret
525
524
  end
526
525
 
526
+ # Returns +uri+ as-is if it is URI, or convert it to URI if it is
527
+ # a String.
527
528
  def convert_to_uri(uri)
528
529
  if uri.is_a?(URI::Generic)
529
530
  uri
@@ -536,4 +537,11 @@ module URI
536
537
  end
537
538
 
538
539
  end # class Parser
540
+
541
+ # Backward compatibility for URI::REGEXP::PATTERN::*
542
+ RFC2396_Parser.new.pattern.each_pair do |sym, str|
543
+ unless RFC2396_REGEXP::PATTERN.const_defined?(sym, false)
544
+ RFC2396_REGEXP::PATTERN.const_set(sym, str)
545
+ end
546
+ end
539
547
  end # module URI
@@ -78,7 +78,7 @@ module URI
78
78
  begin
79
79
  uri = uri.to_str
80
80
  rescue NoMethodError
81
- raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
81
+ raise InvalidURIError, "bad URI (is not URI?): #{uri.inspect}"
82
82
  end
83
83
  uri.ascii_only? or
84
84
  raise InvalidURIError, "URI must be ascii only #{uri.dump}"
@@ -127,7 +127,7 @@ module URI
127
127
  m["fragment"]
128
128
  ]
129
129
  else
130
- raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
130
+ raise InvalidURIError, "bad URI (is not URI?): #{uri.inspect}"
131
131
  end
132
132
  end
133
133
 
@@ -135,12 +135,35 @@ module URI
135
135
  URI.for(*self.split(uri), self)
136
136
  end
137
137
 
138
-
139
138
  def join(*uris) # :nodoc:
140
139
  uris[0] = convert_to_uri(uris[0])
141
140
  uris.inject :merge
142
141
  end
143
142
 
143
+ # Compatibility for RFC2396 parser
144
+ def extract(str, schemes = nil, &block) # :nodoc:
145
+ warn "URI::RFC3986_PARSER.extract is obsolete. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
146
+ RFC2396_PARSER.extract(str, schemes, &block)
147
+ end
148
+
149
+ # Compatibility for RFC2396 parser
150
+ def make_regexp(schemes = nil) # :nodoc:
151
+ warn "URI::RFC3986_PARSER.make_regexp is obsolete. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
152
+ RFC2396_PARSER.make_regexp(schemes)
153
+ end
154
+
155
+ # Compatibility for RFC2396 parser
156
+ def escape(str, unsafe = nil) # :nodoc:
157
+ warn "URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
158
+ unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
159
+ end
160
+
161
+ # Compatibility for RFC2396 parser
162
+ def unescape(str, escaped = nil) # :nodoc:
163
+ warn "URI::RFC3986_PARSER.unescape is obsolete. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
164
+ escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
165
+ end
166
+
144
167
  @@to_s = Kernel.instance_method(:to_s)
145
168
  if @@to_s.respond_to?(:bind_call)
146
169
  def inspect
data/lib/uri/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module URI
2
2
  # :stopdoc:
3
- VERSION_CODE = '001300'.freeze
4
- VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
3
+ VERSION = '1.1.1'.freeze
4
+ VERSION_CODE = VERSION.split('.').map{|s| s.rjust(2, '0')}.join.freeze
5
5
  # :startdoc:
6
6
  end
data/lib/uri.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
  # URI is a module providing classes to handle Uniform Resource Identifiers
3
- # (RFC2396[http://tools.ietf.org/html/rfc2396]).
3
+ # (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]).
4
4
  #
5
5
  # == Features
6
6
  #
@@ -47,14 +47,14 @@
47
47
  # A good place to view an RFC spec is http://www.ietf.org/rfc.html.
48
48
  #
49
49
  # Here is a list of all related RFC's:
50
- # - RFC822[http://tools.ietf.org/html/rfc822]
51
- # - RFC1738[http://tools.ietf.org/html/rfc1738]
52
- # - RFC2255[http://tools.ietf.org/html/rfc2255]
53
- # - RFC2368[http://tools.ietf.org/html/rfc2368]
54
- # - RFC2373[http://tools.ietf.org/html/rfc2373]
55
- # - RFC2396[http://tools.ietf.org/html/rfc2396]
56
- # - RFC2732[http://tools.ietf.org/html/rfc2732]
57
- # - RFC3986[http://tools.ietf.org/html/rfc3986]
50
+ # - RFC822[https://www.rfc-editor.org/rfc/rfc822]
51
+ # - RFC1738[https://www.rfc-editor.org/rfc/rfc1738]
52
+ # - RFC2255[https://www.rfc-editor.org/rfc/rfc2255]
53
+ # - RFC2368[https://www.rfc-editor.org/rfc/rfc2368]
54
+ # - RFC2373[https://www.rfc-editor.org/rfc/rfc2373]
55
+ # - RFC2396[https://www.rfc-editor.org/rfc/rfc2396]
56
+ # - RFC2732[https://www.rfc-editor.org/rfc/rfc2732]
57
+ # - RFC3986[https://www.rfc-editor.org/rfc/rfc3986]
58
58
  #
59
59
  # == Class tree
60
60
  #
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Yamada
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-11-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: URI is a module providing classes to handle Uniform Resource Identifiers
14
13
  email:
@@ -17,16 +16,12 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - ".github/dependabot.yml"
21
- - ".github/workflows/gh-pages.yml"
22
- - ".github/workflows/test.yml"
23
- - ".gitignore"
24
- - Gemfile
25
- - LICENSE.txt
19
+ - ".document"
20
+ - ".rdoc_options"
21
+ - BSDL
22
+ - COPYING
26
23
  - README.md
27
- - Rakefile
28
- - bin/console
29
- - bin/setup
24
+ - docs/kernel.rb
30
25
  - lib/uri.rb
31
26
  - lib/uri/common.rb
32
27
  - lib/uri/file.rb
@@ -42,8 +37,6 @@ files:
42
37
  - lib/uri/version.rb
43
38
  - lib/uri/ws.rb
44
39
  - lib/uri/wss.rb
45
- - rakelib/sync_tool.rake
46
- - uri.gemspec
47
40
  homepage: https://github.com/ruby/uri
48
41
  licenses:
49
42
  - Ruby
@@ -54,7 +47,6 @@ metadata:
54
47
  documentation_uri: https://ruby.github.io/uri/
55
48
  homepage_uri: https://github.com/ruby/uri
56
49
  source_code_uri: https://github.com/ruby/uri
57
- post_install_message:
58
50
  rdoc_options: []
59
51
  require_paths:
60
52
  - lib
@@ -69,8 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  requirements: []
72
- rubygems_version: 3.5.0.dev
73
- signing_key:
64
+ rubygems_version: 3.6.9
74
65
  specification_version: 4
75
66
  summary: URI is a module providing classes to handle Uniform Resource Identifiers
76
67
  test_files: []
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: 'github-actions'
4
- directory: '/'
5
- schedule:
6
- interval: 'weekly'
@@ -1,46 +0,0 @@
1
- name: Deploy RDoc site to Pages
2
-
3
- on:
4
- push:
5
- branches: [ 'master' ]
6
- workflow_dispatch:
7
-
8
- permissions:
9
- contents: read
10
- pages: write
11
- id-token: write
12
-
13
- concurrency:
14
- group: "pages"
15
- cancel-in-progress: true
16
-
17
- jobs:
18
- build:
19
- runs-on: ubuntu-latest
20
- steps:
21
- - name: Checkout
22
- uses: actions/checkout@v4
23
- - name: Setup Ruby
24
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
25
- with:
26
- ruby-version: '3.2'
27
- bundler-cache: true
28
- - name: Setup Pages
29
- id: pages
30
- uses: actions/configure-pages@v3
31
- - name: Build with RDoc
32
- # Outputs to the './_site' directory by default
33
- run: bundle exec rake rdoc
34
- - name: Upload artifact
35
- uses: actions/upload-pages-artifact@v2
36
-
37
- deploy:
38
- environment:
39
- name: github-pages
40
- url: ${{ steps.deployment.outputs.page_url }}
41
- runs-on: ubuntu-latest
42
- needs: build
43
- steps:
44
- - name: Deploy to GitHub Pages
45
- id: deployment
46
- uses: actions/deploy-pages@v2
@@ -1,27 +0,0 @@
1
- name: CI
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- ruby-versions:
7
- uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
- with:
9
- min_version: 2.5
10
-
11
- build:
12
- needs: ruby-versions
13
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
14
- strategy:
15
- matrix:
16
- ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
17
- os: [ ubuntu-latest, macos-latest ]
18
- runs-on: ${{ matrix.os }}
19
- steps:
20
- - uses: actions/checkout@v4
21
- - name: Set up Ruby
22
- uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- - run: bundle install --jobs 4 --retry 3
26
- - name: Run test
27
- run: rake test
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
10
- /_site
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem "bundler"
7
- gem "rake"
8
- gem "test-unit"
9
- gem "test-unit-ruby-core"
10
- end
data/Rakefile DELETED
@@ -1,18 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test/lib"
6
- t.ruby_opts << "-rhelper"
7
- t.test_files = FileList["test/**/test_*.rb"]
8
- end
9
-
10
- require "rdoc/task"
11
- RDoc::Task.new do |doc|
12
- doc.main = "README.md"
13
- doc.title = "URI - handle Uniform Resource Identifiers"
14
- doc.rdoc_files = FileList.new %w[lib README.md LICENSE.txt]
15
- doc.rdoc_dir = "_site" # for github pages
16
- end
17
-
18
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "uri"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,17 +0,0 @@
1
- task :sync_tool, [:from] do |t, from: nil|
2
- from ||= (File.identical?(__dir__, "rakelib") ? "../ruby/tool" : File.dirname(__dir__))
3
-
4
- require 'fileutils'
5
-
6
- {
7
- "rakelib/sync_tool.rake" => "rakelib",
8
- "lib/core_assertions.rb" => "test/lib",
9
- "lib/envutil.rb" => "test/lib",
10
- "lib/find_executable.rb" => "test/lib",
11
- "lib/helper.rb" => "test/lib",
12
- }.each do |src, dest|
13
- FileUtils.mkpath(dest)
14
- FileUtils.cp "#{from}/#{src}", dest
15
- rescue Errno::ENOENT
16
- end
17
- end
data/uri.gemspec DELETED
@@ -1,39 +0,0 @@
1
- begin
2
- require_relative "lib/uri/version"
3
- rescue LoadError # Fallback to load version file in ruby core repository
4
- require_relative "version"
5
- end
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "uri"
9
- spec.version = URI::VERSION
10
- spec.authors = ["Akira Yamada"]
11
- spec.email = ["akira@ruby-lang.org"]
12
-
13
- spec.summary = %q{URI is a module providing classes to handle Uniform Resource Identifiers}
14
- spec.description = spec.summary
15
-
16
- github_link = "https://github.com/ruby/uri"
17
-
18
- spec.homepage = github_link
19
- spec.licenses = ["Ruby", "BSD-2-Clause"]
20
-
21
- spec.required_ruby_version = '>= 2.5'
22
-
23
- spec.metadata = {
24
- "bug_tracker_uri" => "#{github_link}/issues",
25
- "changelog_uri" => "#{github_link}/releases",
26
- "documentation_uri" => "https://ruby.github.io/uri/",
27
- "homepage_uri" => spec.homepage,
28
- "source_code_uri" => github_link
29
- }
30
-
31
- # Specify which files should be added to the gem when it is released.
32
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
- `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
- end
36
- spec.bindir = "exe"
37
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
- spec.require_paths = ["lib"]
39
- end