danger-packwerk 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/danger-packwerk/packwerk_wrapper.rb +2 -2
- data/lib/danger-packwerk/version.rb +1 -1
- data/sorbet/config +1 -0
- data/sorbet/rbi/gems/actionview@7.0.4.rbi +11543 -0
- data/sorbet/rbi/gems/activesupport@7.0.4.rbi +12959 -0
- data/sorbet/rbi/gems/addressable@2.8.1.rbi +1505 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
- data/sorbet/rbi/gems/better_html@2.0.1.rbi +286 -0
- data/sorbet/rbi/gems/builder@3.2.4.rbi +8 -0
- data/sorbet/rbi/gems/claide-plugins@0.9.2.rbi +791 -0
- data/sorbet/rbi/gems/claide@1.1.0.rbi +1132 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +2256 -0
- data/sorbet/rbi/gems/colored2@3.1.2.rbi +130 -0
- data/sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi +8695 -0
- data/sorbet/rbi/gems/cork@0.3.0.rbi +248 -0
- data/sorbet/rbi/gems/crass@1.0.6.rbi +436 -0
- data/sorbet/rbi/gems/danger-plugin-api@1.0.0.rbi +8 -0
- data/sorbet/rbi/gems/danger@9.0.0.rbi +4722 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +862 -0
- data/sorbet/rbi/gems/erubi@1.11.0.rbi +102 -0
- data/sorbet/rbi/gems/faraday-em_http@1.0.0.rbi +266 -0
- data/sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi +209 -0
- data/sorbet/rbi/gems/faraday-excon@1.1.0.rbi +212 -0
- data/sorbet/rbi/gems/faraday-http-cache@2.4.1.rbi +805 -0
- data/sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi +221 -0
- data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +266 -0
- data/sorbet/rbi/gems/faraday-net_http@1.0.1.rbi +216 -0
- data/sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi +206 -0
- data/sorbet/rbi/gems/faraday-patron@1.0.0.rbi +212 -0
- data/sorbet/rbi/gems/faraday-rack@1.0.0.rbi +225 -0
- data/sorbet/rbi/gems/faraday-retry@1.0.3.rbi +222 -0
- data/sorbet/rbi/gems/faraday@1.10.2.rbi +1862 -0
- data/sorbet/rbi/gems/git@1.12.0.rbi +1936 -0
- data/sorbet/rbi/gems/i18n@1.12.0.rbi +1643 -0
- data/sorbet/rbi/gems/json@2.6.2.rbi +1418 -0
- data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +8 -0
- data/sorbet/rbi/gems/kramdown@2.4.0.rbi +2168 -0
- data/sorbet/rbi/gems/loofah@2.19.0.rbi +646 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +199 -0
- data/sorbet/rbi/gems/minitest@5.16.3.rbi +997 -0
- data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +165 -0
- data/sorbet/rbi/gems/nap@1.1.0.rbi +351 -0
- data/sorbet/rbi/gems/no_proxy_fix@0.1.2.rbi +8 -0
- data/sorbet/rbi/gems/nokogiri@1.13.8.rbi +4916 -0
- data/sorbet/rbi/gems/octokit@5.6.1.rbi +8939 -0
- data/sorbet/rbi/gems/open4@1.3.4.rbi +8 -0
- data/sorbet/rbi/gems/{packwerk@2.1.1.rbi → packwerk@2.2.1.rbi} +602 -51
- data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
- data/sorbet/rbi/gems/parser@3.1.2.1.rbi +5988 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +6969 -0
- data/sorbet/rbi/gems/public_suffix@5.0.0.rbi +779 -0
- data/sorbet/rbi/gems/racc@1.6.0.rbi +92 -0
- data/sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi +8 -0
- data/sorbet/rbi/gems/rails-html-sanitizer@1.4.3.rbi +493 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +1865 -0
- data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
- data/sorbet/rbi/gems/rchardet@1.8.0.rbi +587 -0
- data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1851 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
- data/sorbet/rbi/gems/rspec-core@3.11.0.rbi +7725 -0
- data/sorbet/rbi/gems/rspec-expectations@3.11.0.rbi +6201 -0
- data/sorbet/rbi/gems/rspec-mocks@3.11.1.rbi +3625 -0
- data/sorbet/rbi/gems/rspec-support@3.11.0.rbi +1176 -0
- data/sorbet/rbi/gems/rspec@3.11.0.rbi +40 -0
- data/sorbet/rbi/gems/rubocop-ast@1.21.0.rbi +4193 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +677 -0
- data/sorbet/rbi/gems/rubocop@1.36.0.rbi +37914 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
- data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
- data/sorbet/rbi/gems/sawyer@0.9.2.rbi +513 -0
- data/sorbet/rbi/gems/smart_properties@1.17.0.rbi +326 -0
- data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
- data/sorbet/rbi/gems/tapioca@0.8.0.rbi +1959 -0
- data/sorbet/rbi/gems/terminal-table@3.0.2.rbi +438 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
- data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +4879 -0
- data/sorbet/rbi/gems/unicode-display_width@2.3.0.rbi +27 -0
- data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +1802 -0
- data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +288 -0
- data/sorbet/rbi/gems/yard@0.9.27.rbi +12668 -0
- data/sorbet/rbi/todo.rbi +122 -0
- metadata +84 -7
- data/sorbet/rbi/gems/danger@8.5.0.rbi +0 -122
@@ -0,0 +1,1505 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `addressable` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem addressable`.
|
6
|
+
|
7
|
+
# Addressable is a library for processing links and URIs.
|
8
|
+
module Addressable; end
|
9
|
+
|
10
|
+
module Addressable::IDNA
|
11
|
+
class << self
|
12
|
+
# Converts from a Unicode internationalized domain name to an ASCII
|
13
|
+
# domain name as described in RFC 3490.
|
14
|
+
def to_ascii(input); end
|
15
|
+
|
16
|
+
# Converts from an ASCII domain name to a Unicode internationalized
|
17
|
+
# domain name as described in RFC 3490.
|
18
|
+
def to_unicode(input); end
|
19
|
+
|
20
|
+
# Unicode normalization form KC.
|
21
|
+
def unicode_normalize_kc(input); end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def lookup_unicode_combining_class(codepoint); end
|
26
|
+
def lookup_unicode_compatibility(codepoint); end
|
27
|
+
def lookup_unicode_composition(unpacked); end
|
28
|
+
def lookup_unicode_lowercase(codepoint); end
|
29
|
+
|
30
|
+
# Bias adaptation method
|
31
|
+
def punycode_adapt(delta, numpoints, firsttime); end
|
32
|
+
|
33
|
+
# @return [Boolean]
|
34
|
+
def punycode_basic?(codepoint); end
|
35
|
+
|
36
|
+
def punycode_decode(punycode); end
|
37
|
+
|
38
|
+
# Returns the numeric value of a basic codepoint
|
39
|
+
# (for use in representing integers) in the range 0 to
|
40
|
+
# base - 1, or PUNYCODE_BASE if codepoint does not represent a value.
|
41
|
+
def punycode_decode_digit(codepoint); end
|
42
|
+
|
43
|
+
# @return [Boolean]
|
44
|
+
def punycode_delimiter?(codepoint); end
|
45
|
+
|
46
|
+
def punycode_encode(unicode); end
|
47
|
+
def punycode_encode_digit(d); end
|
48
|
+
def ucs4_to_utf8(char, buffer); end
|
49
|
+
def unicode_compose(unpacked); end
|
50
|
+
def unicode_compose_pair(ch_one, ch_two); end
|
51
|
+
def unicode_decompose(unpacked); end
|
52
|
+
def unicode_decompose_hangul(codepoint); end
|
53
|
+
|
54
|
+
# Unicode aware downcase method.
|
55
|
+
#
|
56
|
+
# @api private
|
57
|
+
# @param input [String] The input string.
|
58
|
+
# @return [String] The downcased result.
|
59
|
+
def unicode_downcase(input); end
|
60
|
+
|
61
|
+
def unicode_sort_canonical(unpacked); end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Addressable::IDNA::ACE_MAX_LENGTH = T.let(T.unsafe(nil), Integer)
|
66
|
+
Addressable::IDNA::ACE_PREFIX = T.let(T.unsafe(nil), String)
|
67
|
+
Addressable::IDNA::COMPOSITION_TABLE = T.let(T.unsafe(nil), Hash)
|
68
|
+
Addressable::IDNA::HANGUL_LBASE = T.let(T.unsafe(nil), Integer)
|
69
|
+
Addressable::IDNA::HANGUL_LCOUNT = T.let(T.unsafe(nil), Integer)
|
70
|
+
|
71
|
+
# 588
|
72
|
+
Addressable::IDNA::HANGUL_NCOUNT = T.let(T.unsafe(nil), Integer)
|
73
|
+
|
74
|
+
Addressable::IDNA::HANGUL_SBASE = T.let(T.unsafe(nil), Integer)
|
75
|
+
|
76
|
+
# 11172
|
77
|
+
Addressable::IDNA::HANGUL_SCOUNT = T.let(T.unsafe(nil), Integer)
|
78
|
+
|
79
|
+
Addressable::IDNA::HANGUL_TBASE = T.let(T.unsafe(nil), Integer)
|
80
|
+
Addressable::IDNA::HANGUL_TCOUNT = T.let(T.unsafe(nil), Integer)
|
81
|
+
Addressable::IDNA::HANGUL_VBASE = T.let(T.unsafe(nil), Integer)
|
82
|
+
Addressable::IDNA::HANGUL_VCOUNT = T.let(T.unsafe(nil), Integer)
|
83
|
+
Addressable::IDNA::PUNYCODE_BASE = T.let(T.unsafe(nil), Integer)
|
84
|
+
Addressable::IDNA::PUNYCODE_DAMP = T.let(T.unsafe(nil), Integer)
|
85
|
+
Addressable::IDNA::PUNYCODE_DELIMITER = T.let(T.unsafe(nil), Integer)
|
86
|
+
Addressable::IDNA::PUNYCODE_INITIAL_BIAS = T.let(T.unsafe(nil), Integer)
|
87
|
+
Addressable::IDNA::PUNYCODE_INITIAL_N = T.let(T.unsafe(nil), Integer)
|
88
|
+
Addressable::IDNA::PUNYCODE_MAXINT = T.let(T.unsafe(nil), Integer)
|
89
|
+
Addressable::IDNA::PUNYCODE_PRINT_ASCII = T.let(T.unsafe(nil), String)
|
90
|
+
Addressable::IDNA::PUNYCODE_SKEW = T.let(T.unsafe(nil), Integer)
|
91
|
+
Addressable::IDNA::PUNYCODE_TMAX = T.let(T.unsafe(nil), Integer)
|
92
|
+
Addressable::IDNA::PUNYCODE_TMIN = T.let(T.unsafe(nil), Integer)
|
93
|
+
|
94
|
+
# Input is invalid.
|
95
|
+
class Addressable::IDNA::PunycodeBadInput < ::StandardError; end
|
96
|
+
|
97
|
+
# Output would exceed the space provided.
|
98
|
+
class Addressable::IDNA::PunycodeBigOutput < ::StandardError; end
|
99
|
+
|
100
|
+
# Input needs wider integers to process.
|
101
|
+
class Addressable::IDNA::PunycodeOverflow < ::StandardError; end
|
102
|
+
|
103
|
+
Addressable::IDNA::UNICODE_DATA = T.let(T.unsafe(nil), Hash)
|
104
|
+
Addressable::IDNA::UNICODE_DATA_CANONICAL = T.let(T.unsafe(nil), Integer)
|
105
|
+
Addressable::IDNA::UNICODE_DATA_COMBINING_CLASS = T.let(T.unsafe(nil), Integer)
|
106
|
+
Addressable::IDNA::UNICODE_DATA_COMPATIBILITY = T.let(T.unsafe(nil), Integer)
|
107
|
+
Addressable::IDNA::UNICODE_DATA_EXCLUSION = T.let(T.unsafe(nil), Integer)
|
108
|
+
Addressable::IDNA::UNICODE_DATA_LOWERCASE = T.let(T.unsafe(nil), Integer)
|
109
|
+
Addressable::IDNA::UNICODE_DATA_TITLECASE = T.let(T.unsafe(nil), Integer)
|
110
|
+
Addressable::IDNA::UNICODE_DATA_UPPERCASE = T.let(T.unsafe(nil), Integer)
|
111
|
+
Addressable::IDNA::UNICODE_MAX_LENGTH = T.let(T.unsafe(nil), Integer)
|
112
|
+
Addressable::IDNA::UNICODE_TABLE = T.let(T.unsafe(nil), String)
|
113
|
+
Addressable::IDNA::UTF8_REGEX = T.let(T.unsafe(nil), Regexp)
|
114
|
+
Addressable::IDNA::UTF8_REGEX_MULTIBYTE = T.let(T.unsafe(nil), Regexp)
|
115
|
+
|
116
|
+
# This is an implementation of a URI template based on
|
117
|
+
# RFC 6570 (http://tools.ietf.org/html/rfc6570).
|
118
|
+
class Addressable::Template
|
119
|
+
# Creates a new <tt>Addressable::Template</tt> object.
|
120
|
+
#
|
121
|
+
# @param pattern [#to_str] The URI Template pattern.
|
122
|
+
# @return [Addressable::Template] The initialized Template object.
|
123
|
+
def initialize(pattern); end
|
124
|
+
|
125
|
+
# Returns <code>true</code> if the Template objects are equal. This method
|
126
|
+
# does NOT normalize either Template before doing the comparison.
|
127
|
+
#
|
128
|
+
# @param template [Object] The Template to compare.
|
129
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the Templates are equivalent, <code>false</code>
|
130
|
+
# otherwise.
|
131
|
+
def ==(template); end
|
132
|
+
|
133
|
+
# Returns <code>true</code> if the Template objects are equal. This method
|
134
|
+
# does NOT normalize either Template before doing the comparison.
|
135
|
+
# Addressable::Template makes no distinction between `==` and `eql?`.
|
136
|
+
#
|
137
|
+
# @param template [Object] The Template to compare.
|
138
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the Templates are equivalent, <code>false</code>
|
139
|
+
# otherwise.
|
140
|
+
# @see #==
|
141
|
+
def eql?(template); end
|
142
|
+
|
143
|
+
# Expands a URI template into a full URI.
|
144
|
+
#
|
145
|
+
# The object should respond to either the <tt>validate</tt> or
|
146
|
+
# <tt>transform</tt> messages or both. Both the <tt>validate</tt> and
|
147
|
+
# <tt>transform</tt> methods should take two parameters: <tt>name</tt> and
|
148
|
+
# <tt>value</tt>. The <tt>validate</tt> method should return <tt>true</tt>
|
149
|
+
# or <tt>false</tt>; <tt>true</tt> if the value of the variable is valid,
|
150
|
+
# <tt>false</tt> otherwise. An <tt>InvalidTemplateValueError</tt>
|
151
|
+
# exception will be raised if the value is invalid. The <tt>transform</tt>
|
152
|
+
# method should return the transformed variable value as a <tt>String</tt>.
|
153
|
+
# If a <tt>transform</tt> method is used, the value will not be percent
|
154
|
+
# encoded automatically. Unicode normalization will be performed both
|
155
|
+
# before and after sending the value to the transform method.
|
156
|
+
#
|
157
|
+
# @example
|
158
|
+
# class ExampleProcessor
|
159
|
+
# def self.validate(name, value)
|
160
|
+
# return !!(value =~ /^[\w ]+$/) if name == "query"
|
161
|
+
# return true
|
162
|
+
# end
|
163
|
+
#
|
164
|
+
# def self.transform(name, value)
|
165
|
+
# return value.gsub(/ /, "+") if name == "query"
|
166
|
+
# return value
|
167
|
+
# end
|
168
|
+
# end
|
169
|
+
#
|
170
|
+
# Addressable::Template.new(
|
171
|
+
# "http://example.com/search/{query}/"
|
172
|
+
# ).expand(
|
173
|
+
# {"query" => "an example search query"},
|
174
|
+
# ExampleProcessor
|
175
|
+
# ).to_str
|
176
|
+
# #=> "http://example.com/search/an+example+search+query/"
|
177
|
+
#
|
178
|
+
# Addressable::Template.new(
|
179
|
+
# "http://example.com/search/{query}/"
|
180
|
+
# ).expand(
|
181
|
+
# {"query" => "an example search query"}
|
182
|
+
# ).to_str
|
183
|
+
# #=> "http://example.com/search/an%20example%20search%20query/"
|
184
|
+
#
|
185
|
+
# Addressable::Template.new(
|
186
|
+
# "http://example.com/search/{query}/"
|
187
|
+
# ).expand(
|
188
|
+
# {"query" => "bogus!"},
|
189
|
+
# ExampleProcessor
|
190
|
+
# ).to_str
|
191
|
+
# #=> Addressable::Template::InvalidTemplateValueError
|
192
|
+
# @param mapping [Hash] The mapping that corresponds to the pattern.
|
193
|
+
# @param processor [#validate, #transform] An optional processor object may be supplied.
|
194
|
+
# @param normalize_values [Boolean] Optional flag to enable/disable unicode normalization. Default: true
|
195
|
+
# @return [Addressable::URI] The expanded URI template.
|
196
|
+
def expand(mapping, processor = T.unsafe(nil), normalize_values = T.unsafe(nil)); end
|
197
|
+
|
198
|
+
# Extracts a mapping from the URI using a URI Template pattern.
|
199
|
+
#
|
200
|
+
# @example
|
201
|
+
# class ExampleProcessor
|
202
|
+
# def self.restore(name, value)
|
203
|
+
# return value.gsub(/\+/, " ") if name == "query"
|
204
|
+
# return value
|
205
|
+
# end
|
206
|
+
#
|
207
|
+
# def self.match(name)
|
208
|
+
# return ".*?" if name == "first"
|
209
|
+
# return ".*"
|
210
|
+
# end
|
211
|
+
# end
|
212
|
+
#
|
213
|
+
# uri = Addressable::URI.parse(
|
214
|
+
# "http://example.com/search/an+example+search+query/"
|
215
|
+
# )
|
216
|
+
# Addressable::Template.new(
|
217
|
+
# "http://example.com/search/{query}/"
|
218
|
+
# ).extract(uri, ExampleProcessor)
|
219
|
+
# #=> {"query" => "an example search query"}
|
220
|
+
#
|
221
|
+
# uri = Addressable::URI.parse("http://example.com/a/b/c/")
|
222
|
+
# Addressable::Template.new(
|
223
|
+
# "http://example.com/{first}/{second}/"
|
224
|
+
# ).extract(uri, ExampleProcessor)
|
225
|
+
# #=> {"first" => "a", "second" => "b/c"}
|
226
|
+
#
|
227
|
+
# uri = Addressable::URI.parse("http://example.com/a/b/c/")
|
228
|
+
# Addressable::Template.new(
|
229
|
+
# "http://example.com/{first}/{-list|/|second}/"
|
230
|
+
# ).extract(uri)
|
231
|
+
# #=> {"first" => "a", "second" => ["b", "c"]}
|
232
|
+
# @param uri [Addressable::URI, #to_str] The URI to extract from.
|
233
|
+
# @param processor [#restore, #match] A template processor object may optionally be supplied.
|
234
|
+
#
|
235
|
+
# The object should respond to either the <tt>restore</tt> or
|
236
|
+
# <tt>match</tt> messages or both. The <tt>restore</tt> method should
|
237
|
+
# take two parameters: `[String] name` and `[String] value`.
|
238
|
+
# The <tt>restore</tt> method should reverse any transformations that
|
239
|
+
# have been performed on the value to ensure a valid URI.
|
240
|
+
# The <tt>match</tt> method should take a single
|
241
|
+
# parameter: `[String] name`. The <tt>match</tt> method should return
|
242
|
+
# a <tt>String</tt> containing a regular expression capture group for
|
243
|
+
# matching on that particular variable. The default value is `".*?"`.
|
244
|
+
# The <tt>match</tt> method has no effect on multivariate operator
|
245
|
+
# expansions.
|
246
|
+
# @return [Hash, NilClass] The <tt>Hash</tt> mapping that was extracted from the URI, or
|
247
|
+
# <tt>nil</tt> if the URI didn't match the template.
|
248
|
+
def extract(uri, processor = T.unsafe(nil)); end
|
249
|
+
|
250
|
+
# Freeze URI, initializing instance variables.
|
251
|
+
#
|
252
|
+
# @return [Addressable::URI] The frozen URI object.
|
253
|
+
def freeze; end
|
254
|
+
|
255
|
+
# Returns a <tt>String</tt> representation of the Template object's state.
|
256
|
+
#
|
257
|
+
# @return [String] The Template object's state, as a <tt>String</tt>.
|
258
|
+
def inspect; end
|
259
|
+
|
260
|
+
# Returns an Array of variables used within the template pattern.
|
261
|
+
# The variables are listed in the Array in the order they appear within
|
262
|
+
# the pattern. Multiple occurrences of a variable within a pattern are
|
263
|
+
# not represented in this Array.
|
264
|
+
#
|
265
|
+
# @return [Array] The variables present in the template's pattern.
|
266
|
+
def keys; end
|
267
|
+
|
268
|
+
# Extracts match data from the URI using a URI Template pattern.
|
269
|
+
#
|
270
|
+
# @example
|
271
|
+
# class ExampleProcessor
|
272
|
+
# def self.restore(name, value)
|
273
|
+
# return value.gsub(/\+/, " ") if name == "query"
|
274
|
+
# return value
|
275
|
+
# end
|
276
|
+
#
|
277
|
+
# def self.match(name)
|
278
|
+
# return ".*?" if name == "first"
|
279
|
+
# return ".*"
|
280
|
+
# end
|
281
|
+
# end
|
282
|
+
#
|
283
|
+
# uri = Addressable::URI.parse(
|
284
|
+
# "http://example.com/search/an+example+search+query/"
|
285
|
+
# )
|
286
|
+
# match = Addressable::Template.new(
|
287
|
+
# "http://example.com/search/{query}/"
|
288
|
+
# ).match(uri, ExampleProcessor)
|
289
|
+
# match.variables
|
290
|
+
# #=> ["query"]
|
291
|
+
# match.captures
|
292
|
+
# #=> ["an example search query"]
|
293
|
+
#
|
294
|
+
# uri = Addressable::URI.parse("http://example.com/a/b/c/")
|
295
|
+
# match = Addressable::Template.new(
|
296
|
+
# "http://example.com/{first}/{+second}/"
|
297
|
+
# ).match(uri, ExampleProcessor)
|
298
|
+
# match.variables
|
299
|
+
# #=> ["first", "second"]
|
300
|
+
# match.captures
|
301
|
+
# #=> ["a", "b/c"]
|
302
|
+
#
|
303
|
+
# uri = Addressable::URI.parse("http://example.com/a/b/c/")
|
304
|
+
# match = Addressable::Template.new(
|
305
|
+
# "http://example.com/{first}{/second*}/"
|
306
|
+
# ).match(uri)
|
307
|
+
# match.variables
|
308
|
+
# #=> ["first", "second"]
|
309
|
+
# match.captures
|
310
|
+
# #=> ["a", ["b", "c"]]
|
311
|
+
# @param uri [Addressable::URI, #to_str] The URI to extract from.
|
312
|
+
# @param processor [#restore, #match] A template processor object may optionally be supplied.
|
313
|
+
#
|
314
|
+
# The object should respond to either the <tt>restore</tt> or
|
315
|
+
# <tt>match</tt> messages or both. The <tt>restore</tt> method should
|
316
|
+
# take two parameters: `[String] name` and `[String] value`.
|
317
|
+
# The <tt>restore</tt> method should reverse any transformations that
|
318
|
+
# have been performed on the value to ensure a valid URI.
|
319
|
+
# The <tt>match</tt> method should take a single
|
320
|
+
# parameter: `[String] name`. The <tt>match</tt> method should return
|
321
|
+
# a <tt>String</tt> containing a regular expression capture group for
|
322
|
+
# matching on that particular variable. The default value is `".*?"`.
|
323
|
+
# The <tt>match</tt> method has no effect on multivariate operator
|
324
|
+
# expansions.
|
325
|
+
# @return [Hash, NilClass] The <tt>Hash</tt> mapping that was extracted from the URI, or
|
326
|
+
# <tt>nil</tt> if the URI didn't match the template.
|
327
|
+
def match(uri, processor = T.unsafe(nil)); end
|
328
|
+
|
329
|
+
# Returns the named captures of the coerced `Regexp`.
|
330
|
+
#
|
331
|
+
# @api private
|
332
|
+
# @return [Hash] The named captures of the `Regexp` given by {#to_regexp}.
|
333
|
+
def named_captures; end
|
334
|
+
|
335
|
+
# Returns an Array of variables used within the template pattern.
|
336
|
+
# The variables are listed in the Array in the order they appear within
|
337
|
+
# the pattern. Multiple occurrences of a variable within a pattern are
|
338
|
+
# not represented in this Array.
|
339
|
+
#
|
340
|
+
# @return [Array] The variables present in the template's pattern.
|
341
|
+
def names; end
|
342
|
+
|
343
|
+
# Expands a URI template into another URI template.
|
344
|
+
#
|
345
|
+
# The object should respond to either the <tt>validate</tt> or
|
346
|
+
# <tt>transform</tt> messages or both. Both the <tt>validate</tt> and
|
347
|
+
# <tt>transform</tt> methods should take two parameters: <tt>name</tt> and
|
348
|
+
# <tt>value</tt>. The <tt>validate</tt> method should return <tt>true</tt>
|
349
|
+
# or <tt>false</tt>; <tt>true</tt> if the value of the variable is valid,
|
350
|
+
# <tt>false</tt> otherwise. An <tt>InvalidTemplateValueError</tt>
|
351
|
+
# exception will be raised if the value is invalid. The <tt>transform</tt>
|
352
|
+
# method should return the transformed variable value as a <tt>String</tt>.
|
353
|
+
# If a <tt>transform</tt> method is used, the value will not be percent
|
354
|
+
# encoded automatically. Unicode normalization will be performed both
|
355
|
+
# before and after sending the value to the transform method.
|
356
|
+
#
|
357
|
+
# @example
|
358
|
+
# Addressable::Template.new(
|
359
|
+
# "http://example.com/{one}/{two}/"
|
360
|
+
# ).partial_expand({"one" => "1"}).pattern
|
361
|
+
# #=> "http://example.com/1/{two}/"
|
362
|
+
#
|
363
|
+
# Addressable::Template.new(
|
364
|
+
# "http://example.com/{?one,two}/"
|
365
|
+
# ).partial_expand({"one" => "1"}).pattern
|
366
|
+
# #=> "http://example.com/?one=1{&two}/"
|
367
|
+
#
|
368
|
+
# Addressable::Template.new(
|
369
|
+
# "http://example.com/{?one,two,three}/"
|
370
|
+
# ).partial_expand({"one" => "1", "three" => 3}).pattern
|
371
|
+
# #=> "http://example.com/?one=1{&two}&three=3"
|
372
|
+
# @param mapping [Hash] The mapping that corresponds to the pattern.
|
373
|
+
# @param processor [#validate, #transform] An optional processor object may be supplied.
|
374
|
+
# @param normalize_values [Boolean] Optional flag to enable/disable unicode normalization. Default: true
|
375
|
+
# @return [Addressable::Template] The partially expanded URI template.
|
376
|
+
def partial_expand(mapping, processor = T.unsafe(nil), normalize_values = T.unsafe(nil)); end
|
377
|
+
|
378
|
+
# @return [String] The Template object's pattern.
|
379
|
+
def pattern; end
|
380
|
+
|
381
|
+
# Returns the source of the coerced `Regexp`.
|
382
|
+
#
|
383
|
+
# @api private
|
384
|
+
# @return [String] The source of the `Regexp` given by {#to_regexp}.
|
385
|
+
def source; end
|
386
|
+
|
387
|
+
# Coerces a template into a `Regexp` object. This regular expression will
|
388
|
+
# behave very similarly to the actual template, and should match the same
|
389
|
+
# URI values, but it cannot fully handle, for example, values that would
|
390
|
+
# extract to an `Array`.
|
391
|
+
#
|
392
|
+
# @return [Regexp] A regular expression which should match the template.
|
393
|
+
def to_regexp; end
|
394
|
+
|
395
|
+
# Returns a mapping of variables to their default values specified
|
396
|
+
# in the template. Variables without defaults are not returned.
|
397
|
+
#
|
398
|
+
# @return [Hash] Mapping of template variables to their defaults
|
399
|
+
def variable_defaults; end
|
400
|
+
|
401
|
+
# Returns an Array of variables used within the template pattern.
|
402
|
+
# The variables are listed in the Array in the order they appear within
|
403
|
+
# the pattern. Multiple occurrences of a variable within a pattern are
|
404
|
+
# not represented in this Array.
|
405
|
+
#
|
406
|
+
# @return [Array] The variables present in the template's pattern.
|
407
|
+
def variables; end
|
408
|
+
|
409
|
+
private
|
410
|
+
|
411
|
+
# Takes a set of values, and joins them together based on the
|
412
|
+
# operator.
|
413
|
+
#
|
414
|
+
# @param operator [String, Nil] One of the operators from the set
|
415
|
+
# (?,&,+,#,;,/,.), or nil if there wasn't one.
|
416
|
+
# @param return_value [Array] The set of return values (as [variable_name, value] tuples) that will
|
417
|
+
# be joined together.
|
418
|
+
# @return [String] The transformed mapped value
|
419
|
+
def join_values(operator, return_value); end
|
420
|
+
|
421
|
+
# Generates a hash with string keys
|
422
|
+
#
|
423
|
+
# @param mapping [Hash] A mapping hash to normalize
|
424
|
+
# @return [Hash] A hash with stringified keys
|
425
|
+
def normalize_keys(mapping); end
|
426
|
+
|
427
|
+
# Takes a set of values, and joins them together based on the
|
428
|
+
# operator.
|
429
|
+
#
|
430
|
+
# @param value [Hash, Array, String] Normalizes keys and values with IDNA#unicode_normalize_kc
|
431
|
+
# @return [Hash, Array, String] The normalized values
|
432
|
+
def normalize_value(value); end
|
433
|
+
|
434
|
+
def ordered_variable_defaults; end
|
435
|
+
|
436
|
+
# Generates the <tt>Regexp</tt> that parses a template pattern.
|
437
|
+
#
|
438
|
+
# @param pattern [String] The URI template pattern.
|
439
|
+
# @param processor [#match] The template processor to use.
|
440
|
+
# @return [Array, Regexp] An array of expansion variables nad a regular expression which may be
|
441
|
+
# used to parse a template pattern
|
442
|
+
def parse_new_template_pattern(pattern, processor = T.unsafe(nil)); end
|
443
|
+
|
444
|
+
# Generates the <tt>Regexp</tt> that parses a template pattern. Memoizes the
|
445
|
+
# value if template processor not set (processors may not be deterministic)
|
446
|
+
#
|
447
|
+
# @param pattern [String] The URI template pattern.
|
448
|
+
# @param processor [#match] The template processor to use.
|
449
|
+
# @return [Array, Regexp] An array of expansion variables nad a regular expression which may be
|
450
|
+
# used to parse a template pattern
|
451
|
+
def parse_template_pattern(pattern, processor = T.unsafe(nil)); end
|
452
|
+
|
453
|
+
# Transforms a mapped value so that values can be substituted into the
|
454
|
+
# template.
|
455
|
+
#
|
456
|
+
# The object should respond to either the <tt>validate</tt> or
|
457
|
+
# <tt>transform</tt> messages or both. Both the <tt>validate</tt> and
|
458
|
+
# <tt>transform</tt> methods should take two parameters: <tt>name</tt> and
|
459
|
+
# <tt>value</tt>. The <tt>validate</tt> method should return <tt>true</tt>
|
460
|
+
# or <tt>false</tt>; <tt>true</tt> if the value of the variable is valid,
|
461
|
+
# <tt>false</tt> otherwise. An <tt>InvalidTemplateValueError</tt> exception
|
462
|
+
# will be raised if the value is invalid. The <tt>transform</tt> method
|
463
|
+
# should return the transformed variable value as a <tt>String</tt>. If a
|
464
|
+
# <tt>transform</tt> method is used, the value will not be percent encoded
|
465
|
+
# automatically. Unicode normalization will be performed both before and
|
466
|
+
# after sending the value to the transform method.
|
467
|
+
#
|
468
|
+
# @param mapping [Hash] The mapping to replace captures
|
469
|
+
# @param capture [String] The expression to replace
|
470
|
+
# @param processor [#validate, #transform] An optional processor object may be supplied.
|
471
|
+
# @param normalize_values [Boolean] Optional flag to enable/disable unicode normalization. Default: true
|
472
|
+
# @return [String] The expanded expression
|
473
|
+
def transform_capture(mapping, capture, processor = T.unsafe(nil), normalize_values = T.unsafe(nil)); end
|
474
|
+
|
475
|
+
# Loops through each capture and expands any values available in mapping
|
476
|
+
#
|
477
|
+
# The object should respond to either the <tt>validate</tt> or
|
478
|
+
# <tt>transform</tt> messages or both. Both the <tt>validate</tt> and
|
479
|
+
# <tt>transform</tt> methods should take two parameters: <tt>name</tt> and
|
480
|
+
# <tt>value</tt>. The <tt>validate</tt> method should return <tt>true</tt>
|
481
|
+
# or <tt>false</tt>; <tt>true</tt> if the value of the variable is valid,
|
482
|
+
# <tt>false</tt> otherwise. An <tt>InvalidTemplateValueError</tt> exception
|
483
|
+
# will be raised if the value is invalid. The <tt>transform</tt> method
|
484
|
+
# should return the transformed variable value as a <tt>String</tt>. If a
|
485
|
+
# <tt>transform</tt> method is used, the value will not be percent encoded
|
486
|
+
# automatically. Unicode normalization will be performed both before and
|
487
|
+
# after sending the value to the transform method.
|
488
|
+
#
|
489
|
+
# @param mapping [Hash] Set of keys to expand
|
490
|
+
# @param capture [String] The expression to expand
|
491
|
+
# @param processor [#validate, #transform] An optional processor object may be supplied.
|
492
|
+
# @param normalize_values [Boolean] Optional flag to enable/disable unicode normalization. Default: true
|
493
|
+
# @return [String] The expanded expression
|
494
|
+
def transform_partial_capture(mapping, capture, processor = T.unsafe(nil), normalize_values = T.unsafe(nil)); end
|
495
|
+
end
|
496
|
+
|
497
|
+
Addressable::Template::EXPRESSION = T.let(T.unsafe(nil), Regexp)
|
498
|
+
|
499
|
+
# Raised if an invalid template operator is used in a pattern.
|
500
|
+
class Addressable::Template::InvalidTemplateOperatorError < ::StandardError; end
|
501
|
+
|
502
|
+
# Raised if an invalid template value is supplied.
|
503
|
+
class Addressable::Template::InvalidTemplateValueError < ::StandardError; end
|
504
|
+
|
505
|
+
Addressable::Template::JOINERS = T.let(T.unsafe(nil), Hash)
|
506
|
+
Addressable::Template::LEADERS = T.let(T.unsafe(nil), Hash)
|
507
|
+
|
508
|
+
# This class represents the data that is extracted when a Template
|
509
|
+
# is matched against a URI.
|
510
|
+
class Addressable::Template::MatchData
|
511
|
+
# Creates a new MatchData object.
|
512
|
+
# MatchData objects should never be instantiated directly.
|
513
|
+
#
|
514
|
+
# @param uri [Addressable::URI] The URI that the template was matched against.
|
515
|
+
# @return [MatchData] a new instance of MatchData
|
516
|
+
def initialize(uri, template, mapping); end
|
517
|
+
|
518
|
+
# Accesses captured values by name or by index.
|
519
|
+
#
|
520
|
+
# @param key [String, Symbol, Fixnum] Capture index or name. Note that when accessing by with index
|
521
|
+
# of 0, the full URI will be returned. The intention is to mimic
|
522
|
+
# the ::MatchData#[] behavior.
|
523
|
+
# @param len [#to_int, nil] If provided, an array of values will be returend with the given
|
524
|
+
# parameter used as length.
|
525
|
+
# @return [Array, String, nil] The captured value corresponding to the index or name. If the
|
526
|
+
# value was not provided or the key is unknown, nil will be
|
527
|
+
# returned.
|
528
|
+
#
|
529
|
+
# If the second parameter is provided, an array of that length will
|
530
|
+
# be returned instead.
|
531
|
+
def [](key, len = T.unsafe(nil)); end
|
532
|
+
|
533
|
+
# @return [Array] The list of values that were captured by the Template.
|
534
|
+
# Note that this list will include nils for any variables which
|
535
|
+
# were in the Template, but did not appear in the URI.
|
536
|
+
def captures; end
|
537
|
+
|
538
|
+
# Returns a <tt>String</tt> representation of the MatchData's state.
|
539
|
+
#
|
540
|
+
# @return [String] The MatchData's state, as a <tt>String</tt>.
|
541
|
+
def inspect; end
|
542
|
+
|
543
|
+
# @return [Array] The list of variables that were present in the Template.
|
544
|
+
# Note that this list will include variables which do not appear
|
545
|
+
# in the mapping because they were not present in URI.
|
546
|
+
def keys; end
|
547
|
+
|
548
|
+
# @return [Hash] The mapping that resulted from the match.
|
549
|
+
# Note that this mapping does not include keys or values for
|
550
|
+
# variables that appear in the Template, but are not present
|
551
|
+
# in the URI.
|
552
|
+
def mapping; end
|
553
|
+
|
554
|
+
# @return [Array] The list of variables that were present in the Template.
|
555
|
+
# Note that this list will include variables which do not appear
|
556
|
+
# in the mapping because they were not present in URI.
|
557
|
+
def names; end
|
558
|
+
|
559
|
+
# Dummy method for code expecting a ::MatchData instance
|
560
|
+
#
|
561
|
+
# @return [String] An empty string.
|
562
|
+
def post_match; end
|
563
|
+
|
564
|
+
# Dummy method for code expecting a ::MatchData instance
|
565
|
+
#
|
566
|
+
# @return [String] An empty string.
|
567
|
+
def pre_match; end
|
568
|
+
|
569
|
+
# @return [String] The matched URI as String.
|
570
|
+
def string; end
|
571
|
+
|
572
|
+
# @return [Addressable::Template] The Template used for the match.
|
573
|
+
def template; end
|
574
|
+
|
575
|
+
# @return [Array] Array with the matched URI as first element followed by the captured
|
576
|
+
# values.
|
577
|
+
def to_a; end
|
578
|
+
|
579
|
+
# @return [String] The matched URI as String.
|
580
|
+
def to_s; end
|
581
|
+
|
582
|
+
# @return [Addressable::URI] The URI that the Template was matched against.
|
583
|
+
def uri; end
|
584
|
+
|
585
|
+
# @return [Array] The list of values that were captured by the Template.
|
586
|
+
# Note that this list will include nils for any variables which
|
587
|
+
# were in the Template, but did not appear in the URI.
|
588
|
+
def values; end
|
589
|
+
|
590
|
+
# Returns multiple captured values at once.
|
591
|
+
#
|
592
|
+
# @param *indexes [String, Symbol, Fixnum] Indices of the captures to be returned
|
593
|
+
# @return [Array] Values corresponding to given indices.
|
594
|
+
# @see Addressable::Template::MatchData#[]
|
595
|
+
def values_at(*indexes); end
|
596
|
+
|
597
|
+
# @return [Array] The list of variables that were present in the Template.
|
598
|
+
# Note that this list will include variables which do not appear
|
599
|
+
# in the mapping because they were not present in URI.
|
600
|
+
def variables; end
|
601
|
+
end
|
602
|
+
|
603
|
+
Addressable::Template::RESERVED = T.let(T.unsafe(nil), String)
|
604
|
+
|
605
|
+
# Raised if an invalid template operator is used in a pattern.
|
606
|
+
class Addressable::Template::TemplateOperatorAbortedError < ::StandardError; end
|
607
|
+
|
608
|
+
Addressable::Template::UNRESERVED = T.let(T.unsafe(nil), String)
|
609
|
+
Addressable::Template::VARIABLE_LIST = T.let(T.unsafe(nil), Regexp)
|
610
|
+
Addressable::Template::VARNAME = T.let(T.unsafe(nil), Regexp)
|
611
|
+
Addressable::Template::VARSPEC = T.let(T.unsafe(nil), Regexp)
|
612
|
+
|
613
|
+
# This is an implementation of a URI parser based on
|
614
|
+
# <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>,
|
615
|
+
# <a href="http://www.ietf.org/rfc/rfc3987.txt">RFC 3987</a>.
|
616
|
+
class Addressable::URI
|
617
|
+
# Creates a new uri object from component parts.
|
618
|
+
#
|
619
|
+
# @option [String,
|
620
|
+
# @option [String,
|
621
|
+
# @option [String,
|
622
|
+
# @option [String,
|
623
|
+
# @option [String,
|
624
|
+
# @option [String,
|
625
|
+
# @option [String,
|
626
|
+
# @option [String,
|
627
|
+
# @option [String,
|
628
|
+
# @option [String,
|
629
|
+
# @param [String, [Hash] a customizable set of options
|
630
|
+
# @return [Addressable::URI] The constructed URI object.
|
631
|
+
def initialize(options = T.unsafe(nil)); end
|
632
|
+
|
633
|
+
# Joins two URIs together.
|
634
|
+
#
|
635
|
+
# @param The [String, Addressable::URI, #to_str] URI to join with.
|
636
|
+
# @return [Addressable::URI] The joined URI.
|
637
|
+
def +(uri); end
|
638
|
+
|
639
|
+
# Returns <code>true</code> if the URI objects are equal. This method
|
640
|
+
# normalizes both URIs before doing the comparison.
|
641
|
+
#
|
642
|
+
# @param uri [Object] The URI to compare.
|
643
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the URIs are equivalent, <code>false</code>
|
644
|
+
# otherwise.
|
645
|
+
def ==(uri); end
|
646
|
+
|
647
|
+
# Returns <code>true</code> if the URI objects are equal. This method
|
648
|
+
# normalizes both URIs before doing the comparison, and allows comparison
|
649
|
+
# against <code>Strings</code>.
|
650
|
+
#
|
651
|
+
# @param uri [Object] The URI to compare.
|
652
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the URIs are equivalent, <code>false</code>
|
653
|
+
# otherwise.
|
654
|
+
def ===(uri); end
|
655
|
+
|
656
|
+
# Determines if the URI is absolute.
|
657
|
+
#
|
658
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the URI is absolute. <code>false</code>
|
659
|
+
# otherwise.
|
660
|
+
def absolute?; end
|
661
|
+
|
662
|
+
# The authority component for this URI.
|
663
|
+
# Combines the user, password, host, and port components.
|
664
|
+
#
|
665
|
+
# @return [String] The authority component.
|
666
|
+
def authority; end
|
667
|
+
|
668
|
+
# Sets the authority component for this URI.
|
669
|
+
#
|
670
|
+
# @param new_authority [String, #to_str] The new authority component.
|
671
|
+
def authority=(new_authority); end
|
672
|
+
|
673
|
+
# The basename, if any, of the file in the path component.
|
674
|
+
#
|
675
|
+
# @return [String] The path's basename.
|
676
|
+
def basename; end
|
677
|
+
|
678
|
+
# The default port for this URI's scheme.
|
679
|
+
# This method will always returns the default port for the URI's scheme
|
680
|
+
# regardless of the presence of an explicit port in the URI.
|
681
|
+
#
|
682
|
+
# @return [Integer] The default port.
|
683
|
+
def default_port; end
|
684
|
+
|
685
|
+
# This method allows you to make several changes to a URI simultaneously,
|
686
|
+
# which separately would cause validation errors, but in conjunction,
|
687
|
+
# are valid. The URI will be revalidated as soon as the entire block has
|
688
|
+
# been executed.
|
689
|
+
#
|
690
|
+
# @param block [Proc] A set of operations to perform on a given URI.
|
691
|
+
# @raise [LocalJumpError]
|
692
|
+
def defer_validation; end
|
693
|
+
|
694
|
+
# Creates a URI suitable for display to users. If semantic attacks are
|
695
|
+
# likely, the application should try to detect these and warn the user.
|
696
|
+
# See <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>,
|
697
|
+
# section 7.6 for more information.
|
698
|
+
#
|
699
|
+
# @return [Addressable::URI] A URI suitable for display purposes.
|
700
|
+
def display_uri; end
|
701
|
+
|
702
|
+
# Returns the public suffix domain for this host.
|
703
|
+
#
|
704
|
+
# @example
|
705
|
+
# Addressable::URI.parse("http://www.example.co.uk").domain # => "example.co.uk"
|
706
|
+
def domain; end
|
707
|
+
|
708
|
+
# Clones the URI object.
|
709
|
+
#
|
710
|
+
# @return [Addressable::URI] The cloned URI.
|
711
|
+
def dup; end
|
712
|
+
|
713
|
+
# Determines if the URI is an empty string.
|
714
|
+
#
|
715
|
+
# @return [TrueClass, FalseClass] Returns <code>true</code> if empty, <code>false</code> otherwise.
|
716
|
+
def empty?; end
|
717
|
+
|
718
|
+
# Returns <code>true</code> if the URI objects are equal. This method
|
719
|
+
# does NOT normalize either URI before doing the comparison.
|
720
|
+
#
|
721
|
+
# @param uri [Object] The URI to compare.
|
722
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the URIs are equivalent, <code>false</code>
|
723
|
+
# otherwise.
|
724
|
+
def eql?(uri); end
|
725
|
+
|
726
|
+
# The extname, if any, of the file in the path component.
|
727
|
+
# Empty string if there is no extension.
|
728
|
+
#
|
729
|
+
# @return [String] The path's extname.
|
730
|
+
def extname; end
|
731
|
+
|
732
|
+
# The fragment component for this URI.
|
733
|
+
#
|
734
|
+
# @return [String] The fragment component.
|
735
|
+
def fragment; end
|
736
|
+
|
737
|
+
# Sets the fragment component for this URI.
|
738
|
+
#
|
739
|
+
# @param new_fragment [String, #to_str] The new fragment component.
|
740
|
+
def fragment=(new_fragment); end
|
741
|
+
|
742
|
+
# Freeze URI, initializing instance variables.
|
743
|
+
#
|
744
|
+
# @return [Addressable::URI] The frozen URI object.
|
745
|
+
def freeze; end
|
746
|
+
|
747
|
+
# A hash value that will make a URI equivalent to its normalized
|
748
|
+
# form.
|
749
|
+
#
|
750
|
+
# @return [Integer] A hash of the URI.
|
751
|
+
def hash; end
|
752
|
+
|
753
|
+
# The host component for this URI.
|
754
|
+
#
|
755
|
+
# @return [String] The host component.
|
756
|
+
def host; end
|
757
|
+
|
758
|
+
# Sets the host component for this URI.
|
759
|
+
#
|
760
|
+
# @param new_host [String, #to_str] The new host component.
|
761
|
+
def host=(new_host); end
|
762
|
+
|
763
|
+
# This method is same as URI::Generic#host except
|
764
|
+
# brackets for IPv6 (and 'IPvFuture') addresses are removed.
|
765
|
+
#
|
766
|
+
# @return [String] The hostname for this URI.
|
767
|
+
# @see Addressable::URI#host
|
768
|
+
def hostname; end
|
769
|
+
|
770
|
+
# This method is same as URI::Generic#host= except
|
771
|
+
# the argument can be a bare IPv6 address (or 'IPvFuture').
|
772
|
+
#
|
773
|
+
# @param new_hostname [String, #to_str] The new hostname for this URI.
|
774
|
+
# @see Addressable::URI#host=
|
775
|
+
def hostname=(new_hostname); end
|
776
|
+
|
777
|
+
# The inferred port component for this URI.
|
778
|
+
# This method will normalize to the default port for the URI's scheme if
|
779
|
+
# the port isn't explicitly specified in the URI.
|
780
|
+
#
|
781
|
+
# @return [Integer] The inferred port component.
|
782
|
+
def inferred_port; end
|
783
|
+
|
784
|
+
# Returns a <code>String</code> representation of the URI object's state.
|
785
|
+
#
|
786
|
+
# @return [String] The URI object's state, as a <code>String</code>.
|
787
|
+
def inspect; end
|
788
|
+
|
789
|
+
# Determines if the scheme indicates an IP-based protocol.
|
790
|
+
#
|
791
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the scheme indicates an IP-based protocol.
|
792
|
+
# <code>false</code> otherwise.
|
793
|
+
def ip_based?; end
|
794
|
+
|
795
|
+
# Joins two URIs together.
|
796
|
+
#
|
797
|
+
# @param The [String, Addressable::URI, #to_str] URI to join with.
|
798
|
+
# @return [Addressable::URI] The joined URI.
|
799
|
+
def join(uri); end
|
800
|
+
|
801
|
+
# Destructive form of <code>join</code>.
|
802
|
+
#
|
803
|
+
# @param The [String, Addressable::URI, #to_str] URI to join with.
|
804
|
+
# @return [Addressable::URI] The joined URI.
|
805
|
+
# @see Addressable::URI#join
|
806
|
+
def join!(uri); end
|
807
|
+
|
808
|
+
# Merges a URI with a <code>Hash</code> of components.
|
809
|
+
# This method has different behavior from <code>join</code>. Any
|
810
|
+
# components present in the <code>hash</code> parameter will override the
|
811
|
+
# original components. The path component is not treated specially.
|
812
|
+
#
|
813
|
+
# @param The [Hash, Addressable::URI, #to_hash] components to merge with.
|
814
|
+
# @return [Addressable::URI] The merged URI.
|
815
|
+
# @see Hash#merge
|
816
|
+
def merge(hash); end
|
817
|
+
|
818
|
+
# Destructive form of <code>merge</code>.
|
819
|
+
#
|
820
|
+
# @param The [Hash, Addressable::URI, #to_hash] components to merge with.
|
821
|
+
# @return [Addressable::URI] The merged URI.
|
822
|
+
# @see Addressable::URI#merge
|
823
|
+
def merge!(uri); end
|
824
|
+
|
825
|
+
# Returns a normalized URI object.
|
826
|
+
#
|
827
|
+
# NOTE: This method does not attempt to fully conform to specifications.
|
828
|
+
# It exists largely to correct other people's failures to read the
|
829
|
+
# specifications, and also to deal with caching issues since several
|
830
|
+
# different URIs may represent the same resource and should not be
|
831
|
+
# cached multiple times.
|
832
|
+
#
|
833
|
+
# @return [Addressable::URI] The normalized URI.
|
834
|
+
def normalize; end
|
835
|
+
|
836
|
+
# Destructively normalizes this URI object.
|
837
|
+
#
|
838
|
+
# @return [Addressable::URI] The normalized URI.
|
839
|
+
# @see Addressable::URI#normalize
|
840
|
+
def normalize!; end
|
841
|
+
|
842
|
+
# The authority component for this URI, normalized.
|
843
|
+
#
|
844
|
+
# @return [String] The authority component, normalized.
|
845
|
+
def normalized_authority; end
|
846
|
+
|
847
|
+
# The fragment component for this URI, normalized.
|
848
|
+
#
|
849
|
+
# @return [String] The fragment component, normalized.
|
850
|
+
def normalized_fragment; end
|
851
|
+
|
852
|
+
# The host component for this URI, normalized.
|
853
|
+
#
|
854
|
+
# @return [String] The host component, normalized.
|
855
|
+
def normalized_host; end
|
856
|
+
|
857
|
+
# The password component for this URI, normalized.
|
858
|
+
#
|
859
|
+
# @return [String] The password component, normalized.
|
860
|
+
def normalized_password; end
|
861
|
+
|
862
|
+
# The path component for this URI, normalized.
|
863
|
+
#
|
864
|
+
# @return [String] The path component, normalized.
|
865
|
+
def normalized_path; end
|
866
|
+
|
867
|
+
# The port component for this URI, normalized.
|
868
|
+
#
|
869
|
+
# @return [Integer] The port component, normalized.
|
870
|
+
def normalized_port; end
|
871
|
+
|
872
|
+
# The query component for this URI, normalized.
|
873
|
+
#
|
874
|
+
# @return [String] The query component, normalized.
|
875
|
+
def normalized_query(*flags); end
|
876
|
+
|
877
|
+
# The scheme component for this URI, normalized.
|
878
|
+
#
|
879
|
+
# @return [String] The scheme component, normalized.
|
880
|
+
def normalized_scheme; end
|
881
|
+
|
882
|
+
# The normalized combination of components that represent a site.
|
883
|
+
# Combines the scheme, user, password, host, and port components.
|
884
|
+
# Primarily useful for HTTP and HTTPS.
|
885
|
+
#
|
886
|
+
# For example, <code>"http://example.com/path?query"</code> would have a
|
887
|
+
# <code>site</code> value of <code>"http://example.com"</code>.
|
888
|
+
#
|
889
|
+
# @return [String] The normalized components that identify a site.
|
890
|
+
def normalized_site; end
|
891
|
+
|
892
|
+
# The user component for this URI, normalized.
|
893
|
+
#
|
894
|
+
# @return [String] The user component, normalized.
|
895
|
+
def normalized_user; end
|
896
|
+
|
897
|
+
# The userinfo component for this URI, normalized.
|
898
|
+
#
|
899
|
+
# @return [String] The userinfo component, normalized.
|
900
|
+
def normalized_userinfo; end
|
901
|
+
|
902
|
+
# Omits components from a URI.
|
903
|
+
#
|
904
|
+
# @example
|
905
|
+
# uri = Addressable::URI.parse("http://example.com/path?query")
|
906
|
+
# #=> #<Addressable::URI:0xcc5e7a URI:http://example.com/path?query>
|
907
|
+
# uri.omit(:scheme, :authority)
|
908
|
+
# #=> #<Addressable::URI:0xcc4d86 URI:/path?query>
|
909
|
+
# @param *components [Symbol] The components to be omitted.
|
910
|
+
# @return [Addressable::URI] The URI with components omitted.
|
911
|
+
def omit(*components); end
|
912
|
+
|
913
|
+
# Destructive form of omit.
|
914
|
+
#
|
915
|
+
# @param *components [Symbol] The components to be omitted.
|
916
|
+
# @return [Addressable::URI] The URI with components omitted.
|
917
|
+
# @see Addressable::URI#omit
|
918
|
+
def omit!(*components); end
|
919
|
+
|
920
|
+
# The origin for this URI, serialized to ASCII, as per
|
921
|
+
# RFC 6454, section 6.2.
|
922
|
+
#
|
923
|
+
# @return [String] The serialized origin.
|
924
|
+
def origin; end
|
925
|
+
|
926
|
+
# Sets the origin for this URI, serialized to ASCII, as per
|
927
|
+
# RFC 6454, section 6.2. This assignment will reset the `userinfo`
|
928
|
+
# component.
|
929
|
+
#
|
930
|
+
# @param new_origin [String, #to_str] The new origin component.
|
931
|
+
def origin=(new_origin); end
|
932
|
+
|
933
|
+
# The password component for this URI.
|
934
|
+
#
|
935
|
+
# @return [String] The password component.
|
936
|
+
def password; end
|
937
|
+
|
938
|
+
# Sets the password component for this URI.
|
939
|
+
#
|
940
|
+
# @param new_password [String, #to_str] The new password component.
|
941
|
+
def password=(new_password); end
|
942
|
+
|
943
|
+
# The path component for this URI.
|
944
|
+
#
|
945
|
+
# @return [String] The path component.
|
946
|
+
def path; end
|
947
|
+
|
948
|
+
# Sets the path component for this URI.
|
949
|
+
#
|
950
|
+
# @param new_path [String, #to_str] The new path component.
|
951
|
+
def path=(new_path); end
|
952
|
+
|
953
|
+
# The port component for this URI.
|
954
|
+
# This is the port number actually given in the URI. This does not
|
955
|
+
# infer port numbers from default values.
|
956
|
+
#
|
957
|
+
# @return [Integer] The port component.
|
958
|
+
def port; end
|
959
|
+
|
960
|
+
# Sets the port component for this URI.
|
961
|
+
#
|
962
|
+
# @param new_port [String, Integer, #to_s] The new port component.
|
963
|
+
def port=(new_port); end
|
964
|
+
|
965
|
+
# The query component for this URI.
|
966
|
+
#
|
967
|
+
# @return [String] The query component.
|
968
|
+
def query; end
|
969
|
+
|
970
|
+
# Sets the query component for this URI.
|
971
|
+
#
|
972
|
+
# @param new_query [String, #to_str] The new query component.
|
973
|
+
def query=(new_query); end
|
974
|
+
|
975
|
+
# Converts the query component to a Hash value.
|
976
|
+
#
|
977
|
+
# @example
|
978
|
+
# Addressable::URI.parse("?one=1&two=2&three=3").query_values
|
979
|
+
# #=> {"one" => "1", "two" => "2", "three" => "3"}
|
980
|
+
# Addressable::URI.parse("?one=two&one=three").query_values(Array)
|
981
|
+
# #=> [["one", "two"], ["one", "three"]]
|
982
|
+
# Addressable::URI.parse("?one=two&one=three").query_values(Hash)
|
983
|
+
# #=> {"one" => "three"}
|
984
|
+
# Addressable::URI.parse("?").query_values
|
985
|
+
# #=> {}
|
986
|
+
# Addressable::URI.parse("").query_values
|
987
|
+
# #=> nil
|
988
|
+
# @param return_type [Class] The return type desired. Value must be either
|
989
|
+
# `Hash` or `Array`.
|
990
|
+
# @return [Hash, Array, nil] The query string parsed as a Hash or Array
|
991
|
+
# or nil if the query string is blank.
|
992
|
+
def query_values(return_type = T.unsafe(nil)); end
|
993
|
+
|
994
|
+
# Sets the query component for this URI from a Hash object.
|
995
|
+
# An empty Hash or Array will result in an empty query string.
|
996
|
+
#
|
997
|
+
# @example
|
998
|
+
# uri.query_values = {:a => "a", :b => ["c", "d", "e"]}
|
999
|
+
# uri.query
|
1000
|
+
# # => "a=a&b=c&b=d&b=e"
|
1001
|
+
# uri.query_values = [['a', 'a'], ['b', 'c'], ['b', 'd'], ['b', 'e']]
|
1002
|
+
# uri.query
|
1003
|
+
# # => "a=a&b=c&b=d&b=e"
|
1004
|
+
# uri.query_values = [['a', 'a'], ['b', ['c', 'd', 'e']]]
|
1005
|
+
# uri.query
|
1006
|
+
# # => "a=a&b=c&b=d&b=e"
|
1007
|
+
# uri.query_values = [['flag'], ['key', 'value']]
|
1008
|
+
# uri.query
|
1009
|
+
# # => "flag&key=value"
|
1010
|
+
# @param new_query_values [Hash, #to_hash, Array] The new query values.
|
1011
|
+
def query_values=(new_query_values); end
|
1012
|
+
|
1013
|
+
# Determines if the URI is relative.
|
1014
|
+
#
|
1015
|
+
# @return [TrueClass, FalseClass] <code>true</code> if the URI is relative. <code>false</code>
|
1016
|
+
# otherwise.
|
1017
|
+
def relative?; end
|
1018
|
+
|
1019
|
+
# The HTTP request URI for this URI. This is the path and the
|
1020
|
+
# query string.
|
1021
|
+
#
|
1022
|
+
# @return [String] The request URI required for an HTTP request.
|
1023
|
+
def request_uri; end
|
1024
|
+
|
1025
|
+
# Sets the HTTP request URI for this URI.
|
1026
|
+
#
|
1027
|
+
# @param new_request_uri [String, #to_str] The new HTTP request URI.
|
1028
|
+
def request_uri=(new_request_uri); end
|
1029
|
+
|
1030
|
+
# Returns the shortest normalized relative form of this URI that uses the
|
1031
|
+
# supplied URI as a base for resolution. Returns an absolute URI if
|
1032
|
+
# necessary. This is effectively the opposite of <code>route_to</code>.
|
1033
|
+
#
|
1034
|
+
# @param uri [String, Addressable::URI, #to_str] The URI to route from.
|
1035
|
+
# @return [Addressable::URI] The normalized relative URI that is equivalent to the original URI.
|
1036
|
+
def route_from(uri); end
|
1037
|
+
|
1038
|
+
# Returns the shortest normalized relative form of the supplied URI that
|
1039
|
+
# uses this URI as a base for resolution. Returns an absolute URI if
|
1040
|
+
# necessary. This is effectively the opposite of <code>route_from</code>.
|
1041
|
+
#
|
1042
|
+
# @param uri [String, Addressable::URI, #to_str] The URI to route to.
|
1043
|
+
# @return [Addressable::URI] The normalized relative URI that is equivalent to the supplied URI.
|
1044
|
+
def route_to(uri); end
|
1045
|
+
|
1046
|
+
# The scheme component for this URI.
|
1047
|
+
#
|
1048
|
+
# @return [String] The scheme component.
|
1049
|
+
def scheme; end
|
1050
|
+
|
1051
|
+
# Sets the scheme component for this URI.
|
1052
|
+
#
|
1053
|
+
# @param new_scheme [String, #to_str] The new scheme component.
|
1054
|
+
def scheme=(new_scheme); end
|
1055
|
+
|
1056
|
+
# The combination of components that represent a site.
|
1057
|
+
# Combines the scheme, user, password, host, and port components.
|
1058
|
+
# Primarily useful for HTTP and HTTPS.
|
1059
|
+
#
|
1060
|
+
# For example, <code>"http://example.com/path?query"</code> would have a
|
1061
|
+
# <code>site</code> value of <code>"http://example.com"</code>.
|
1062
|
+
#
|
1063
|
+
# @return [String] The components that identify a site.
|
1064
|
+
def site; end
|
1065
|
+
|
1066
|
+
# Sets the site value for this URI.
|
1067
|
+
#
|
1068
|
+
# @param new_site [String, #to_str] The new site value.
|
1069
|
+
def site=(new_site); end
|
1070
|
+
|
1071
|
+
# Returns the top-level domain for this host.
|
1072
|
+
#
|
1073
|
+
# @example
|
1074
|
+
# Addressable::URI.parse("http://www.example.co.uk").tld # => "co.uk"
|
1075
|
+
def tld; end
|
1076
|
+
|
1077
|
+
# Sets the top-level domain for this URI.
|
1078
|
+
#
|
1079
|
+
# @param new_tld [String, #to_str] The new top-level domain.
|
1080
|
+
def tld=(new_tld); end
|
1081
|
+
|
1082
|
+
# Returns a Hash of the URI components.
|
1083
|
+
#
|
1084
|
+
# @return [Hash] The URI as a <code>Hash</code> of components.
|
1085
|
+
def to_hash; end
|
1086
|
+
|
1087
|
+
# Converts the URI to a <code>String</code>.
|
1088
|
+
#
|
1089
|
+
# @return [String] The URI's <code>String</code> representation.
|
1090
|
+
def to_s; end
|
1091
|
+
|
1092
|
+
# Converts the URI to a <code>String</code>.
|
1093
|
+
# URI's are glorified <code>Strings</code>. Allow implicit conversion.
|
1094
|
+
#
|
1095
|
+
# @return [String] The URI's <code>String</code> representation.
|
1096
|
+
def to_str; end
|
1097
|
+
|
1098
|
+
# The user component for this URI.
|
1099
|
+
#
|
1100
|
+
# @return [String] The user component.
|
1101
|
+
def user; end
|
1102
|
+
|
1103
|
+
# Sets the user component for this URI.
|
1104
|
+
#
|
1105
|
+
# @param new_user [String, #to_str] The new user component.
|
1106
|
+
def user=(new_user); end
|
1107
|
+
|
1108
|
+
# The userinfo component for this URI.
|
1109
|
+
# Combines the user and password components.
|
1110
|
+
#
|
1111
|
+
# @return [String] The userinfo component.
|
1112
|
+
def userinfo; end
|
1113
|
+
|
1114
|
+
# Sets the userinfo component for this URI.
|
1115
|
+
#
|
1116
|
+
# @param new_userinfo [String, #to_str] The new userinfo component.
|
1117
|
+
def userinfo=(new_userinfo); end
|
1118
|
+
|
1119
|
+
protected
|
1120
|
+
|
1121
|
+
# Converts the string to be UTF-8 if it is not already UTF-8
|
1122
|
+
#
|
1123
|
+
# @api private
|
1124
|
+
def force_utf8_encoding_if_needed(str); end
|
1125
|
+
|
1126
|
+
# Resets composite values for the entire URI
|
1127
|
+
#
|
1128
|
+
# @api private
|
1129
|
+
def remove_composite_values; end
|
1130
|
+
|
1131
|
+
# Replaces the internal state of self with the specified URI's state.
|
1132
|
+
# Used in destructive operations to avoid massive code repetition.
|
1133
|
+
#
|
1134
|
+
# @param uri [Addressable::URI] The URI to replace <code>self</code> with.
|
1135
|
+
# @return [Addressable::URI] <code>self</code>.
|
1136
|
+
def replace_self(uri); end
|
1137
|
+
|
1138
|
+
# Splits path string with "/" (slash).
|
1139
|
+
# It is considered that there is empty string after last slash when
|
1140
|
+
# path ends with slash.
|
1141
|
+
#
|
1142
|
+
# @param path [String] The path to split.
|
1143
|
+
# @return [Array<String>] An array of parts of path.
|
1144
|
+
def split_path(path); end
|
1145
|
+
|
1146
|
+
# Ensures that the URI is valid.
|
1147
|
+
def validate; end
|
1148
|
+
|
1149
|
+
class << self
|
1150
|
+
# Converts a path to a file scheme URI. If the path supplied is
|
1151
|
+
# relative, it will be returned as a relative URI. If the path supplied
|
1152
|
+
# is actually a non-file URI, it will parse the URI as if it had been
|
1153
|
+
# parsed with <code>Addressable::URI.parse</code>. Handles all of the
|
1154
|
+
# various Microsoft-specific formats for specifying paths.
|
1155
|
+
#
|
1156
|
+
# @example
|
1157
|
+
# base = Addressable::URI.convert_path("/absolute/path/")
|
1158
|
+
# uri = Addressable::URI.convert_path("relative/path")
|
1159
|
+
# (base + uri).to_s
|
1160
|
+
# #=> "file:///absolute/path/relative/path"
|
1161
|
+
#
|
1162
|
+
# Addressable::URI.convert_path(
|
1163
|
+
# "c:\\windows\\My Documents 100%20\\foo.txt"
|
1164
|
+
# ).to_s
|
1165
|
+
# #=> "file:///c:/windows/My%20Documents%20100%20/foo.txt"
|
1166
|
+
#
|
1167
|
+
# Addressable::URI.convert_path("http://example.com/").to_s
|
1168
|
+
# #=> "http://example.com/"
|
1169
|
+
# @param path [String, Addressable::URI, #to_str] Typically a <code>String</code> path to a file or directory, but
|
1170
|
+
# will return a sensible return value if an absolute URI is supplied
|
1171
|
+
# instead.
|
1172
|
+
# @return [Addressable::URI] The parsed file scheme URI or the original URI if some other URI
|
1173
|
+
# scheme was provided.
|
1174
|
+
def convert_path(path); end
|
1175
|
+
|
1176
|
+
# Percent encodes any special characters in the URI.
|
1177
|
+
#
|
1178
|
+
# @param uri [String, Addressable::URI, #to_str] The URI to encode.
|
1179
|
+
# @param return_type [Class] The type of object to return.
|
1180
|
+
# This value may only be set to <code>String</code> or
|
1181
|
+
# <code>Addressable::URI</code>. All other values are invalid. Defaults
|
1182
|
+
# to <code>String</code>.
|
1183
|
+
# @return [String, Addressable::URI] The encoded URI.
|
1184
|
+
# The return type is determined by the <code>return_type</code>
|
1185
|
+
# parameter.
|
1186
|
+
def encode(uri, return_type = T.unsafe(nil)); end
|
1187
|
+
|
1188
|
+
# Percent encodes a URI component.
|
1189
|
+
#
|
1190
|
+
# '9' to be percent encoded. If a <code>Regexp</code> is passed, the
|
1191
|
+
# value <code>/[^b-zB-Z0-9]/</code> would have the same effect. A set of
|
1192
|
+
# useful <code>String</code> values may be found in the
|
1193
|
+
# <code>Addressable::URI::CharacterClasses</code> module. The default
|
1194
|
+
# value is the reserved plus unreserved character classes specified in
|
1195
|
+
# <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>.
|
1196
|
+
#
|
1197
|
+
# @example
|
1198
|
+
# Addressable::URI.encode_component("simple/example", "b-zB-Z0-9")
|
1199
|
+
# => "simple%2Fex%61mple"
|
1200
|
+
# Addressable::URI.encode_component("simple/example", /[^b-zB-Z0-9]/)
|
1201
|
+
# => "simple%2Fex%61mple"
|
1202
|
+
# Addressable::URI.encode_component(
|
1203
|
+
# "simple/example", Addressable::URI::CharacterClasses::UNRESERVED
|
1204
|
+
# )
|
1205
|
+
# => "simple%2Fexample"
|
1206
|
+
# @param component [String, #to_str] The URI component to encode.
|
1207
|
+
# @param character_class [String, Regexp] The characters which are not percent encoded. If a <code>String</code>
|
1208
|
+
# is passed, the <code>String</code> must be formatted as a regular
|
1209
|
+
# expression character class. (Do not include the surrounding square
|
1210
|
+
# brackets.) For example, <code>"b-zB-Z0-9"</code> would cause
|
1211
|
+
# everything but the letters 'b' through 'z' and the numbers '0' through
|
1212
|
+
# @param upcase_encoded [Regexp] A string of characters that may already be percent encoded, and whose
|
1213
|
+
# encodings should be upcased. This allows normalization of percent
|
1214
|
+
# encodings for characters not included in the
|
1215
|
+
# <code>character_class</code>.
|
1216
|
+
# @return [String] The encoded component.
|
1217
|
+
def encode_component(component, character_class = T.unsafe(nil), upcase_encoded = T.unsafe(nil)); end
|
1218
|
+
|
1219
|
+
# Percent encodes any special characters in the URI.
|
1220
|
+
#
|
1221
|
+
# @param uri [String, Addressable::URI, #to_str] The URI to encode.
|
1222
|
+
# @param return_type [Class] The type of object to return.
|
1223
|
+
# This value may only be set to <code>String</code> or
|
1224
|
+
# <code>Addressable::URI</code>. All other values are invalid. Defaults
|
1225
|
+
# to <code>String</code>.
|
1226
|
+
# @return [String, Addressable::URI] The encoded URI.
|
1227
|
+
# The return type is determined by the <code>return_type</code>
|
1228
|
+
# parameter.
|
1229
|
+
def escape(uri, return_type = T.unsafe(nil)); end
|
1230
|
+
|
1231
|
+
# Percent encodes a URI component.
|
1232
|
+
#
|
1233
|
+
# '9' to be percent encoded. If a <code>Regexp</code> is passed, the
|
1234
|
+
# value <code>/[^b-zB-Z0-9]/</code> would have the same effect. A set of
|
1235
|
+
# useful <code>String</code> values may be found in the
|
1236
|
+
# <code>Addressable::URI::CharacterClasses</code> module. The default
|
1237
|
+
# value is the reserved plus unreserved character classes specified in
|
1238
|
+
# <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>.
|
1239
|
+
#
|
1240
|
+
# @example
|
1241
|
+
# Addressable::URI.encode_component("simple/example", "b-zB-Z0-9")
|
1242
|
+
# => "simple%2Fex%61mple"
|
1243
|
+
# Addressable::URI.encode_component("simple/example", /[^b-zB-Z0-9]/)
|
1244
|
+
# => "simple%2Fex%61mple"
|
1245
|
+
# Addressable::URI.encode_component(
|
1246
|
+
# "simple/example", Addressable::URI::CharacterClasses::UNRESERVED
|
1247
|
+
# )
|
1248
|
+
# => "simple%2Fexample"
|
1249
|
+
# @param component [String, #to_str] The URI component to encode.
|
1250
|
+
# @param character_class [String, Regexp] The characters which are not percent encoded. If a <code>String</code>
|
1251
|
+
# is passed, the <code>String</code> must be formatted as a regular
|
1252
|
+
# expression character class. (Do not include the surrounding square
|
1253
|
+
# brackets.) For example, <code>"b-zB-Z0-9"</code> would cause
|
1254
|
+
# everything but the letters 'b' through 'z' and the numbers '0' through
|
1255
|
+
# @param upcase_encoded [Regexp] A string of characters that may already be percent encoded, and whose
|
1256
|
+
# encodings should be upcased. This allows normalization of percent
|
1257
|
+
# encodings for characters not included in the
|
1258
|
+
# <code>character_class</code>.
|
1259
|
+
# @return [String] The encoded component.
|
1260
|
+
def escape_component(component, character_class = T.unsafe(nil), upcase_encoded = T.unsafe(nil)); end
|
1261
|
+
|
1262
|
+
# Encodes a set of key/value pairs according to the rules for the
|
1263
|
+
# <code>application/x-www-form-urlencoded</code> MIME type.
|
1264
|
+
#
|
1265
|
+
# @param form_values [#to_hash, #to_ary] The form values to encode.
|
1266
|
+
# @param sort [TrueClass, FalseClass] Sort the key/value pairs prior to encoding.
|
1267
|
+
# Defaults to <code>false</code>.
|
1268
|
+
# @return [String] The encoded value.
|
1269
|
+
def form_encode(form_values, sort = T.unsafe(nil)); end
|
1270
|
+
|
1271
|
+
# Decodes a <code>String</code> according to the rules for the
|
1272
|
+
# <code>application/x-www-form-urlencoded</code> MIME type.
|
1273
|
+
#
|
1274
|
+
# @param encoded_value [String, #to_str] The form values to decode.
|
1275
|
+
# @return [Array] The decoded values.
|
1276
|
+
# This is not a <code>Hash</code> because of the possibility for
|
1277
|
+
# duplicate keys.
|
1278
|
+
def form_unencode(encoded_value); end
|
1279
|
+
|
1280
|
+
# Converts an input to a URI. The input does not have to be a valid
|
1281
|
+
# URI — the method will use heuristics to guess what URI was intended.
|
1282
|
+
# This is not standards-compliant, merely user-friendly.
|
1283
|
+
#
|
1284
|
+
# @param uri [String, Addressable::URI, #to_str] The URI string to parse.
|
1285
|
+
# No parsing is performed if the object is already an
|
1286
|
+
# <code>Addressable::URI</code>.
|
1287
|
+
# @param hints [Hash] A <code>Hash</code> of hints to the heuristic parser.
|
1288
|
+
# Defaults to <code>{:scheme => "http"}</code>.
|
1289
|
+
# @return [Addressable::URI] The parsed URI.
|
1290
|
+
def heuristic_parse(uri, hints = T.unsafe(nil)); end
|
1291
|
+
|
1292
|
+
# Returns an array of known ip-based schemes. These schemes typically
|
1293
|
+
# use a similar URI form:
|
1294
|
+
# <code>//<user>:<password>@<host>:<port>/<url-path></code>
|
1295
|
+
def ip_based_schemes; end
|
1296
|
+
|
1297
|
+
# Joins several URIs together.
|
1298
|
+
#
|
1299
|
+
# @example
|
1300
|
+
# base = "http://example.com/"
|
1301
|
+
# uri = Addressable::URI.parse("relative/path")
|
1302
|
+
# Addressable::URI.join(base, uri)
|
1303
|
+
# #=> #<Addressable::URI:0xcab390 URI:http://example.com/relative/path>
|
1304
|
+
# @param *uris [String, Addressable::URI, #to_str] The URIs to join.
|
1305
|
+
# @return [Addressable::URI] The joined URI.
|
1306
|
+
def join(*uris); end
|
1307
|
+
|
1308
|
+
# Normalizes the encoding of a URI component.
|
1309
|
+
#
|
1310
|
+
# @example
|
1311
|
+
# Addressable::URI.normalize_component("simpl%65/%65xampl%65", "b-zB-Z")
|
1312
|
+
# => "simple%2Fex%61mple"
|
1313
|
+
# Addressable::URI.normalize_component(
|
1314
|
+
# "simpl%65/%65xampl%65", /[^b-zB-Z]/
|
1315
|
+
# )
|
1316
|
+
# => "simple%2Fex%61mple"
|
1317
|
+
# Addressable::URI.normalize_component(
|
1318
|
+
# "simpl%65/%65xampl%65",
|
1319
|
+
# Addressable::URI::CharacterClasses::UNRESERVED
|
1320
|
+
# )
|
1321
|
+
# => "simple%2Fexample"
|
1322
|
+
# Addressable::URI.normalize_component(
|
1323
|
+
# "one%20two%2fthree%26four",
|
1324
|
+
# "0-9a-zA-Z &/",
|
1325
|
+
# "/"
|
1326
|
+
# )
|
1327
|
+
# => "one two%2Fthree&four"
|
1328
|
+
# @param component [String, #to_str] The URI component to encode.
|
1329
|
+
# @param character_class [String, Regexp] The characters which are not percent encoded. If a <code>String</code>
|
1330
|
+
# is passed, the <code>String</code> must be formatted as a regular
|
1331
|
+
# expression character class. (Do not include the surrounding square
|
1332
|
+
# brackets.) For example, <code>"b-zB-Z0-9"</code> would cause
|
1333
|
+
# everything but the letters 'b' through 'z' and the numbers '0'
|
1334
|
+
# through '9' to be percent encoded. If a <code>Regexp</code> is passed,
|
1335
|
+
# the value <code>/[^b-zB-Z0-9]/</code> would have the same effect. A
|
1336
|
+
# set of useful <code>String</code> values may be found in the
|
1337
|
+
# <code>Addressable::URI::CharacterClasses</code> module. The default
|
1338
|
+
# value is the reserved plus unreserved character classes specified in
|
1339
|
+
# <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>.
|
1340
|
+
# @param leave_encoded [String] When <code>character_class</code> is a <code>String</code> then
|
1341
|
+
# <code>leave_encoded</code> is a string of characters that should remain
|
1342
|
+
# percent encoded while normalizing the component; if they appear percent
|
1343
|
+
# encoded in the original component, then they will be upcased ("%2f"
|
1344
|
+
# normalized to "%2F") but otherwise left alone.
|
1345
|
+
# @return [String] The normalized component.
|
1346
|
+
def normalize_component(component, character_class = T.unsafe(nil), leave_encoded = T.unsafe(nil)); end
|
1347
|
+
|
1348
|
+
# Resolves paths to their simplest form.
|
1349
|
+
#
|
1350
|
+
# @param path [String] The path to normalize.
|
1351
|
+
# @return [String] The normalized path.
|
1352
|
+
def normalize_path(path); end
|
1353
|
+
|
1354
|
+
# Normalizes the encoding of a URI. Characters within a hostname are
|
1355
|
+
# not percent encoded to allow for internationalized domain names.
|
1356
|
+
#
|
1357
|
+
# @param uri [String, Addressable::URI, #to_str] The URI to encode.
|
1358
|
+
# @param return_type [Class] The type of object to return.
|
1359
|
+
# This value may only be set to <code>String</code> or
|
1360
|
+
# <code>Addressable::URI</code>. All other values are invalid. Defaults
|
1361
|
+
# to <code>String</code>.
|
1362
|
+
# @return [String, Addressable::URI] The encoded URI.
|
1363
|
+
# The return type is determined by the <code>return_type</code>
|
1364
|
+
# parameter.
|
1365
|
+
def normalized_encode(uri, return_type = T.unsafe(nil)); end
|
1366
|
+
|
1367
|
+
# Returns a URI object based on the parsed string.
|
1368
|
+
#
|
1369
|
+
# @param uri [String, Addressable::URI, #to_str] The URI string to parse.
|
1370
|
+
# No parsing is performed if the object is already an
|
1371
|
+
# <code>Addressable::URI</code>.
|
1372
|
+
# @return [Addressable::URI] The parsed URI.
|
1373
|
+
def parse(uri); end
|
1374
|
+
|
1375
|
+
# Returns a hash of common IP-based schemes and their default port
|
1376
|
+
# numbers. Adding new schemes to this hash, as necessary, will allow
|
1377
|
+
# for better URI normalization.
|
1378
|
+
def port_mapping; end
|
1379
|
+
|
1380
|
+
# Unencodes any percent encoded characters within a URI component.
|
1381
|
+
# This method may be used for unencoding either components or full URIs,
|
1382
|
+
# however, it is recommended to use the <code>unencode_component</code>
|
1383
|
+
# alias when unencoding components.
|
1384
|
+
#
|
1385
|
+
# @param uri [String, Addressable::URI, #to_str] The URI or component to unencode.
|
1386
|
+
# @param return_type [Class] The type of object to return.
|
1387
|
+
# This value may only be set to <code>String</code> or
|
1388
|
+
# <code>Addressable::URI</code>. All other values are invalid. Defaults
|
1389
|
+
# to <code>String</code>.
|
1390
|
+
# @param leave_encoded [String] A string of characters to leave encoded. If a percent encoded character
|
1391
|
+
# in this list is encountered then it will remain percent encoded.
|
1392
|
+
# @return [String, Addressable::URI] The unencoded component or URI.
|
1393
|
+
# The return type is determined by the <code>return_type</code>
|
1394
|
+
# parameter.
|
1395
|
+
def unencode(uri, return_type = T.unsafe(nil), leave_encoded = T.unsafe(nil)); end
|
1396
|
+
|
1397
|
+
# Unencodes any percent encoded characters within a URI component.
|
1398
|
+
# This method may be used for unencoding either components or full URIs,
|
1399
|
+
# however, it is recommended to use the <code>unencode_component</code>
|
1400
|
+
# alias when unencoding components.
|
1401
|
+
#
|
1402
|
+
# @param uri [String, Addressable::URI, #to_str] The URI or component to unencode.
|
1403
|
+
# @param return_type [Class] The type of object to return.
|
1404
|
+
# This value may only be set to <code>String</code> or
|
1405
|
+
# <code>Addressable::URI</code>. All other values are invalid. Defaults
|
1406
|
+
# to <code>String</code>.
|
1407
|
+
# @param leave_encoded [String] A string of characters to leave encoded. If a percent encoded character
|
1408
|
+
# in this list is encountered then it will remain percent encoded.
|
1409
|
+
# @return [String, Addressable::URI] The unencoded component or URI.
|
1410
|
+
# The return type is determined by the <code>return_type</code>
|
1411
|
+
# parameter.
|
1412
|
+
def unencode_component(uri, return_type = T.unsafe(nil), leave_encoded = T.unsafe(nil)); end
|
1413
|
+
|
1414
|
+
# Unencodes any percent encoded characters within a URI component.
|
1415
|
+
# This method may be used for unencoding either components or full URIs,
|
1416
|
+
# however, it is recommended to use the <code>unencode_component</code>
|
1417
|
+
# alias when unencoding components.
|
1418
|
+
#
|
1419
|
+
# @param uri [String, Addressable::URI, #to_str] The URI or component to unencode.
|
1420
|
+
# @param return_type [Class] The type of object to return.
|
1421
|
+
# This value may only be set to <code>String</code> or
|
1422
|
+
# <code>Addressable::URI</code>. All other values are invalid. Defaults
|
1423
|
+
# to <code>String</code>.
|
1424
|
+
# @param leave_encoded [String] A string of characters to leave encoded. If a percent encoded character
|
1425
|
+
# in this list is encountered then it will remain percent encoded.
|
1426
|
+
# @return [String, Addressable::URI] The unencoded component or URI.
|
1427
|
+
# The return type is determined by the <code>return_type</code>
|
1428
|
+
# parameter.
|
1429
|
+
def unescape(uri, return_type = T.unsafe(nil), leave_encoded = T.unsafe(nil)); end
|
1430
|
+
|
1431
|
+
# Unencodes any percent encoded characters within a URI component.
|
1432
|
+
# This method may be used for unencoding either components or full URIs,
|
1433
|
+
# however, it is recommended to use the <code>unencode_component</code>
|
1434
|
+
# alias when unencoding components.
|
1435
|
+
#
|
1436
|
+
# @param uri [String, Addressable::URI, #to_str] The URI or component to unencode.
|
1437
|
+
# @param return_type [Class] The type of object to return.
|
1438
|
+
# This value may only be set to <code>String</code> or
|
1439
|
+
# <code>Addressable::URI</code>. All other values are invalid. Defaults
|
1440
|
+
# to <code>String</code>.
|
1441
|
+
# @param leave_encoded [String] A string of characters to leave encoded. If a percent encoded character
|
1442
|
+
# in this list is encountered then it will remain percent encoded.
|
1443
|
+
# @return [String, Addressable::URI] The unencoded component or URI.
|
1444
|
+
# The return type is determined by the <code>return_type</code>
|
1445
|
+
# parameter.
|
1446
|
+
def unescape_component(uri, return_type = T.unsafe(nil), leave_encoded = T.unsafe(nil)); end
|
1447
|
+
end
|
1448
|
+
end
|
1449
|
+
|
1450
|
+
# Container for the character classes specified in
|
1451
|
+
# <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>.
|
1452
|
+
#
|
1453
|
+
# Note: Concatenated and interpolated `String`s are not affected by the
|
1454
|
+
# `frozen_string_literal` directive and must be frozen explicitly.
|
1455
|
+
#
|
1456
|
+
# Interpolated `String`s *were* frozen this way before Ruby 3.0:
|
1457
|
+
# https://bugs.ruby-lang.org/issues/17104
|
1458
|
+
module Addressable::URI::CharacterClasses; end
|
1459
|
+
|
1460
|
+
Addressable::URI::CharacterClasses::ALPHA = T.let(T.unsafe(nil), String)
|
1461
|
+
Addressable::URI::CharacterClasses::AUTHORITY = T.let(T.unsafe(nil), String)
|
1462
|
+
Addressable::URI::CharacterClasses::DIGIT = T.let(T.unsafe(nil), String)
|
1463
|
+
Addressable::URI::CharacterClasses::FRAGMENT = T.let(T.unsafe(nil), String)
|
1464
|
+
Addressable::URI::CharacterClasses::GEN_DELIMS = T.let(T.unsafe(nil), String)
|
1465
|
+
Addressable::URI::CharacterClasses::HOST = T.let(T.unsafe(nil), String)
|
1466
|
+
Addressable::URI::CharacterClasses::PATH = T.let(T.unsafe(nil), String)
|
1467
|
+
Addressable::URI::CharacterClasses::PCHAR = T.let(T.unsafe(nil), String)
|
1468
|
+
Addressable::URI::CharacterClasses::QUERY = T.let(T.unsafe(nil), String)
|
1469
|
+
Addressable::URI::CharacterClasses::RESERVED = T.let(T.unsafe(nil), String)
|
1470
|
+
Addressable::URI::CharacterClasses::SCHEME = T.let(T.unsafe(nil), String)
|
1471
|
+
Addressable::URI::CharacterClasses::SUB_DELIMS = T.let(T.unsafe(nil), String)
|
1472
|
+
Addressable::URI::CharacterClasses::UNRESERVED = T.let(T.unsafe(nil), String)
|
1473
|
+
Addressable::URI::EMPTY_STR = T.let(T.unsafe(nil), String)
|
1474
|
+
|
1475
|
+
# Raised if something other than a uri is supplied.
|
1476
|
+
class Addressable::URI::InvalidURIError < ::StandardError; end
|
1477
|
+
|
1478
|
+
Addressable::URI::NORMPATH = T.let(T.unsafe(nil), Regexp)
|
1479
|
+
module Addressable::URI::NormalizeCharacterClasses; end
|
1480
|
+
Addressable::URI::NormalizeCharacterClasses::FRAGMENT = T.let(T.unsafe(nil), Regexp)
|
1481
|
+
Addressable::URI::NormalizeCharacterClasses::HOST = T.let(T.unsafe(nil), Regexp)
|
1482
|
+
Addressable::URI::NormalizeCharacterClasses::PCHAR = T.let(T.unsafe(nil), Regexp)
|
1483
|
+
Addressable::URI::NormalizeCharacterClasses::QUERY = T.let(T.unsafe(nil), Regexp)
|
1484
|
+
Addressable::URI::NormalizeCharacterClasses::SCHEME = T.let(T.unsafe(nil), Regexp)
|
1485
|
+
Addressable::URI::NormalizeCharacterClasses::UNRESERVED = T.let(T.unsafe(nil), Regexp)
|
1486
|
+
Addressable::URI::PARENT = T.let(T.unsafe(nil), String)
|
1487
|
+
Addressable::URI::PORT_MAPPING = T.let(T.unsafe(nil), Hash)
|
1488
|
+
Addressable::URI::RULE_2A = T.let(T.unsafe(nil), Regexp)
|
1489
|
+
Addressable::URI::RULE_2B_2C = T.let(T.unsafe(nil), Regexp)
|
1490
|
+
Addressable::URI::RULE_2D = T.let(T.unsafe(nil), Regexp)
|
1491
|
+
Addressable::URI::RULE_PREFIXED_PARENT = T.let(T.unsafe(nil), Regexp)
|
1492
|
+
Addressable::URI::SELF_REF = T.let(T.unsafe(nil), String)
|
1493
|
+
|
1494
|
+
# Tables used to optimize encoding operations in `self.encode_component`
|
1495
|
+
# and `self.normalize_component`
|
1496
|
+
Addressable::URI::SEQUENCE_ENCODING_TABLE = T.let(T.unsafe(nil), Hash)
|
1497
|
+
|
1498
|
+
Addressable::URI::SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE = T.let(T.unsafe(nil), Hash)
|
1499
|
+
Addressable::URI::SLASH = T.let(T.unsafe(nil), String)
|
1500
|
+
Addressable::URI::URIREGEX = T.let(T.unsafe(nil), Regexp)
|
1501
|
+
module Addressable::VERSION; end
|
1502
|
+
Addressable::VERSION::MAJOR = T.let(T.unsafe(nil), Integer)
|
1503
|
+
Addressable::VERSION::MINOR = T.let(T.unsafe(nil), Integer)
|
1504
|
+
Addressable::VERSION::STRING = T.let(T.unsafe(nil), String)
|
1505
|
+
Addressable::VERSION::TINY = T.let(T.unsafe(nil), Integer)
|