rubygems-update 3.5.5 → 3.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +107 -0
- data/Manifest.txt +84 -64
- data/POLICIES.md +75 -6
- data/bundler/CHANGELOG.md +75 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/binstubs.rb +1 -1
- data/bundler/lib/bundler/cli/gem.rb +1 -1
- data/bundler/lib/bundler/cli/lock.rb +5 -4
- data/bundler/lib/bundler/cli/plugin.rb +3 -2
- data/bundler/lib/bundler/cli.rb +7 -24
- data/bundler/lib/bundler/definition.rb +111 -56
- data/bundler/lib/bundler/dependency.rb +2 -1
- data/bundler/lib/bundler/dsl.rb +16 -1
- data/bundler/lib/bundler/environment_preserver.rb +5 -23
- data/bundler/lib/bundler/fetcher/downloader.rb +1 -1
- data/bundler/lib/bundler/fetcher.rb +2 -2
- data/bundler/lib/bundler/gem_version_promoter.rb +42 -38
- data/bundler/lib/bundler/injector.rb +3 -2
- data/bundler/lib/bundler/installer.rb +2 -2
- data/bundler/lib/bundler/man/bundle-add.1 +1 -1
- data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
- data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
- data/bundler/lib/bundler/man/bundle-check.1 +3 -1
- data/bundler/lib/bundler/man/bundle-check.1.ronn +3 -0
- data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
- data/bundler/lib/bundler/man/bundle-config.1 +1 -3
- data/bundler/lib/bundler/man/bundle-config.1.ronn +0 -3
- data/bundler/lib/bundler/man/bundle-console.1 +1 -1
- data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
- data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
- data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
- data/bundler/lib/bundler/man/bundle-help.1 +1 -1
- data/bundler/lib/bundler/man/bundle-info.1 +1 -1
- data/bundler/lib/bundler/man/bundle-init.1 +1 -1
- data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
- data/bundler/lib/bundler/man/bundle-install.1 +3 -3
- data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
- data/bundler/lib/bundler/man/bundle-list.1 +1 -1
- data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
- data/bundler/lib/bundler/man/bundle-open.1 +1 -1
- data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
- data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
- data/bundler/lib/bundler/man/bundle-plugin.1 +7 -4
- data/bundler/lib/bundler/man/bundle-plugin.1.ronn +7 -3
- data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
- data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
- data/bundler/lib/bundler/man/bundle-show.1 +1 -1
- data/bundler/lib/bundler/man/bundle-update.1 +1 -1
- data/bundler/lib/bundler/man/bundle-version.1 +1 -1
- data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
- data/bundler/lib/bundler/man/bundle.1 +1 -1
- data/bundler/lib/bundler/man/gemfile.5 +3 -3
- data/bundler/lib/bundler/man/gemfile.5.ronn +2 -2
- data/bundler/lib/bundler/mirror.rb +3 -3
- data/bundler/lib/bundler/plugin/api/source.rb +2 -2
- data/bundler/lib/bundler/plugin/installer/path.rb +18 -0
- data/bundler/lib/bundler/plugin/installer.rb +36 -16
- data/bundler/lib/bundler/plugin/source_list.rb +4 -4
- data/bundler/lib/bundler/resolver/candidate.rb +1 -1
- data/bundler/lib/bundler/resolver.rb +54 -24
- data/bundler/lib/bundler/rubygems_ext.rb +12 -0
- data/bundler/lib/bundler/runtime.rb +1 -1
- data/bundler/lib/bundler/self_manager.rb +1 -1
- data/bundler/lib/bundler/settings.rb +14 -12
- data/bundler/lib/bundler/setup.rb +3 -0
- data/bundler/lib/bundler/source/git/git_proxy.rb +1 -1
- data/bundler/lib/bundler/source/git.rb +1 -1
- data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
- data/bundler/lib/bundler/source/rubygems.rb +7 -20
- data/bundler/lib/bundler/source_list.rb +17 -4
- data/bundler/lib/bundler/spec_set.rb +1 -1
- data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -3
- data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
- data/bundler/lib/bundler/uri_credentials_filter.rb +2 -2
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +22 -22
- data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +1 -0
- data/bundler/lib/bundler/vendored_net_http.rb +7 -3
- data/bundler/lib/bundler/vendored_timeout.rb +7 -3
- data/bundler/lib/bundler/vendored_uri.rb +18 -1
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/lib/bundler/yaml_serializer.rb +12 -0
- data/bundler/lib/bundler.rb +23 -2
- data/lib/rubygems/command.rb +1 -1
- data/lib/rubygems/command_manager.rb +2 -1
- data/lib/rubygems/commands/build_command.rb +2 -11
- data/lib/rubygems/commands/help_command.rb +2 -2
- data/lib/rubygems/commands/rdoc_command.rb +1 -8
- data/lib/rubygems/commands/rebuild_command.rb +264 -0
- data/lib/rubygems/commands/sources_command.rb +2 -2
- data/lib/rubygems/commands/update_command.rb +8 -9
- data/lib/rubygems/config_file.rb +20 -8
- data/lib/rubygems/defaults.rb +4 -4
- data/lib/rubygems/dependency.rb +2 -2
- data/lib/rubygems/dependency_list.rb +1 -1
- data/lib/rubygems/deprecate.rb +79 -77
- data/lib/rubygems/ext/cargo_builder.rb +1 -1
- data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +1 -1
- data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +3 -1
- data/lib/rubygems/gemcutter_utilities.rb +40 -23
- data/lib/rubygems/gemspec_helpers.rb +19 -0
- data/lib/rubygems/local_remote_options.rb +6 -6
- data/lib/rubygems/package.rb +13 -7
- data/lib/rubygems/remote_fetcher.rb +3 -3
- data/lib/rubygems/request.rb +5 -5
- data/lib/rubygems/request_set.rb +1 -1
- data/lib/rubygems/requirement.rb +5 -0
- data/lib/rubygems/resolver/api_set.rb +1 -1
- data/lib/rubygems/resolver/best_set.rb +1 -1
- data/lib/rubygems/resolver/spec_specification.rb +7 -0
- data/lib/rubygems/resolver.rb +5 -5
- data/lib/rubygems/s3_uri_signer.rb +3 -3
- data/lib/rubygems/safe_yaml.rb +10 -1
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/source/git.rb +2 -2
- data/lib/rubygems/source_list.rb +1 -1
- data/lib/rubygems/specification.rb +6 -6
- data/lib/rubygems/specification_policy.rb +15 -7
- data/lib/rubygems/uri.rb +6 -6
- data/lib/rubygems/util/licenses.rb +43 -0
- data/lib/rubygems/util.rb +1 -1
- data/lib/rubygems/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/delegates/specification_provider.rb +11 -11
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/action.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/log.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/vertex.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph.rb +2 -2
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/errors.rb +1 -1
- data/lib/rubygems/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/specification_provider.rb +2 -2
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/ui.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolution.rb +3 -3
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolver.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/state.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo.rb +2 -2
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/generic_request.rb +9 -9
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/header.rb +2 -2
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/request.rb +3 -3
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/requests.rb +30 -30
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/response.rb +2 -2
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/responses.rb +6 -6
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/status.rb +1 -1
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http.rb +15 -15
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/https.rb +1 -1
- data/lib/rubygems/vendor/optparse/lib/optparse/uri.rb +7 -0
- data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse.rb +11 -11
- data/lib/rubygems/{timeout → vendor/timeout}/lib/timeout.rb +1 -1
- data/lib/rubygems/{tsort → vendor/tsort}/lib/tsort.rb +2 -2
- data/lib/rubygems/vendor/uri/.document +1 -0
- data/lib/rubygems/vendor/uri/LICENSE.txt +22 -0
- data/lib/rubygems/vendor/uri/lib/uri/common.rb +853 -0
- data/lib/rubygems/vendor/uri/lib/uri/file.rb +100 -0
- data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/rubygems/vendor/uri/lib/uri/generic.rb +1588 -0
- data/lib/rubygems/vendor/uri/lib/uri/http.rb +125 -0
- data/lib/rubygems/vendor/uri/lib/uri/https.rb +23 -0
- data/lib/rubygems/vendor/uri/lib/uri/ldap.rb +261 -0
- data/lib/rubygems/vendor/uri/lib/uri/ldaps.rb +22 -0
- data/lib/rubygems/vendor/uri/lib/uri/mailto.rb +293 -0
- data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
- data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +183 -0
- data/lib/rubygems/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/rubygems/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/rubygems/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/rubygems/vendor/uri/lib/uri.rb +104 -0
- data/lib/rubygems/vendored_molinillo.rb +3 -0
- data/lib/rubygems/vendored_net_http.rb +5 -0
- data/lib/rubygems/vendored_optparse.rb +3 -0
- data/lib/rubygems/vendored_timeout.rb +5 -0
- data/lib/rubygems/vendored_tsort.rb +3 -0
- data/lib/rubygems/yaml_serializer.rb +12 -0
- data/lib/rubygems.rb +2 -2
- data/rubygems-update.gemspec +7 -2
- metadata +90 -67
- data/lib/rubygems/net/http.rb +0 -3
- data/lib/rubygems/optparse/lib/optparse/uri.rb +0 -7
- data/lib/rubygems/optparse.rb +0 -3
- data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/rubygems/resolver/molinillo.rb +0 -3
- data/lib/rubygems/timeout.rb +0 -3
- data/lib/rubygems/tsort.rb +0 -3
- /data/lib/rubygems/{net-http → vendor/molinillo}/.document +0 -0
- /data/lib/rubygems/{resolver → vendor}/molinillo/LICENSE +0 -0
- /data/lib/rubygems/{net-protocol → vendor/net-http}/.document +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/LICENSE.txt +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/backward.rb +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/exceptions.rb +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/proxy_delta.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/net-protocol}/.document +0 -0
- /data/lib/rubygems/{net-protocol → vendor/net-protocol}/LICENSE.txt +0 -0
- /data/lib/rubygems/{net-protocol → vendor/net-protocol}/lib/net/protocol.rb +0 -0
- /data/lib/rubygems/{resolv → vendor/optparse}/.document +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/COPYING +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optionparser.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/ac.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/date.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/kwargs.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/shellwords.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/time.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/version.rb +0 -0
- /data/lib/rubygems/{resolver/molinillo → vendor/resolv}/.document +0 -0
- /data/lib/rubygems/{resolv → vendor/resolv}/LICENSE.txt +0 -0
- /data/lib/rubygems/{resolv → vendor/resolv}/lib/resolv.rb +0 -0
- /data/lib/rubygems/{timeout → vendor/timeout}/.document +0 -0
- /data/lib/rubygems/{timeout → vendor/timeout}/LICENSE.txt +0 -0
- /data/lib/rubygems/{tsort → vendor/tsort}/.document +0 -0
- /data/lib/rubygems/{tsort → vendor/tsort}/LICENSE.txt +0 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'generic'
|
4
|
+
|
5
|
+
module Gem::URI
|
6
|
+
|
7
|
+
#
|
8
|
+
# The "file" Gem::URI is defined by RFC8089.
|
9
|
+
#
|
10
|
+
class File < Generic
|
11
|
+
# A Default port of nil for Gem::URI::File.
|
12
|
+
DEFAULT_PORT = nil
|
13
|
+
|
14
|
+
#
|
15
|
+
# An Array of the available components for Gem::URI::File.
|
16
|
+
#
|
17
|
+
COMPONENT = [
|
18
|
+
:scheme,
|
19
|
+
:host,
|
20
|
+
:path
|
21
|
+
].freeze
|
22
|
+
|
23
|
+
#
|
24
|
+
# == Description
|
25
|
+
#
|
26
|
+
# Creates a new Gem::URI::File object from components, with syntax checking.
|
27
|
+
#
|
28
|
+
# The components accepted are +host+ and +path+.
|
29
|
+
#
|
30
|
+
# The components should be provided either as an Array, or as a Hash
|
31
|
+
# with keys formed by preceding the component names with a colon.
|
32
|
+
#
|
33
|
+
# If an Array is used, the components must be passed in the
|
34
|
+
# order <code>[host, path]</code>.
|
35
|
+
#
|
36
|
+
# A path from e.g. the File class should be escaped before
|
37
|
+
# being passed.
|
38
|
+
#
|
39
|
+
# Examples:
|
40
|
+
#
|
41
|
+
# require 'rubygems/vendor/uri/lib/uri'
|
42
|
+
#
|
43
|
+
# uri1 = Gem::URI::File.build(['host.example.com', '/path/file.zip'])
|
44
|
+
# uri1.to_s # => "file://host.example.com/path/file.zip"
|
45
|
+
#
|
46
|
+
# uri2 = Gem::URI::File.build({:host => 'host.example.com',
|
47
|
+
# :path => '/ruby/src'})
|
48
|
+
# uri2.to_s # => "file://host.example.com/ruby/src"
|
49
|
+
#
|
50
|
+
# uri3 = Gem::URI::File.build({:path => Gem::URI::escape('/path/my file.txt')})
|
51
|
+
# uri3.to_s # => "file:///path/my%20file.txt"
|
52
|
+
#
|
53
|
+
def self.build(args)
|
54
|
+
tmp = Util::make_components_hash(self, args)
|
55
|
+
super(tmp)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Protected setter for the host component +v+.
|
59
|
+
#
|
60
|
+
# See also Gem::URI::Generic.host=.
|
61
|
+
#
|
62
|
+
def set_host(v)
|
63
|
+
v = "" if v.nil? || v == "localhost"
|
64
|
+
@host = v
|
65
|
+
end
|
66
|
+
|
67
|
+
# do nothing
|
68
|
+
def set_port(v)
|
69
|
+
end
|
70
|
+
|
71
|
+
# raise InvalidURIError
|
72
|
+
def check_userinfo(user)
|
73
|
+
raise Gem::URI::InvalidURIError, "can not set userinfo for file Gem::URI"
|
74
|
+
end
|
75
|
+
|
76
|
+
# raise InvalidURIError
|
77
|
+
def check_user(user)
|
78
|
+
raise Gem::URI::InvalidURIError, "can not set user for file Gem::URI"
|
79
|
+
end
|
80
|
+
|
81
|
+
# raise InvalidURIError
|
82
|
+
def check_password(user)
|
83
|
+
raise Gem::URI::InvalidURIError, "can not set password for file Gem::URI"
|
84
|
+
end
|
85
|
+
|
86
|
+
# do nothing
|
87
|
+
def set_userinfo(v)
|
88
|
+
end
|
89
|
+
|
90
|
+
# do nothing
|
91
|
+
def set_user(v)
|
92
|
+
end
|
93
|
+
|
94
|
+
# do nothing
|
95
|
+
def set_password(v)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
register_scheme 'FILE', File
|
100
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# = uri/ftp.rb
|
3
|
+
#
|
4
|
+
# Author:: Akira Yamada <akira@ruby-lang.org>
|
5
|
+
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
+
#
|
7
|
+
# See Gem::URI for general documentation
|
8
|
+
#
|
9
|
+
|
10
|
+
require_relative 'generic'
|
11
|
+
|
12
|
+
module Gem::URI
|
13
|
+
|
14
|
+
#
|
15
|
+
# FTP Gem::URI syntax is defined by RFC1738 section 3.2.
|
16
|
+
#
|
17
|
+
# This class will be redesigned because of difference of implementations;
|
18
|
+
# the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
|
19
|
+
# is a good summary about the de facto spec.
|
20
|
+
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
|
21
|
+
#
|
22
|
+
class FTP < Generic
|
23
|
+
# A Default port of 21 for Gem::URI::FTP.
|
24
|
+
DEFAULT_PORT = 21
|
25
|
+
|
26
|
+
#
|
27
|
+
# An Array of the available components for Gem::URI::FTP.
|
28
|
+
#
|
29
|
+
COMPONENT = [
|
30
|
+
:scheme,
|
31
|
+
:userinfo, :host, :port,
|
32
|
+
:path, :typecode
|
33
|
+
].freeze
|
34
|
+
|
35
|
+
#
|
36
|
+
# Typecode is "a", "i", or "d".
|
37
|
+
#
|
38
|
+
# * "a" indicates a text file (the FTP command was ASCII)
|
39
|
+
# * "i" indicates a binary file (FTP command IMAGE)
|
40
|
+
# * "d" indicates the contents of a directory should be displayed
|
41
|
+
#
|
42
|
+
TYPECODE = ['a', 'i', 'd'].freeze
|
43
|
+
|
44
|
+
# Typecode prefix ";type=".
|
45
|
+
TYPECODE_PREFIX = ';type='.freeze
|
46
|
+
|
47
|
+
def self.new2(user, password, host, port, path,
|
48
|
+
typecode = nil, arg_check = true) # :nodoc:
|
49
|
+
# Do not use this method! Not tested. [Bug #7301]
|
50
|
+
# This methods remains just for compatibility,
|
51
|
+
# Keep it undocumented until the active maintainer is assigned.
|
52
|
+
typecode = nil if typecode.size == 0
|
53
|
+
if typecode && !TYPECODE.include?(typecode)
|
54
|
+
raise ArgumentError,
|
55
|
+
"bad typecode is specified: #{typecode}"
|
56
|
+
end
|
57
|
+
|
58
|
+
# do escape
|
59
|
+
|
60
|
+
self.new('ftp',
|
61
|
+
[user, password],
|
62
|
+
host, port, nil,
|
63
|
+
typecode ? path + TYPECODE_PREFIX + typecode : path,
|
64
|
+
nil, nil, nil, arg_check)
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# == Description
|
69
|
+
#
|
70
|
+
# Creates a new Gem::URI::FTP object from components, with syntax checking.
|
71
|
+
#
|
72
|
+
# The components accepted are +userinfo+, +host+, +port+, +path+, and
|
73
|
+
# +typecode+.
|
74
|
+
#
|
75
|
+
# The components should be provided either as an Array, or as a Hash
|
76
|
+
# with keys formed by preceding the component names with a colon.
|
77
|
+
#
|
78
|
+
# If an Array is used, the components must be passed in the
|
79
|
+
# order <code>[userinfo, host, port, path, typecode]</code>.
|
80
|
+
#
|
81
|
+
# If the path supplied is absolute, it will be escaped in order to
|
82
|
+
# make it absolute in the Gem::URI.
|
83
|
+
#
|
84
|
+
# Examples:
|
85
|
+
#
|
86
|
+
# require 'rubygems/vendor/uri/lib/uri'
|
87
|
+
#
|
88
|
+
# uri1 = Gem::URI::FTP.build(['user:password', 'ftp.example.com', nil,
|
89
|
+
# '/path/file.zip', 'i'])
|
90
|
+
# uri1.to_s # => "ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i"
|
91
|
+
#
|
92
|
+
# uri2 = Gem::URI::FTP.build({:host => 'ftp.example.com',
|
93
|
+
# :path => 'ruby/src'})
|
94
|
+
# uri2.to_s # => "ftp://ftp.example.com/ruby/src"
|
95
|
+
#
|
96
|
+
def self.build(args)
|
97
|
+
|
98
|
+
# Fix the incoming path to be generic URL syntax
|
99
|
+
# FTP path -> URL path
|
100
|
+
# foo/bar /foo/bar
|
101
|
+
# /foo/bar /%2Ffoo/bar
|
102
|
+
#
|
103
|
+
if args.kind_of?(Array)
|
104
|
+
args[3] = '/' + args[3].sub(/^\//, '%2F')
|
105
|
+
else
|
106
|
+
args[:path] = '/' + args[:path].sub(/^\//, '%2F')
|
107
|
+
end
|
108
|
+
|
109
|
+
tmp = Util::make_components_hash(self, args)
|
110
|
+
|
111
|
+
if tmp[:typecode]
|
112
|
+
if tmp[:typecode].size == 1
|
113
|
+
tmp[:typecode] = TYPECODE_PREFIX + tmp[:typecode]
|
114
|
+
end
|
115
|
+
tmp[:path] << tmp[:typecode]
|
116
|
+
end
|
117
|
+
|
118
|
+
return super(tmp)
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# == Description
|
123
|
+
#
|
124
|
+
# Creates a new Gem::URI::FTP object from generic URL components with no
|
125
|
+
# syntax checking.
|
126
|
+
#
|
127
|
+
# Unlike build(), this method does not escape the path component as
|
128
|
+
# required by RFC1738; instead it is treated as per RFC2396.
|
129
|
+
#
|
130
|
+
# Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
|
131
|
+
# +opaque+, +query+, and +fragment+, in that order.
|
132
|
+
#
|
133
|
+
def initialize(scheme,
|
134
|
+
userinfo, host, port, registry,
|
135
|
+
path, opaque,
|
136
|
+
query,
|
137
|
+
fragment,
|
138
|
+
parser = nil,
|
139
|
+
arg_check = false)
|
140
|
+
raise InvalidURIError unless path
|
141
|
+
path = path.sub(/^\//,'')
|
142
|
+
path.sub!(/^%2F/,'/')
|
143
|
+
super(scheme, userinfo, host, port, registry, path, opaque,
|
144
|
+
query, fragment, parser, arg_check)
|
145
|
+
@typecode = nil
|
146
|
+
if tmp = @path.index(TYPECODE_PREFIX)
|
147
|
+
typecode = @path[tmp + TYPECODE_PREFIX.size..-1]
|
148
|
+
@path = @path[0..tmp - 1]
|
149
|
+
|
150
|
+
if arg_check
|
151
|
+
self.typecode = typecode
|
152
|
+
else
|
153
|
+
self.set_typecode(typecode)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# typecode accessor.
|
159
|
+
#
|
160
|
+
# See Gem::URI::FTP::COMPONENT.
|
161
|
+
attr_reader :typecode
|
162
|
+
|
163
|
+
# Validates typecode +v+,
|
164
|
+
# returns +true+ or +false+.
|
165
|
+
#
|
166
|
+
def check_typecode(v)
|
167
|
+
if TYPECODE.include?(v)
|
168
|
+
return true
|
169
|
+
else
|
170
|
+
raise InvalidComponentError,
|
171
|
+
"bad typecode(expected #{TYPECODE.join(', ')}): #{v}"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
private :check_typecode
|
175
|
+
|
176
|
+
# Private setter for the typecode +v+.
|
177
|
+
#
|
178
|
+
# See also Gem::URI::FTP.typecode=.
|
179
|
+
#
|
180
|
+
def set_typecode(v)
|
181
|
+
@typecode = v
|
182
|
+
end
|
183
|
+
protected :set_typecode
|
184
|
+
|
185
|
+
#
|
186
|
+
# == Args
|
187
|
+
#
|
188
|
+
# +v+::
|
189
|
+
# String
|
190
|
+
#
|
191
|
+
# == Description
|
192
|
+
#
|
193
|
+
# Public setter for the typecode +v+
|
194
|
+
# (with validation).
|
195
|
+
#
|
196
|
+
# See also Gem::URI::FTP.check_typecode.
|
197
|
+
#
|
198
|
+
# == Usage
|
199
|
+
#
|
200
|
+
# require 'rubygems/vendor/uri/lib/uri'
|
201
|
+
#
|
202
|
+
# uri = Gem::URI.parse("ftp://john@ftp.example.com/my_file.img")
|
203
|
+
# #=> #<Gem::URI::FTP ftp://john@ftp.example.com/my_file.img>
|
204
|
+
# uri.typecode = "i"
|
205
|
+
# uri
|
206
|
+
# #=> #<Gem::URI::FTP ftp://john@ftp.example.com/my_file.img;type=i>
|
207
|
+
#
|
208
|
+
def typecode=(typecode)
|
209
|
+
check_typecode(typecode)
|
210
|
+
set_typecode(typecode)
|
211
|
+
typecode
|
212
|
+
end
|
213
|
+
|
214
|
+
def merge(oth) # :nodoc:
|
215
|
+
tmp = super(oth)
|
216
|
+
if self != tmp
|
217
|
+
tmp.set_typecode(oth.typecode)
|
218
|
+
end
|
219
|
+
|
220
|
+
return tmp
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the path from an FTP Gem::URI.
|
224
|
+
#
|
225
|
+
# RFC 1738 specifically states that the path for an FTP Gem::URI does not
|
226
|
+
# include the / which separates the Gem::URI path from the Gem::URI host. Example:
|
227
|
+
#
|
228
|
+
# <code>ftp://ftp.example.com/pub/ruby</code>
|
229
|
+
#
|
230
|
+
# The above Gem::URI indicates that the client should connect to
|
231
|
+
# ftp.example.com then cd to pub/ruby from the initial login directory.
|
232
|
+
#
|
233
|
+
# If you want to cd to an absolute directory, you must include an
|
234
|
+
# escaped / (%2F) in the path. Example:
|
235
|
+
#
|
236
|
+
# <code>ftp://ftp.example.com/%2Fpub/ruby</code>
|
237
|
+
#
|
238
|
+
# This method will then return "/pub/ruby".
|
239
|
+
#
|
240
|
+
def path
|
241
|
+
return @path.sub(/^\//,'').sub(/^%2F/,'/')
|
242
|
+
end
|
243
|
+
|
244
|
+
# Private setter for the path of the Gem::URI::FTP.
|
245
|
+
def set_path(v)
|
246
|
+
super("/" + v.sub(/^\//, "%2F"))
|
247
|
+
end
|
248
|
+
protected :set_path
|
249
|
+
|
250
|
+
# Returns a String representation of the Gem::URI::FTP.
|
251
|
+
def to_s
|
252
|
+
save_path = nil
|
253
|
+
if @typecode
|
254
|
+
save_path = @path
|
255
|
+
@path = @path + TYPECODE_PREFIX + @typecode
|
256
|
+
end
|
257
|
+
str = super
|
258
|
+
if @typecode
|
259
|
+
@path = save_path
|
260
|
+
end
|
261
|
+
|
262
|
+
return str
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
register_scheme 'FTP', FTP
|
267
|
+
end
|