bundler 2.1.0.pre.3 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -3
- data/lib/bundler.rb +0 -1
- data/lib/bundler/build_metadata.rb +2 -2
- data/lib/bundler/cli.rb +1 -1
- data/lib/bundler/cli/config.rb +1 -1
- data/lib/bundler/cli/update.rb +1 -1
- data/lib/bundler/feature_flag.rb +1 -1
- data/lib/bundler/fetcher.rb +2 -2
- data/lib/bundler/fetcher/downloader.rb +1 -1
- data/lib/bundler/fetcher/index.rb +1 -1
- data/lib/bundler/friendly_errors.rb +1 -1
- data/lib/bundler/gem_helper.rb +12 -10
- data/lib/bundler/inline.rb +36 -31
- data/lib/bundler/lazy_specification.rb +0 -1
- data/lib/bundler/mirror.rb +3 -3
- data/lib/bundler/plugin/api/source.rb +2 -4
- data/lib/bundler/remote_specification.rb +0 -2
- data/lib/bundler/rubygems_integration.rb +15 -13
- data/lib/bundler/settings.rb +7 -4
- data/lib/bundler/setup.rb +5 -0
- data/lib/bundler/source/git.rb +5 -5
- data/lib/bundler/source/git/git_proxy.rb +3 -2
- data/lib/bundler/source/rubygems.rb +3 -3
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/uri_credentials_filter.rb +7 -3
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +3 -3
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +26 -26
- data/lib/bundler/vendor/thor/lib/thor.rb +7 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +10 -6
- data/lib/bundler/vendor/thor/lib/thor/base.rb +29 -19
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +13 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +8 -9
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/util.rb +17 -1
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
- data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
- data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
- data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
- data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/bundler/vendored_uri.rb +4 -0
- data/lib/bundler/version.rb +1 -1
- data/man/bundle-add.1 +1 -1
- data/man/bundle-add.1.txt +1 -1
- data/man/bundle-binstubs.1 +1 -1
- data/man/bundle-binstubs.1.txt +1 -1
- data/man/bundle-cache.1 +1 -1
- data/man/bundle-cache.1.txt +1 -1
- data/man/bundle-check.1 +1 -1
- data/man/bundle-check.1.txt +1 -1
- data/man/bundle-clean.1 +1 -1
- data/man/bundle-clean.1.txt +1 -1
- data/man/bundle-config.1 +1 -1
- data/man/bundle-config.1.txt +1 -1
- data/man/bundle-doctor.1 +1 -1
- data/man/bundle-doctor.1.txt +1 -1
- data/man/bundle-exec.1 +1 -1
- data/man/bundle-exec.1.txt +1 -1
- data/man/bundle-gem.1 +1 -1
- data/man/bundle-gem.1.txt +1 -1
- data/man/bundle-info.1 +1 -1
- data/man/bundle-info.1.txt +1 -1
- data/man/bundle-init.1 +1 -1
- data/man/bundle-init.1.txt +1 -1
- data/man/bundle-inject.1 +1 -1
- data/man/bundle-inject.1.txt +1 -1
- data/man/bundle-install.1 +1 -1
- data/man/bundle-install.1.txt +1 -1
- data/man/bundle-list.1 +1 -1
- data/man/bundle-list.1.txt +1 -1
- data/man/bundle-lock.1 +1 -1
- data/man/bundle-lock.1.txt +1 -1
- data/man/bundle-open.1 +1 -1
- data/man/bundle-open.1.txt +1 -1
- data/man/bundle-outdated.1 +1 -1
- data/man/bundle-outdated.1.txt +1 -1
- data/man/bundle-platform.1 +1 -1
- data/man/bundle-platform.1.txt +1 -1
- data/man/bundle-pristine.1 +1 -1
- data/man/bundle-pristine.1.txt +1 -1
- data/man/bundle-remove.1 +1 -1
- data/man/bundle-remove.1.txt +1 -1
- data/man/bundle-show.1 +1 -1
- data/man/bundle-show.1.txt +1 -1
- data/man/bundle-update.1 +1 -1
- data/man/bundle-update.1.txt +1 -1
- data/man/bundle-viz.1 +1 -1
- data/man/bundle-viz.1.txt +1 -1
- data/man/bundle.1 +1 -1
- data/man/bundle.1.txt +1 -1
- data/man/gemfile.5 +1 -1
- data/man/gemfile.5.txt +1 -1
- metadata +18 -6
- data/lib/bundler/gem_remote_fetcher.rb +0 -43
- data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +0 -5
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
@@ -0,0 +1,29 @@
|
|
1
|
+
class Bundler::Thor
|
2
|
+
class NestedContext
|
3
|
+
def initialize
|
4
|
+
@depth = 0
|
5
|
+
end
|
6
|
+
|
7
|
+
def enter
|
8
|
+
push
|
9
|
+
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
pop
|
13
|
+
end
|
14
|
+
|
15
|
+
def entered?
|
16
|
+
@depth > 0
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def push
|
22
|
+
@depth += 1
|
23
|
+
end
|
24
|
+
|
25
|
+
def pop
|
26
|
+
@depth -= 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -112,7 +112,7 @@ class Bundler::Thor
|
|
112
112
|
|
113
113
|
def validate!
|
114
114
|
raise ArgumentError, "An option cannot be boolean and required." if boolean? && required?
|
115
|
-
validate_default_type!
|
115
|
+
validate_default_type!
|
116
116
|
end
|
117
117
|
|
118
118
|
def validate_default_type!
|
@@ -130,7 +130,18 @@ class Bundler::Thor
|
|
130
130
|
end
|
131
131
|
|
132
132
|
expected_type = (@repeatable && @type != :hash) ? :array : @type
|
133
|
-
|
133
|
+
|
134
|
+
if default_type != expected_type
|
135
|
+
err = "Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})"
|
136
|
+
|
137
|
+
if @check_default_type
|
138
|
+
raise ArgumentError, err
|
139
|
+
elsif @check_default_type == nil
|
140
|
+
Bundler::Thor.deprecation_warning "#{err}.\n" +
|
141
|
+
'This will be rejected in the future unless you explicitly pass the options `check_default_type: false`' +
|
142
|
+
' or call `allow_incompatible_default_type!` in your code'
|
143
|
+
end
|
144
|
+
end
|
134
145
|
end
|
135
146
|
|
136
147
|
def dasherized?
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require_relative "../thor"
|
2
2
|
require_relative "group"
|
3
|
-
require_relative "core_ext/io_binary_read"
|
4
3
|
|
5
4
|
require "yaml"
|
6
5
|
require "digest/md5"
|
@@ -67,7 +66,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
67
66
|
raise Error, "Error opening file '#{name}'"
|
68
67
|
end
|
69
68
|
|
70
|
-
say "Your
|
69
|
+
say "Your Thorfile contains:"
|
71
70
|
say contents
|
72
71
|
|
73
72
|
unless options["force"]
|
@@ -206,7 +205,7 @@ private
|
|
206
205
|
File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
|
207
206
|
end
|
208
207
|
|
209
|
-
# Load the
|
208
|
+
# Load the Thorfiles. If relevant_to is supplied, looks for specific files
|
210
209
|
# in the thor_root instead of loading them all.
|
211
210
|
#
|
212
211
|
# By default, it also traverses the current path until find Bundler::Thor files, as
|
@@ -219,11 +218,11 @@ private
|
|
219
218
|
end
|
220
219
|
end
|
221
220
|
|
222
|
-
# Finds
|
221
|
+
# Finds Thorfiles by traversing from your current directory down to the root
|
223
222
|
# directory of your system. If at any time we find a Bundler::Thor file, we stop.
|
224
223
|
#
|
225
|
-
# We also ensure that system-wide
|
226
|
-
#
|
224
|
+
# We also ensure that system-wide Thorfiles are loaded first, so local
|
225
|
+
# Thorfiles can override them.
|
227
226
|
#
|
228
227
|
# ==== Example
|
229
228
|
#
|
@@ -231,7 +230,7 @@ private
|
|
231
230
|
#
|
232
231
|
# 1. /Users/wycats/dev/thor
|
233
232
|
# 2. /Users/wycats/dev
|
234
|
-
# 3. /Users/wycats <-- we find a
|
233
|
+
# 3. /Users/wycats <-- we find a Thorfile here, so we stop
|
235
234
|
#
|
236
235
|
# Suppose we start at c:\Documents and Settings\james\dev\thor ...
|
237
236
|
#
|
@@ -239,7 +238,7 @@ private
|
|
239
238
|
# 2. c:\Documents and Settings\james\dev
|
240
239
|
# 3. c:\Documents and Settings\james
|
241
240
|
# 4. c:\Documents and Settings
|
242
|
-
# 5. c:\ <-- no
|
241
|
+
# 5. c:\ <-- no Thorfiles found!
|
243
242
|
#
|
244
243
|
def thorfiles(relevant_to = nil, skip_lookup = false)
|
245
244
|
thorfiles = []
|
@@ -260,7 +259,7 @@ private
|
|
260
259
|
end
|
261
260
|
end
|
262
261
|
|
263
|
-
# Load
|
262
|
+
# Load Thorfiles relevant to the given method. If you provide "foo:bar" it
|
264
263
|
# will load all thor files in the thor.yaml that has "foo" e "foo:bar"
|
265
264
|
# namespaces registered.
|
266
265
|
#
|
@@ -451,16 +451,25 @@ class Bundler::Thor
|
|
451
451
|
|
452
452
|
def ask_filtered(statement, color, options)
|
453
453
|
answer_set = options[:limited_to]
|
454
|
+
case_insensitive = options.fetch(:case_insensitive, false)
|
454
455
|
correct_answer = nil
|
455
456
|
until correct_answer
|
456
457
|
answers = answer_set.join(", ")
|
457
458
|
answer = ask_simply("#{statement} [#{answers}]", color, options)
|
458
|
-
correct_answer = answer_set
|
459
|
+
correct_answer = answer_match(answer_set, answer, case_insensitive)
|
459
460
|
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
|
460
461
|
end
|
461
462
|
correct_answer
|
462
463
|
end
|
463
464
|
|
465
|
+
def answer_match(possibilities, answer, case_insensitive)
|
466
|
+
if case_insensitive
|
467
|
+
possibilities.detect{ |possibility| possibility.downcase == answer.downcase }
|
468
|
+
else
|
469
|
+
possibilities.detect{ |possibility| possibility == answer }
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
464
473
|
def merge(destination, content) #:nodoc:
|
465
474
|
require "tempfile"
|
466
475
|
Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
|
@@ -51,13 +51,13 @@ class Bundler::Thor
|
|
51
51
|
def set_color(string, *colors)
|
52
52
|
if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
|
53
53
|
html_colors = colors.map { |color| lookup_color(color) }
|
54
|
-
"<span style=\"#{html_colors.join('; ')};\">#{string}</span>"
|
54
|
+
"<span style=\"#{html_colors.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>"
|
55
55
|
else
|
56
56
|
color, bold = colors
|
57
57
|
html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
58
58
|
styles = [html_color]
|
59
59
|
styles << BOLD if bold
|
60
|
-
"<span style=\"#{styles.join('; ')};\">#{string}</span>"
|
60
|
+
"<span style=\"#{styles.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -211,7 +211,7 @@ class Bundler::Thor
|
|
211
211
|
#
|
212
212
|
def globs_for(path)
|
213
213
|
path = escape_globs(path)
|
214
|
-
["#{path}/
|
214
|
+
["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
|
215
215
|
end
|
216
216
|
|
217
217
|
# Return the path to the ruby interpreter taking into account multiple
|
@@ -263,6 +263,22 @@ class Bundler::Thor
|
|
263
263
|
def escape_globs(path)
|
264
264
|
path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
|
265
265
|
end
|
266
|
+
|
267
|
+
# Returns a string that has had any HTML characters escaped.
|
268
|
+
#
|
269
|
+
# ==== Examples
|
270
|
+
#
|
271
|
+
# Bundler::Thor::Util.escape_html('<div>') # => "<div>"
|
272
|
+
#
|
273
|
+
# ==== Parameters
|
274
|
+
# String
|
275
|
+
#
|
276
|
+
# ==== Returns
|
277
|
+
# String
|
278
|
+
#
|
279
|
+
def escape_html(string)
|
280
|
+
CGI.escapeHTML(string)
|
281
|
+
end
|
266
282
|
end
|
267
283
|
end
|
268
284
|
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# Bundler::URI is a module providing classes to handle Uniform Resource Identifiers
|
3
|
+
# (RFC2396[http://tools.ietf.org/html/rfc2396]).
|
4
|
+
#
|
5
|
+
# == Features
|
6
|
+
#
|
7
|
+
# * Uniform way of handling URIs.
|
8
|
+
# * Flexibility to introduce custom Bundler::URI schemes.
|
9
|
+
# * Flexibility to have an alternate Bundler::URI::Parser (or just different patterns
|
10
|
+
# and regexp's).
|
11
|
+
#
|
12
|
+
# == Basic example
|
13
|
+
#
|
14
|
+
# require 'bundler/vendor/uri/lib/uri'
|
15
|
+
#
|
16
|
+
# uri = Bundler::URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
|
17
|
+
# #=> #<Bundler::URI::HTTP http://foo.com/posts?id=30&limit=5#time=1305298413>
|
18
|
+
#
|
19
|
+
# uri.scheme #=> "http"
|
20
|
+
# uri.host #=> "foo.com"
|
21
|
+
# uri.path #=> "/posts"
|
22
|
+
# uri.query #=> "id=30&limit=5"
|
23
|
+
# uri.fragment #=> "time=1305298413"
|
24
|
+
#
|
25
|
+
# uri.to_s #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
|
26
|
+
#
|
27
|
+
# == Adding custom URIs
|
28
|
+
#
|
29
|
+
# module Bundler::URI
|
30
|
+
# class RSYNC < Generic
|
31
|
+
# DEFAULT_PORT = 873
|
32
|
+
# end
|
33
|
+
# @@schemes['RSYNC'] = RSYNC
|
34
|
+
# end
|
35
|
+
# #=> Bundler::URI::RSYNC
|
36
|
+
#
|
37
|
+
# Bundler::URI.scheme_list
|
38
|
+
# #=> {"FILE"=>Bundler::URI::File, "FTP"=>Bundler::URI::FTP, "HTTP"=>Bundler::URI::HTTP,
|
39
|
+
# # "HTTPS"=>Bundler::URI::HTTPS, "LDAP"=>Bundler::URI::LDAP, "LDAPS"=>Bundler::URI::LDAPS,
|
40
|
+
# # "MAILTO"=>Bundler::URI::MailTo, "RSYNC"=>Bundler::URI::RSYNC}
|
41
|
+
#
|
42
|
+
# uri = Bundler::URI("rsync://rsync.foo.com")
|
43
|
+
# #=> #<Bundler::URI::RSYNC rsync://rsync.foo.com>
|
44
|
+
#
|
45
|
+
# == RFC References
|
46
|
+
#
|
47
|
+
# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
|
48
|
+
#
|
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]
|
58
|
+
#
|
59
|
+
# == Class tree
|
60
|
+
#
|
61
|
+
# - Bundler::URI::Generic (in uri/generic.rb)
|
62
|
+
# - Bundler::URI::File - (in uri/file.rb)
|
63
|
+
# - Bundler::URI::FTP - (in uri/ftp.rb)
|
64
|
+
# - Bundler::URI::HTTP - (in uri/http.rb)
|
65
|
+
# - Bundler::URI::HTTPS - (in uri/https.rb)
|
66
|
+
# - Bundler::URI::LDAP - (in uri/ldap.rb)
|
67
|
+
# - Bundler::URI::LDAPS - (in uri/ldaps.rb)
|
68
|
+
# - Bundler::URI::MailTo - (in uri/mailto.rb)
|
69
|
+
# - Bundler::URI::Parser - (in uri/common.rb)
|
70
|
+
# - Bundler::URI::REGEXP - (in uri/common.rb)
|
71
|
+
# - Bundler::URI::REGEXP::PATTERN - (in uri/common.rb)
|
72
|
+
# - Bundler::URI::Util - (in uri/common.rb)
|
73
|
+
# - Bundler::URI::Escape - (in uri/common.rb)
|
74
|
+
# - Bundler::URI::Error - (in uri/common.rb)
|
75
|
+
# - Bundler::URI::InvalidURIError - (in uri/common.rb)
|
76
|
+
# - Bundler::URI::InvalidComponentError - (in uri/common.rb)
|
77
|
+
# - Bundler::URI::BadURIError - (in uri/common.rb)
|
78
|
+
#
|
79
|
+
# == Copyright Info
|
80
|
+
#
|
81
|
+
# Author:: Akira Yamada <akira@ruby-lang.org>
|
82
|
+
# Documentation::
|
83
|
+
# Akira Yamada <akira@ruby-lang.org>
|
84
|
+
# Dmitry V. Sabanin <sdmitry@lrn.ru>
|
85
|
+
# Vincent Batts <vbatts@hashbangbash.com>
|
86
|
+
# License::
|
87
|
+
# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
|
88
|
+
# You can redistribute it and/or modify it under the same term as Ruby.
|
89
|
+
# Revision:: $Id$
|
90
|
+
#
|
91
|
+
|
92
|
+
module Bundler::URI
|
93
|
+
end
|
94
|
+
|
95
|
+
require_relative 'uri/version'
|
96
|
+
require_relative 'uri/common'
|
97
|
+
require_relative 'uri/generic'
|
98
|
+
require_relative 'uri/file'
|
99
|
+
require_relative 'uri/ftp'
|
100
|
+
require_relative 'uri/http'
|
101
|
+
require_relative 'uri/https'
|
102
|
+
require_relative 'uri/ldap'
|
103
|
+
require_relative 'uri/ldaps'
|
104
|
+
require_relative 'uri/mailto'
|
@@ -0,0 +1,744 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#--
|
3
|
+
# = uri/common.rb
|
4
|
+
#
|
5
|
+
# Author:: Akira Yamada <akira@ruby-lang.org>
|
6
|
+
# Revision:: $Id$
|
7
|
+
# License::
|
8
|
+
# You can redistribute it and/or modify it under the same term as Ruby.
|
9
|
+
#
|
10
|
+
# See Bundler::URI for general documentation
|
11
|
+
#
|
12
|
+
|
13
|
+
require_relative "rfc2396_parser"
|
14
|
+
require_relative "rfc3986_parser"
|
15
|
+
|
16
|
+
module Bundler::URI
|
17
|
+
REGEXP = RFC2396_REGEXP
|
18
|
+
Parser = RFC2396_Parser
|
19
|
+
RFC3986_PARSER = RFC3986_Parser.new
|
20
|
+
|
21
|
+
# Bundler::URI::Parser.new
|
22
|
+
DEFAULT_PARSER = Parser.new
|
23
|
+
DEFAULT_PARSER.pattern.each_pair do |sym, str|
|
24
|
+
unless REGEXP::PATTERN.const_defined?(sym)
|
25
|
+
REGEXP::PATTERN.const_set(sym, str)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
DEFAULT_PARSER.regexp.each_pair do |sym, str|
|
29
|
+
const_set(sym, str)
|
30
|
+
end
|
31
|
+
|
32
|
+
module Util # :nodoc:
|
33
|
+
def make_components_hash(klass, array_hash)
|
34
|
+
tmp = {}
|
35
|
+
if array_hash.kind_of?(Array) &&
|
36
|
+
array_hash.size == klass.component.size - 1
|
37
|
+
klass.component[1..-1].each_index do |i|
|
38
|
+
begin
|
39
|
+
tmp[klass.component[i + 1]] = array_hash[i].clone
|
40
|
+
rescue TypeError
|
41
|
+
tmp[klass.component[i + 1]] = array_hash[i]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
elsif array_hash.kind_of?(Hash)
|
46
|
+
array_hash.each do |key, value|
|
47
|
+
begin
|
48
|
+
tmp[key] = value.clone
|
49
|
+
rescue TypeError
|
50
|
+
tmp[key] = value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
else
|
54
|
+
raise ArgumentError,
|
55
|
+
"expected Array of or Hash of components of #{klass} (#{klass.component[1..-1].join(', ')})"
|
56
|
+
end
|
57
|
+
tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase
|
58
|
+
|
59
|
+
return tmp
|
60
|
+
end
|
61
|
+
module_function :make_components_hash
|
62
|
+
end
|
63
|
+
|
64
|
+
# Module for escaping unsafe characters with codes.
|
65
|
+
module Escape
|
66
|
+
#
|
67
|
+
# == Synopsis
|
68
|
+
#
|
69
|
+
# Bundler::URI.escape(str [, unsafe])
|
70
|
+
#
|
71
|
+
# == Args
|
72
|
+
#
|
73
|
+
# +str+::
|
74
|
+
# String to replaces in.
|
75
|
+
# +unsafe+::
|
76
|
+
# Regexp that matches all symbols that must be replaced with codes.
|
77
|
+
# By default uses <tt>UNSAFE</tt>.
|
78
|
+
# When this argument is a String, it represents a character set.
|
79
|
+
#
|
80
|
+
# == Description
|
81
|
+
#
|
82
|
+
# Escapes the string, replacing all unsafe characters with codes.
|
83
|
+
#
|
84
|
+
# This method is obsolete and should not be used. Instead, use
|
85
|
+
# CGI.escape, Bundler::URI.encode_www_form or Bundler::URI.encode_www_form_component
|
86
|
+
# depending on your specific use case.
|
87
|
+
#
|
88
|
+
# == Usage
|
89
|
+
#
|
90
|
+
# require 'bundler/vendor/uri/lib/uri'
|
91
|
+
#
|
92
|
+
# enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
|
93
|
+
# # => "http://example.com/?a=%09%0D"
|
94
|
+
#
|
95
|
+
# Bundler::URI.unescape(enc_uri)
|
96
|
+
# # => "http://example.com/?a=\t\r"
|
97
|
+
#
|
98
|
+
# Bundler::URI.escape("@?@!", "!?")
|
99
|
+
# # => "@%3F@%21"
|
100
|
+
#
|
101
|
+
def escape(*arg)
|
102
|
+
warn "Bundler::URI.escape is obsolete", uplevel: 1
|
103
|
+
DEFAULT_PARSER.escape(*arg)
|
104
|
+
end
|
105
|
+
alias encode escape
|
106
|
+
#
|
107
|
+
# == Synopsis
|
108
|
+
#
|
109
|
+
# Bundler::URI.unescape(str)
|
110
|
+
#
|
111
|
+
# == Args
|
112
|
+
#
|
113
|
+
# +str+::
|
114
|
+
# String to unescape.
|
115
|
+
#
|
116
|
+
# == Description
|
117
|
+
#
|
118
|
+
# This method is obsolete and should not be used. Instead, use
|
119
|
+
# CGI.unescape, Bundler::URI.decode_www_form or Bundler::URI.decode_www_form_component
|
120
|
+
# depending on your specific use case.
|
121
|
+
#
|
122
|
+
# == Usage
|
123
|
+
#
|
124
|
+
# require 'bundler/vendor/uri/lib/uri'
|
125
|
+
#
|
126
|
+
# enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
|
127
|
+
# # => "http://example.com/?a=%09%0D"
|
128
|
+
#
|
129
|
+
# Bundler::URI.unescape(enc_uri)
|
130
|
+
# # => "http://example.com/?a=\t\r"
|
131
|
+
#
|
132
|
+
def unescape(*arg)
|
133
|
+
warn "Bundler::URI.unescape is obsolete", uplevel: 1
|
134
|
+
DEFAULT_PARSER.unescape(*arg)
|
135
|
+
end
|
136
|
+
alias decode unescape
|
137
|
+
end # module Escape
|
138
|
+
|
139
|
+
extend Escape
|
140
|
+
include REGEXP
|
141
|
+
|
142
|
+
@@schemes = {}
|
143
|
+
# Returns a Hash of the defined schemes.
|
144
|
+
def self.scheme_list
|
145
|
+
@@schemes
|
146
|
+
end
|
147
|
+
|
148
|
+
#
|
149
|
+
# Base class for all Bundler::URI exceptions.
|
150
|
+
#
|
151
|
+
class Error < StandardError; end
|
152
|
+
#
|
153
|
+
# Not a Bundler::URI.
|
154
|
+
#
|
155
|
+
class InvalidURIError < Error; end
|
156
|
+
#
|
157
|
+
# Not a Bundler::URI component.
|
158
|
+
#
|
159
|
+
class InvalidComponentError < Error; end
|
160
|
+
#
|
161
|
+
# Bundler::URI is valid, bad usage is not.
|
162
|
+
#
|
163
|
+
class BadURIError < Error; end
|
164
|
+
|
165
|
+
#
|
166
|
+
# == Synopsis
|
167
|
+
#
|
168
|
+
# Bundler::URI::split(uri)
|
169
|
+
#
|
170
|
+
# == Args
|
171
|
+
#
|
172
|
+
# +uri+::
|
173
|
+
# String with Bundler::URI.
|
174
|
+
#
|
175
|
+
# == Description
|
176
|
+
#
|
177
|
+
# Splits the string on following parts and returns array with result:
|
178
|
+
#
|
179
|
+
# * Scheme
|
180
|
+
# * Userinfo
|
181
|
+
# * Host
|
182
|
+
# * Port
|
183
|
+
# * Registry
|
184
|
+
# * Path
|
185
|
+
# * Opaque
|
186
|
+
# * Query
|
187
|
+
# * Fragment
|
188
|
+
#
|
189
|
+
# == Usage
|
190
|
+
#
|
191
|
+
# require 'bundler/vendor/uri/lib/uri'
|
192
|
+
#
|
193
|
+
# Bundler::URI.split("http://www.ruby-lang.org/")
|
194
|
+
# # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
|
195
|
+
#
|
196
|
+
def self.split(uri)
|
197
|
+
RFC3986_PARSER.split(uri)
|
198
|
+
end
|
199
|
+
|
200
|
+
#
|
201
|
+
# == Synopsis
|
202
|
+
#
|
203
|
+
# Bundler::URI::parse(uri_str)
|
204
|
+
#
|
205
|
+
# == Args
|
206
|
+
#
|
207
|
+
# +uri_str+::
|
208
|
+
# String with Bundler::URI.
|
209
|
+
#
|
210
|
+
# == Description
|
211
|
+
#
|
212
|
+
# Creates one of the Bundler::URI's subclasses instance from the string.
|
213
|
+
#
|
214
|
+
# == Raises
|
215
|
+
#
|
216
|
+
# Bundler::URI::InvalidURIError::
|
217
|
+
# Raised if Bundler::URI given is not a correct one.
|
218
|
+
#
|
219
|
+
# == Usage
|
220
|
+
#
|
221
|
+
# require 'bundler/vendor/uri/lib/uri'
|
222
|
+
#
|
223
|
+
# uri = Bundler::URI.parse("http://www.ruby-lang.org/")
|
224
|
+
# # => #<Bundler::URI::HTTP http://www.ruby-lang.org/>
|
225
|
+
# uri.scheme
|
226
|
+
# # => "http"
|
227
|
+
# uri.host
|
228
|
+
# # => "www.ruby-lang.org"
|
229
|
+
#
|
230
|
+
# It's recommended to first ::escape the provided +uri_str+ if there are any
|
231
|
+
# invalid Bundler::URI characters.
|
232
|
+
#
|
233
|
+
def self.parse(uri)
|
234
|
+
RFC3986_PARSER.parse(uri)
|
235
|
+
end
|
236
|
+
|
237
|
+
#
|
238
|
+
# == Synopsis
|
239
|
+
#
|
240
|
+
# Bundler::URI::join(str[, str, ...])
|
241
|
+
#
|
242
|
+
# == Args
|
243
|
+
#
|
244
|
+
# +str+::
|
245
|
+
# String(s) to work with, will be converted to RFC3986 URIs before merging.
|
246
|
+
#
|
247
|
+
# == Description
|
248
|
+
#
|
249
|
+
# Joins URIs.
|
250
|
+
#
|
251
|
+
# == Usage
|
252
|
+
#
|
253
|
+
# require 'bundler/vendor/uri/lib/uri'
|
254
|
+
#
|
255
|
+
# Bundler::URI.join("http://example.com/","main.rbx")
|
256
|
+
# # => #<Bundler::URI::HTTP http://example.com/main.rbx>
|
257
|
+
#
|
258
|
+
# Bundler::URI.join('http://example.com', 'foo')
|
259
|
+
# # => #<Bundler::URI::HTTP http://example.com/foo>
|
260
|
+
#
|
261
|
+
# Bundler::URI.join('http://example.com', '/foo', '/bar')
|
262
|
+
# # => #<Bundler::URI::HTTP http://example.com/bar>
|
263
|
+
#
|
264
|
+
# Bundler::URI.join('http://example.com', '/foo', 'bar')
|
265
|
+
# # => #<Bundler::URI::HTTP http://example.com/bar>
|
266
|
+
#
|
267
|
+
# Bundler::URI.join('http://example.com', '/foo/', 'bar')
|
268
|
+
# # => #<Bundler::URI::HTTP http://example.com/foo/bar>
|
269
|
+
#
|
270
|
+
def self.join(*str)
|
271
|
+
RFC3986_PARSER.join(*str)
|
272
|
+
end
|
273
|
+
|
274
|
+
#
|
275
|
+
# == Synopsis
|
276
|
+
#
|
277
|
+
# Bundler::URI::extract(str[, schemes][,&blk])
|
278
|
+
#
|
279
|
+
# == Args
|
280
|
+
#
|
281
|
+
# +str+::
|
282
|
+
# String to extract URIs from.
|
283
|
+
# +schemes+::
|
284
|
+
# Limit Bundler::URI matching to specific schemes.
|
285
|
+
#
|
286
|
+
# == Description
|
287
|
+
#
|
288
|
+
# Extracts URIs from a string. If block given, iterates through all matched URIs.
|
289
|
+
# Returns nil if block given or array with matches.
|
290
|
+
#
|
291
|
+
# == Usage
|
292
|
+
#
|
293
|
+
# require "bundler/vendor/uri/lib/uri"
|
294
|
+
#
|
295
|
+
# Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
|
296
|
+
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
|
297
|
+
#
|
298
|
+
def self.extract(str, schemes = nil, &block)
|
299
|
+
warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
|
300
|
+
DEFAULT_PARSER.extract(str, schemes, &block)
|
301
|
+
end
|
302
|
+
|
303
|
+
#
|
304
|
+
# == Synopsis
|
305
|
+
#
|
306
|
+
# Bundler::URI::regexp([match_schemes])
|
307
|
+
#
|
308
|
+
# == Args
|
309
|
+
#
|
310
|
+
# +match_schemes+::
|
311
|
+
# Array of schemes. If given, resulting regexp matches to URIs
|
312
|
+
# whose scheme is one of the match_schemes.
|
313
|
+
#
|
314
|
+
# == Description
|
315
|
+
#
|
316
|
+
# Returns a Regexp object which matches to Bundler::URI-like strings.
|
317
|
+
# The Regexp object returned by this method includes arbitrary
|
318
|
+
# number of capture group (parentheses). Never rely on it's number.
|
319
|
+
#
|
320
|
+
# == Usage
|
321
|
+
#
|
322
|
+
# require 'bundler/vendor/uri/lib/uri'
|
323
|
+
#
|
324
|
+
# # extract first Bundler::URI from html_string
|
325
|
+
# html_string.slice(Bundler::URI.regexp)
|
326
|
+
#
|
327
|
+
# # remove ftp URIs
|
328
|
+
# html_string.sub(Bundler::URI.regexp(['ftp']), '')
|
329
|
+
#
|
330
|
+
# # You should not rely on the number of parentheses
|
331
|
+
# html_string.scan(Bundler::URI.regexp) do |*matches|
|
332
|
+
# p $&
|
333
|
+
# end
|
334
|
+
#
|
335
|
+
def self.regexp(schemes = nil)
|
336
|
+
warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
|
337
|
+
DEFAULT_PARSER.make_regexp(schemes)
|
338
|
+
end
|
339
|
+
|
340
|
+
TBLENCWWWCOMP_ = {} # :nodoc:
|
341
|
+
256.times do |i|
|
342
|
+
TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
|
343
|
+
end
|
344
|
+
TBLENCWWWCOMP_[' '] = '+'
|
345
|
+
TBLENCWWWCOMP_.freeze
|
346
|
+
TBLDECWWWCOMP_ = {} # :nodoc:
|
347
|
+
256.times do |i|
|
348
|
+
h, l = i>>4, i&15
|
349
|
+
TBLDECWWWCOMP_[-('%%%X%X' % [h, l])] = -i.chr
|
350
|
+
TBLDECWWWCOMP_[-('%%%x%X' % [h, l])] = -i.chr
|
351
|
+
TBLDECWWWCOMP_[-('%%%X%x' % [h, l])] = -i.chr
|
352
|
+
TBLDECWWWCOMP_[-('%%%x%x' % [h, l])] = -i.chr
|
353
|
+
end
|
354
|
+
TBLDECWWWCOMP_['+'] = ' '
|
355
|
+
TBLDECWWWCOMP_.freeze
|
356
|
+
|
357
|
+
# Encodes given +str+ to URL-encoded form data.
|
358
|
+
#
|
359
|
+
# This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
|
360
|
+
# (ASCII space) to + and converts others to %XX.
|
361
|
+
#
|
362
|
+
# If +enc+ is given, convert +str+ to the encoding before percent encoding.
|
363
|
+
#
|
364
|
+
# This is an implementation of
|
365
|
+
# http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
|
366
|
+
#
|
367
|
+
# See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
|
368
|
+
def self.encode_www_form_component(str, enc=nil)
|
369
|
+
str = str.to_s.dup
|
370
|
+
if str.encoding != Encoding::ASCII_8BIT
|
371
|
+
if enc && enc != Encoding::ASCII_8BIT
|
372
|
+
str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
|
373
|
+
str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
|
374
|
+
end
|
375
|
+
str.force_encoding(Encoding::ASCII_8BIT)
|
376
|
+
end
|
377
|
+
str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
|
378
|
+
str.force_encoding(Encoding::US_ASCII)
|
379
|
+
end
|
380
|
+
|
381
|
+
# Decodes given +str+ of URL-encoded form data.
|
382
|
+
#
|
383
|
+
# This decodes + to SP.
|
384
|
+
#
|
385
|
+
# See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
|
386
|
+
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
387
|
+
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
|
388
|
+
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
|
389
|
+
end
|
390
|
+
|
391
|
+
# Generates URL-encoded form data from given +enum+.
|
392
|
+
#
|
393
|
+
# This generates application/x-www-form-urlencoded data defined in HTML5
|
394
|
+
# from given an Enumerable object.
|
395
|
+
#
|
396
|
+
# This internally uses Bundler::URI.encode_www_form_component(str).
|
397
|
+
#
|
398
|
+
# This method doesn't convert the encoding of given items, so convert them
|
399
|
+
# before calling this method if you want to send data as other than original
|
400
|
+
# encoding or mixed encoding data. (Strings which are encoded in an HTML5
|
401
|
+
# ASCII incompatible encoding are converted to UTF-8.)
|
402
|
+
#
|
403
|
+
# This method doesn't handle files. When you send a file, use
|
404
|
+
# multipart/form-data.
|
405
|
+
#
|
406
|
+
# This refers http://url.spec.whatwg.org/#concept-urlencoded-serializer
|
407
|
+
#
|
408
|
+
# Bundler::URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
|
409
|
+
# #=> "q=ruby&lang=en"
|
410
|
+
# Bundler::URI.encode_www_form("q" => "ruby", "lang" => "en")
|
411
|
+
# #=> "q=ruby&lang=en"
|
412
|
+
# Bundler::URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
|
413
|
+
# #=> "q=ruby&q=perl&lang=en"
|
414
|
+
# Bundler::URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
|
415
|
+
# #=> "q=ruby&q=perl&lang=en"
|
416
|
+
#
|
417
|
+
# See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
|
418
|
+
def self.encode_www_form(enum, enc=nil)
|
419
|
+
enum.map do |k,v|
|
420
|
+
if v.nil?
|
421
|
+
encode_www_form_component(k, enc)
|
422
|
+
elsif v.respond_to?(:to_ary)
|
423
|
+
v.to_ary.map do |w|
|
424
|
+
str = encode_www_form_component(k, enc)
|
425
|
+
unless w.nil?
|
426
|
+
str << '='
|
427
|
+
str << encode_www_form_component(w, enc)
|
428
|
+
end
|
429
|
+
end.join('&')
|
430
|
+
else
|
431
|
+
str = encode_www_form_component(k, enc)
|
432
|
+
str << '='
|
433
|
+
str << encode_www_form_component(v, enc)
|
434
|
+
end
|
435
|
+
end.join('&')
|
436
|
+
end
|
437
|
+
|
438
|
+
# Decodes URL-encoded form data from given +str+.
|
439
|
+
#
|
440
|
+
# This decodes application/x-www-form-urlencoded data
|
441
|
+
# and returns an array of key-value arrays.
|
442
|
+
#
|
443
|
+
# This refers http://url.spec.whatwg.org/#concept-urlencoded-parser,
|
444
|
+
# so this supports only &-separator, and doesn't support ;-separator.
|
445
|
+
#
|
446
|
+
# ary = Bundler::URI.decode_www_form("a=1&a=2&b=3")
|
447
|
+
# ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
|
448
|
+
# ary.assoc('a').last #=> '1'
|
449
|
+
# ary.assoc('b').last #=> '3'
|
450
|
+
# ary.rassoc('a').last #=> '2'
|
451
|
+
# Hash[ary] #=> {"a"=>"2", "b"=>"3"}
|
452
|
+
#
|
453
|
+
# See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
|
454
|
+
def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
|
455
|
+
raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
|
456
|
+
ary = []
|
457
|
+
return ary if str.empty?
|
458
|
+
enc = Encoding.find(enc)
|
459
|
+
str.b.each_line(separator) do |string|
|
460
|
+
string.chomp!(separator)
|
461
|
+
key, sep, val = string.partition('=')
|
462
|
+
if isindex
|
463
|
+
if sep.empty?
|
464
|
+
val = key
|
465
|
+
key = +''
|
466
|
+
end
|
467
|
+
isindex = false
|
468
|
+
end
|
469
|
+
|
470
|
+
if use__charset_ and key == '_charset_' and e = get_encoding(val)
|
471
|
+
enc = e
|
472
|
+
use__charset_ = false
|
473
|
+
end
|
474
|
+
|
475
|
+
key.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
|
476
|
+
if val
|
477
|
+
val.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
|
478
|
+
else
|
479
|
+
val = +''
|
480
|
+
end
|
481
|
+
|
482
|
+
ary << [key, val]
|
483
|
+
end
|
484
|
+
ary.each do |k, v|
|
485
|
+
k.force_encoding(enc)
|
486
|
+
k.scrub!
|
487
|
+
v.force_encoding(enc)
|
488
|
+
v.scrub!
|
489
|
+
end
|
490
|
+
ary
|
491
|
+
end
|
492
|
+
|
493
|
+
private
|
494
|
+
=begin command for WEB_ENCODINGS_
|
495
|
+
curl https://encoding.spec.whatwg.org/encodings.json|
|
496
|
+
ruby -rjson -e 'H={}
|
497
|
+
h={
|
498
|
+
"shift_jis"=>"Windows-31J",
|
499
|
+
"euc-jp"=>"cp51932",
|
500
|
+
"iso-2022-jp"=>"cp50221",
|
501
|
+
"x-mac-cyrillic"=>"macCyrillic",
|
502
|
+
}
|
503
|
+
JSON($<.read).map{|x|x["encodings"]}.flatten.each{|x|
|
504
|
+
Encoding.find(n=h.fetch(n=x["name"].downcase,n))rescue next
|
505
|
+
x["labels"].each{|y|H[y]=n}
|
506
|
+
}
|
507
|
+
puts "{"
|
508
|
+
H.each{|k,v|puts %[ #{k.dump}=>#{v.dump},]}
|
509
|
+
puts "}"
|
510
|
+
'
|
511
|
+
=end
|
512
|
+
WEB_ENCODINGS_ = {
|
513
|
+
"unicode-1-1-utf-8"=>"utf-8",
|
514
|
+
"utf-8"=>"utf-8",
|
515
|
+
"utf8"=>"utf-8",
|
516
|
+
"866"=>"ibm866",
|
517
|
+
"cp866"=>"ibm866",
|
518
|
+
"csibm866"=>"ibm866",
|
519
|
+
"ibm866"=>"ibm866",
|
520
|
+
"csisolatin2"=>"iso-8859-2",
|
521
|
+
"iso-8859-2"=>"iso-8859-2",
|
522
|
+
"iso-ir-101"=>"iso-8859-2",
|
523
|
+
"iso8859-2"=>"iso-8859-2",
|
524
|
+
"iso88592"=>"iso-8859-2",
|
525
|
+
"iso_8859-2"=>"iso-8859-2",
|
526
|
+
"iso_8859-2:1987"=>"iso-8859-2",
|
527
|
+
"l2"=>"iso-8859-2",
|
528
|
+
"latin2"=>"iso-8859-2",
|
529
|
+
"csisolatin3"=>"iso-8859-3",
|
530
|
+
"iso-8859-3"=>"iso-8859-3",
|
531
|
+
"iso-ir-109"=>"iso-8859-3",
|
532
|
+
"iso8859-3"=>"iso-8859-3",
|
533
|
+
"iso88593"=>"iso-8859-3",
|
534
|
+
"iso_8859-3"=>"iso-8859-3",
|
535
|
+
"iso_8859-3:1988"=>"iso-8859-3",
|
536
|
+
"l3"=>"iso-8859-3",
|
537
|
+
"latin3"=>"iso-8859-3",
|
538
|
+
"csisolatin4"=>"iso-8859-4",
|
539
|
+
"iso-8859-4"=>"iso-8859-4",
|
540
|
+
"iso-ir-110"=>"iso-8859-4",
|
541
|
+
"iso8859-4"=>"iso-8859-4",
|
542
|
+
"iso88594"=>"iso-8859-4",
|
543
|
+
"iso_8859-4"=>"iso-8859-4",
|
544
|
+
"iso_8859-4:1988"=>"iso-8859-4",
|
545
|
+
"l4"=>"iso-8859-4",
|
546
|
+
"latin4"=>"iso-8859-4",
|
547
|
+
"csisolatincyrillic"=>"iso-8859-5",
|
548
|
+
"cyrillic"=>"iso-8859-5",
|
549
|
+
"iso-8859-5"=>"iso-8859-5",
|
550
|
+
"iso-ir-144"=>"iso-8859-5",
|
551
|
+
"iso8859-5"=>"iso-8859-5",
|
552
|
+
"iso88595"=>"iso-8859-5",
|
553
|
+
"iso_8859-5"=>"iso-8859-5",
|
554
|
+
"iso_8859-5:1988"=>"iso-8859-5",
|
555
|
+
"arabic"=>"iso-8859-6",
|
556
|
+
"asmo-708"=>"iso-8859-6",
|
557
|
+
"csiso88596e"=>"iso-8859-6",
|
558
|
+
"csiso88596i"=>"iso-8859-6",
|
559
|
+
"csisolatinarabic"=>"iso-8859-6",
|
560
|
+
"ecma-114"=>"iso-8859-6",
|
561
|
+
"iso-8859-6"=>"iso-8859-6",
|
562
|
+
"iso-8859-6-e"=>"iso-8859-6",
|
563
|
+
"iso-8859-6-i"=>"iso-8859-6",
|
564
|
+
"iso-ir-127"=>"iso-8859-6",
|
565
|
+
"iso8859-6"=>"iso-8859-6",
|
566
|
+
"iso88596"=>"iso-8859-6",
|
567
|
+
"iso_8859-6"=>"iso-8859-6",
|
568
|
+
"iso_8859-6:1987"=>"iso-8859-6",
|
569
|
+
"csisolatingreek"=>"iso-8859-7",
|
570
|
+
"ecma-118"=>"iso-8859-7",
|
571
|
+
"elot_928"=>"iso-8859-7",
|
572
|
+
"greek"=>"iso-8859-7",
|
573
|
+
"greek8"=>"iso-8859-7",
|
574
|
+
"iso-8859-7"=>"iso-8859-7",
|
575
|
+
"iso-ir-126"=>"iso-8859-7",
|
576
|
+
"iso8859-7"=>"iso-8859-7",
|
577
|
+
"iso88597"=>"iso-8859-7",
|
578
|
+
"iso_8859-7"=>"iso-8859-7",
|
579
|
+
"iso_8859-7:1987"=>"iso-8859-7",
|
580
|
+
"sun_eu_greek"=>"iso-8859-7",
|
581
|
+
"csiso88598e"=>"iso-8859-8",
|
582
|
+
"csisolatinhebrew"=>"iso-8859-8",
|
583
|
+
"hebrew"=>"iso-8859-8",
|
584
|
+
"iso-8859-8"=>"iso-8859-8",
|
585
|
+
"iso-8859-8-e"=>"iso-8859-8",
|
586
|
+
"iso-ir-138"=>"iso-8859-8",
|
587
|
+
"iso8859-8"=>"iso-8859-8",
|
588
|
+
"iso88598"=>"iso-8859-8",
|
589
|
+
"iso_8859-8"=>"iso-8859-8",
|
590
|
+
"iso_8859-8:1988"=>"iso-8859-8",
|
591
|
+
"visual"=>"iso-8859-8",
|
592
|
+
"csisolatin6"=>"iso-8859-10",
|
593
|
+
"iso-8859-10"=>"iso-8859-10",
|
594
|
+
"iso-ir-157"=>"iso-8859-10",
|
595
|
+
"iso8859-10"=>"iso-8859-10",
|
596
|
+
"iso885910"=>"iso-8859-10",
|
597
|
+
"l6"=>"iso-8859-10",
|
598
|
+
"latin6"=>"iso-8859-10",
|
599
|
+
"iso-8859-13"=>"iso-8859-13",
|
600
|
+
"iso8859-13"=>"iso-8859-13",
|
601
|
+
"iso885913"=>"iso-8859-13",
|
602
|
+
"iso-8859-14"=>"iso-8859-14",
|
603
|
+
"iso8859-14"=>"iso-8859-14",
|
604
|
+
"iso885914"=>"iso-8859-14",
|
605
|
+
"csisolatin9"=>"iso-8859-15",
|
606
|
+
"iso-8859-15"=>"iso-8859-15",
|
607
|
+
"iso8859-15"=>"iso-8859-15",
|
608
|
+
"iso885915"=>"iso-8859-15",
|
609
|
+
"iso_8859-15"=>"iso-8859-15",
|
610
|
+
"l9"=>"iso-8859-15",
|
611
|
+
"iso-8859-16"=>"iso-8859-16",
|
612
|
+
"cskoi8r"=>"koi8-r",
|
613
|
+
"koi"=>"koi8-r",
|
614
|
+
"koi8"=>"koi8-r",
|
615
|
+
"koi8-r"=>"koi8-r",
|
616
|
+
"koi8_r"=>"koi8-r",
|
617
|
+
"koi8-ru"=>"koi8-u",
|
618
|
+
"koi8-u"=>"koi8-u",
|
619
|
+
"dos-874"=>"windows-874",
|
620
|
+
"iso-8859-11"=>"windows-874",
|
621
|
+
"iso8859-11"=>"windows-874",
|
622
|
+
"iso885911"=>"windows-874",
|
623
|
+
"tis-620"=>"windows-874",
|
624
|
+
"windows-874"=>"windows-874",
|
625
|
+
"cp1250"=>"windows-1250",
|
626
|
+
"windows-1250"=>"windows-1250",
|
627
|
+
"x-cp1250"=>"windows-1250",
|
628
|
+
"cp1251"=>"windows-1251",
|
629
|
+
"windows-1251"=>"windows-1251",
|
630
|
+
"x-cp1251"=>"windows-1251",
|
631
|
+
"ansi_x3.4-1968"=>"windows-1252",
|
632
|
+
"ascii"=>"windows-1252",
|
633
|
+
"cp1252"=>"windows-1252",
|
634
|
+
"cp819"=>"windows-1252",
|
635
|
+
"csisolatin1"=>"windows-1252",
|
636
|
+
"ibm819"=>"windows-1252",
|
637
|
+
"iso-8859-1"=>"windows-1252",
|
638
|
+
"iso-ir-100"=>"windows-1252",
|
639
|
+
"iso8859-1"=>"windows-1252",
|
640
|
+
"iso88591"=>"windows-1252",
|
641
|
+
"iso_8859-1"=>"windows-1252",
|
642
|
+
"iso_8859-1:1987"=>"windows-1252",
|
643
|
+
"l1"=>"windows-1252",
|
644
|
+
"latin1"=>"windows-1252",
|
645
|
+
"us-ascii"=>"windows-1252",
|
646
|
+
"windows-1252"=>"windows-1252",
|
647
|
+
"x-cp1252"=>"windows-1252",
|
648
|
+
"cp1253"=>"windows-1253",
|
649
|
+
"windows-1253"=>"windows-1253",
|
650
|
+
"x-cp1253"=>"windows-1253",
|
651
|
+
"cp1254"=>"windows-1254",
|
652
|
+
"csisolatin5"=>"windows-1254",
|
653
|
+
"iso-8859-9"=>"windows-1254",
|
654
|
+
"iso-ir-148"=>"windows-1254",
|
655
|
+
"iso8859-9"=>"windows-1254",
|
656
|
+
"iso88599"=>"windows-1254",
|
657
|
+
"iso_8859-9"=>"windows-1254",
|
658
|
+
"iso_8859-9:1989"=>"windows-1254",
|
659
|
+
"l5"=>"windows-1254",
|
660
|
+
"latin5"=>"windows-1254",
|
661
|
+
"windows-1254"=>"windows-1254",
|
662
|
+
"x-cp1254"=>"windows-1254",
|
663
|
+
"cp1255"=>"windows-1255",
|
664
|
+
"windows-1255"=>"windows-1255",
|
665
|
+
"x-cp1255"=>"windows-1255",
|
666
|
+
"cp1256"=>"windows-1256",
|
667
|
+
"windows-1256"=>"windows-1256",
|
668
|
+
"x-cp1256"=>"windows-1256",
|
669
|
+
"cp1257"=>"windows-1257",
|
670
|
+
"windows-1257"=>"windows-1257",
|
671
|
+
"x-cp1257"=>"windows-1257",
|
672
|
+
"cp1258"=>"windows-1258",
|
673
|
+
"windows-1258"=>"windows-1258",
|
674
|
+
"x-cp1258"=>"windows-1258",
|
675
|
+
"x-mac-cyrillic"=>"macCyrillic",
|
676
|
+
"x-mac-ukrainian"=>"macCyrillic",
|
677
|
+
"chinese"=>"gbk",
|
678
|
+
"csgb2312"=>"gbk",
|
679
|
+
"csiso58gb231280"=>"gbk",
|
680
|
+
"gb2312"=>"gbk",
|
681
|
+
"gb_2312"=>"gbk",
|
682
|
+
"gb_2312-80"=>"gbk",
|
683
|
+
"gbk"=>"gbk",
|
684
|
+
"iso-ir-58"=>"gbk",
|
685
|
+
"x-gbk"=>"gbk",
|
686
|
+
"gb18030"=>"gb18030",
|
687
|
+
"big5"=>"big5",
|
688
|
+
"big5-hkscs"=>"big5",
|
689
|
+
"cn-big5"=>"big5",
|
690
|
+
"csbig5"=>"big5",
|
691
|
+
"x-x-big5"=>"big5",
|
692
|
+
"cseucpkdfmtjapanese"=>"cp51932",
|
693
|
+
"euc-jp"=>"cp51932",
|
694
|
+
"x-euc-jp"=>"cp51932",
|
695
|
+
"csiso2022jp"=>"cp50221",
|
696
|
+
"iso-2022-jp"=>"cp50221",
|
697
|
+
"csshiftjis"=>"Windows-31J",
|
698
|
+
"ms932"=>"Windows-31J",
|
699
|
+
"ms_kanji"=>"Windows-31J",
|
700
|
+
"shift-jis"=>"Windows-31J",
|
701
|
+
"shift_jis"=>"Windows-31J",
|
702
|
+
"sjis"=>"Windows-31J",
|
703
|
+
"windows-31j"=>"Windows-31J",
|
704
|
+
"x-sjis"=>"Windows-31J",
|
705
|
+
"cseuckr"=>"euc-kr",
|
706
|
+
"csksc56011987"=>"euc-kr",
|
707
|
+
"euc-kr"=>"euc-kr",
|
708
|
+
"iso-ir-149"=>"euc-kr",
|
709
|
+
"korean"=>"euc-kr",
|
710
|
+
"ks_c_5601-1987"=>"euc-kr",
|
711
|
+
"ks_c_5601-1989"=>"euc-kr",
|
712
|
+
"ksc5601"=>"euc-kr",
|
713
|
+
"ksc_5601"=>"euc-kr",
|
714
|
+
"windows-949"=>"euc-kr",
|
715
|
+
"utf-16be"=>"utf-16be",
|
716
|
+
"utf-16"=>"utf-16le",
|
717
|
+
"utf-16le"=>"utf-16le",
|
718
|
+
} # :nodoc:
|
719
|
+
|
720
|
+
# :nodoc:
|
721
|
+
# return encoding or nil
|
722
|
+
# http://encoding.spec.whatwg.org/#concept-encoding-get
|
723
|
+
def self.get_encoding(label)
|
724
|
+
Encoding.find(WEB_ENCODINGS_[label.to_str.strip.downcase]) rescue nil
|
725
|
+
end
|
726
|
+
end # module Bundler::URI
|
727
|
+
|
728
|
+
module Bundler
|
729
|
+
|
730
|
+
#
|
731
|
+
# Returns +uri+ converted to an Bundler::URI object.
|
732
|
+
#
|
733
|
+
def URI(uri)
|
734
|
+
if uri.is_a?(Bundler::URI::Generic)
|
735
|
+
uri
|
736
|
+
elsif uri = String.try_convert(uri)
|
737
|
+
Bundler::URI.parse(uri)
|
738
|
+
else
|
739
|
+
raise ArgumentError,
|
740
|
+
"bad argument (expected Bundler::URI object or Bundler::URI string)"
|
741
|
+
end
|
742
|
+
end
|
743
|
+
module_function :URI
|
744
|
+
end
|