rubygems-update 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +24 -0
- data/.document +4 -3
- data/ChangeLog +382 -1
- data/Manifest.txt +214 -0
- data/README +1 -49
- data/Rakefile +124 -191
- data/bin/gem +1 -4
- data/cruise_config.rb +22 -0
- data/doc/release_notes/rel_1_3_1.rdoc +3 -3
- data/doc/release_notes/rel_1_3_2.rdoc +119 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rubygems.rb +250 -25
- data/lib/rubygems/builder.rb +62 -60
- data/lib/rubygems/command.rb +421 -319
- data/lib/rubygems/command_manager.rb +153 -125
- data/lib/rubygems/commands/check_command.rb +12 -7
- data/lib/rubygems/commands/cleanup_command.rb +11 -2
- data/lib/rubygems/commands/contents_command.rb +42 -18
- data/lib/rubygems/commands/generate_index_command.rb +91 -15
- data/lib/rubygems/commands/install_command.rb +33 -47
- data/lib/rubygems/commands/query_command.rb +36 -20
- data/lib/rubygems/commands/rdoc_command.rb +62 -68
- data/lib/rubygems/commands/search_command.rb +26 -32
- data/lib/rubygems/commands/setup_command.rb +353 -0
- data/lib/rubygems/commands/sources_command.rb +5 -0
- data/lib/rubygems/commands/specification_command.rb +23 -3
- data/lib/rubygems/commands/uninstall_command.rb +71 -61
- data/lib/rubygems/commands/unpack_command.rb +14 -12
- data/lib/rubygems/commands/update_command.rb +26 -5
- data/lib/rubygems/defaults.rb +16 -3
- data/lib/rubygems/dependency.rb +38 -7
- data/lib/rubygems/dependency_installer.rb +7 -4
- data/lib/rubygems/digest/digest_adapter.rb +42 -33
- data/lib/rubygems/digest/sha1.rb +6 -1
- data/lib/rubygems/digest/sha2.rb +5 -0
- data/lib/rubygems/doc_manager.rb +31 -11
- data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
- data/lib/rubygems/ext/rake_builder.rb +6 -2
- data/lib/rubygems/format.rb +63 -63
- data/lib/rubygems/gem_openssl.rb +14 -2
- data/lib/rubygems/gem_path_searcher.rb +7 -3
- data/lib/rubygems/gem_runner.rb +59 -39
- data/lib/rubygems/indexer.rb +450 -109
- data/lib/rubygems/install_update_options.rb +13 -1
- data/lib/rubygems/installer.rb +25 -22
- data/lib/rubygems/local_remote_options.rb +5 -3
- data/lib/rubygems/old_format.rb +124 -120
- data/lib/rubygems/package/tar_header.rb +25 -3
- data/lib/rubygems/package/tar_input.rb +5 -5
- data/lib/rubygems/package/tar_output.rb +2 -0
- data/lib/rubygems/package/tar_reader.rb +19 -0
- data/lib/rubygems/package/tar_reader/entry.rb +43 -0
- data/lib/rubygems/package/tar_writer.rb +65 -3
- data/lib/rubygems/package_task.rb +117 -0
- data/lib/rubygems/platform.rb +12 -8
- data/lib/rubygems/remote_fetcher.rb +43 -24
- data/lib/rubygems/require_paths_builder.rb +14 -12
- data/lib/rubygems/requirement.rb +15 -6
- data/lib/rubygems/rubygems_version.rb +14 -1
- data/lib/rubygems/source_index.rb +38 -16
- data/lib/rubygems/source_info_cache_entry.rb +2 -2
- data/lib/rubygems/spec_fetcher.rb +43 -20
- data/lib/rubygems/specification.rb +1122 -947
- data/lib/rubygems/text.rb +30 -0
- data/lib/rubygems/timer.rb +14 -11
- data/lib/rubygems/uninstaller.rb +25 -5
- data/lib/rubygems/user_interaction.rb +294 -264
- data/lib/rubygems/validator.rb +70 -36
- data/lib/rubygems/version.rb +97 -33
- data/lib/rubygems/version_option.rb +1 -0
- data/setup.rb +11 -306
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +22 -11
- data/test/gem_package_tar_test_case.rb +0 -14
- data/test/gemutilities.rb +89 -8
- data/test/mockgemui.rb +2 -1
- data/test/rubygems_plugin.rb +16 -0
- data/test/test_gem.rb +107 -36
- data/test/test_gem_command.rb +3 -13
- data/test/test_gem_command_manager.rb +1 -14
- data/test/test_gem_commands_cert_command.rb +1 -1
- data/test/test_gem_commands_contents_command.rb +63 -0
- data/test/test_gem_commands_environment_command.rb +1 -1
- data/test/test_gem_commands_generate_index_command.rb +104 -1
- data/test/test_gem_commands_install_command.rb +95 -0
- data/test/test_gem_commands_pristine_command.rb +3 -3
- data/test/test_gem_commands_query_command.rb +46 -0
- data/test/test_gem_commands_sources_command.rb +9 -5
- data/test/test_gem_commands_specification_command.rb +31 -0
- data/test/test_gem_commands_uninstall_command.rb +3 -2
- data/test/test_gem_commands_unpack_command.rb +3 -2
- data/test/test_gem_commands_update_command.rb +12 -7
- data/test/test_gem_dependency.rb +62 -11
- data/test/test_gem_dependency_installer.rb +18 -5
- data/test/test_gem_dependency_list.rb +6 -6
- data/test/test_gem_doc_manager.rb +7 -1
- data/test/test_gem_ext_configure_builder.rb +8 -10
- data/test/test_gem_ext_ext_conf_builder.rb +14 -8
- data/test/test_gem_gem_path_searcher.rb +1 -1
- data/test/test_gem_gem_runner.rb +11 -0
- data/test/test_gem_indexer.rb +398 -21
- data/test/test_gem_install_update_options.rb +20 -6
- data/test/test_gem_installer.rb +22 -14
- data/test/test_gem_local_remote_options.rb +2 -1
- data/test/test_gem_package_tar_header.rb +3 -3
- data/test/test_gem_package_tar_input.rb +3 -3
- data/test/test_gem_package_tar_output.rb +2 -2
- data/test/test_gem_package_task.rb +70 -0
- data/test/test_gem_platform.rb +12 -6
- data/test/test_gem_remote_fetcher.rb +23 -1
- data/test/test_gem_source_index.rb +32 -21
- data/test/test_gem_spec_fetcher.rb +77 -5
- data/test/test_gem_specification.rb +274 -1
- data/test/test_gem_uninstaller.rb +34 -4
- data/test/test_gem_version.rb +94 -4
- data/test/test_gem_version_option.rb +13 -0
- data/test/test_kernel.rb +4 -4
- data/util/CL2notes +56 -0
- data/util/gem_prelude.rb.template +251 -0
- metadata +30 -20
- metadata.gz.sig +3 -4
- data/TODO +0 -1
- data/scripts/buildtests.rb +0 -31
- data/scripts/gemdoc.rb +0 -67
- data/scripts/runtest.rb +0 -40
- data/scripts/specdoc.rb +0 -171
- data/scripts/upload_gemdoc.rb +0 -140
@@ -2,72 +2,82 @@ require 'rubygems/command'
|
|
2
2
|
require 'rubygems/version_option'
|
3
3
|
require 'rubygems/uninstaller'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
include VersionOption
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
super 'uninstall', 'Uninstall gems from the local repository',
|
13
|
-
:version => Gem::Requirement.default
|
14
|
-
|
15
|
-
add_option('-a', '--[no-]all',
|
16
|
-
'Uninstall all matching versions'
|
17
|
-
) do |value, options|
|
18
|
-
options[:all] = value
|
19
|
-
end
|
20
|
-
|
21
|
-
add_option('-I', '--[no-]ignore-dependencies',
|
22
|
-
'Ignore dependency requirements while',
|
23
|
-
'uninstalling') do |value, options|
|
24
|
-
options[:ignore] = value
|
25
|
-
end
|
26
|
-
|
27
|
-
add_option('-x', '--[no-]executables',
|
28
|
-
'Uninstall applicable executables without',
|
29
|
-
'confirmation') do |value, options|
|
30
|
-
options[:executables] = value
|
31
|
-
end
|
32
|
-
|
33
|
-
add_option('-i', '--install-dir DIR',
|
34
|
-
'Directory to uninstall gem from') do |value, options|
|
35
|
-
options[:install_dir] = File.expand_path(value)
|
36
|
-
end
|
37
|
-
|
38
|
-
add_option('-n', '--bindir DIR',
|
39
|
-
'Directory to remove binaries from') do |value, options|
|
40
|
-
options[:bin_dir] = File.expand_path(value)
|
41
|
-
end
|
42
|
-
|
43
|
-
add_version_option
|
44
|
-
add_platform_option
|
45
|
-
end
|
5
|
+
##
|
6
|
+
# Gem uninstaller command line tool
|
7
|
+
#
|
8
|
+
# See `gem help uninstall`
|
46
9
|
|
47
|
-
|
48
|
-
"GEMNAME name of gem to uninstall"
|
49
|
-
end
|
10
|
+
class Gem::Commands::UninstallCommand < Gem::Command
|
50
11
|
|
51
|
-
|
52
|
-
"--version '#{Gem::Requirement.default}' --no-force " \
|
53
|
-
"--install-dir #{Gem.dir}"
|
54
|
-
end
|
12
|
+
include Gem::VersionOption
|
55
13
|
|
56
|
-
|
57
|
-
|
58
|
-
|
14
|
+
def initialize
|
15
|
+
super 'uninstall', 'Uninstall gems from the local repository',
|
16
|
+
:version => Gem::Requirement.default, :user_install => true
|
17
|
+
|
18
|
+
add_option('-a', '--[no-]all',
|
19
|
+
'Uninstall all matching versions'
|
20
|
+
) do |value, options|
|
21
|
+
options[:all] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
add_option('-I', '--[no-]ignore-dependencies',
|
25
|
+
'Ignore dependency requirements while',
|
26
|
+
'uninstalling') do |value, options|
|
27
|
+
options[:ignore] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
add_option('-x', '--[no-]executables',
|
31
|
+
'Uninstall applicable executables without',
|
32
|
+
'confirmation') do |value, options|
|
33
|
+
options[:executables] = value
|
34
|
+
end
|
35
|
+
|
36
|
+
add_option('-i', '--install-dir DIR',
|
37
|
+
'Directory to uninstall gem from') do |value, options|
|
38
|
+
options[:install_dir] = File.expand_path(value)
|
39
|
+
end
|
40
|
+
|
41
|
+
add_option('-n', '--bindir DIR',
|
42
|
+
'Directory to remove binaries from') do |value, options|
|
43
|
+
options[:bin_dir] = File.expand_path(value)
|
44
|
+
end
|
45
|
+
|
46
|
+
add_option('--[no-]user-install',
|
47
|
+
'Uninstall from user\'s home directory',
|
48
|
+
'in addition to GEM_HOME.') do |value, options|
|
49
|
+
options[:user_install] = value
|
50
|
+
end
|
51
|
+
|
52
|
+
add_version_option
|
53
|
+
add_platform_option
|
54
|
+
end
|
55
|
+
|
56
|
+
def arguments # :nodoc:
|
57
|
+
"GEMNAME name of gem to uninstall"
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
60
|
+
def defaults_str # :nodoc:
|
61
|
+
"--version '#{Gem::Requirement.default}' --no-force " \
|
62
|
+
"--install-dir #{Gem.dir}\n" \
|
63
|
+
"--user-install"
|
64
|
+
end
|
65
|
+
|
66
|
+
def usage # :nodoc:
|
67
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
68
|
+
end
|
69
|
+
|
70
|
+
def execute
|
71
|
+
get_all_gem_names.each do |gem_name|
|
72
|
+
begin
|
73
|
+
Gem::Uninstaller.new(gem_name, options).uninstall
|
74
|
+
rescue Gem::GemNotInHomeException => e
|
75
|
+
spec = e.spec
|
76
|
+
alert("In order to remove #{spec.name}, please execute:\n" \
|
77
|
+
"\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
|
70
78
|
end
|
71
79
|
end
|
72
80
|
end
|
81
|
+
|
73
82
|
end
|
83
|
+
|
@@ -12,7 +12,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
12
12
|
:version => Gem::Requirement.default,
|
13
13
|
:target => Dir.pwd
|
14
14
|
|
15
|
-
add_option('--target', 'target directory for unpacking') do |value, options|
|
15
|
+
add_option('--target=DIR', 'target directory for unpacking') do |value, options|
|
16
16
|
options[:target] = value
|
17
17
|
end
|
18
18
|
|
@@ -35,18 +35,20 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
35
35
|
# TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for
|
36
36
|
# this, so that it works for uninstall as well. (And check other commands
|
37
37
|
# at the same time.)
|
38
|
+
|
38
39
|
def execute
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
get_all_gem_names.each do |name|
|
41
|
+
path = get_path name, options[:version]
|
42
|
+
|
43
|
+
if path then
|
44
|
+
basename = File.basename(path).sub(/\.gem$/, '')
|
45
|
+
target_dir = File.expand_path File.join(options[:target], basename)
|
46
|
+
FileUtils.mkdir_p target_dir
|
47
|
+
Gem::Installer.new(path, :unpack => true).unpack target_dir
|
48
|
+
say "Unpacked gem: '#{target_dir}'"
|
49
|
+
else
|
50
|
+
alert_error "Gem '#{name}' not installed."
|
51
|
+
end
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -16,9 +16,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
16
16
|
super 'update',
|
17
17
|
'Update the named gems (or all installed gems) in the local repository',
|
18
18
|
:generate_rdoc => true,
|
19
|
-
:generate_ri
|
20
|
-
:force
|
21
|
-
:test
|
19
|
+
:generate_ri => true,
|
20
|
+
:force => false,
|
21
|
+
:test => false
|
22
22
|
|
23
23
|
add_install_update_options
|
24
24
|
|
@@ -80,13 +80,20 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
80
80
|
|
81
81
|
gems_to_update.uniq.sort.each do |name|
|
82
82
|
next if updated.any? { |spec| spec.name == name }
|
83
|
+
success = false
|
83
84
|
|
84
85
|
say "Updating #{name}"
|
85
|
-
|
86
|
+
begin
|
87
|
+
installer.install name
|
88
|
+
success = true
|
89
|
+
rescue Gem::InstallError => e
|
90
|
+
alert_error "Error installing #{name}:\n\t#{e.message}"
|
91
|
+
success = false
|
92
|
+
end
|
86
93
|
|
87
94
|
installer.installed_gems.each do |spec|
|
88
95
|
updated << spec
|
89
|
-
say "Successfully installed #{spec.full_name}"
|
96
|
+
say "Successfully installed #{spec.full_name}" if success
|
90
97
|
end
|
91
98
|
end
|
92
99
|
|
@@ -106,6 +113,20 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
106
113
|
say "Nothing to update"
|
107
114
|
else
|
108
115
|
say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}"
|
116
|
+
|
117
|
+
if options[:generate_ri] then
|
118
|
+
updated.each do |gem|
|
119
|
+
Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
|
120
|
+
end
|
121
|
+
|
122
|
+
Gem::DocManager.update_ri_cache
|
123
|
+
end
|
124
|
+
|
125
|
+
if options[:generate_rdoc] then
|
126
|
+
updated.each do |gem|
|
127
|
+
Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
|
128
|
+
end
|
129
|
+
end
|
109
130
|
end
|
110
131
|
end
|
111
132
|
end
|
data/lib/rubygems/defaults.rb
CHANGED
@@ -20,6 +20,9 @@ module Gem
|
|
20
20
|
if defined? RUBY_FRAMEWORK_VERSION then
|
21
21
|
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
|
22
22
|
ConfigMap[:ruby_version]
|
23
|
+
elsif RUBY_VERSION > '1.9' then
|
24
|
+
File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
|
25
|
+
ConfigMap[:ruby_version])
|
23
26
|
else
|
24
27
|
File.join(ConfigMap[:libdir], ruby_engine, 'gems',
|
25
28
|
ConfigMap[:ruby_version])
|
@@ -38,15 +41,25 @@ module Gem
|
|
38
41
|
# Default gem load path
|
39
42
|
|
40
43
|
def self.default_path
|
41
|
-
|
44
|
+
if File.exist?(Gem.user_home)
|
45
|
+
[user_dir, default_dir]
|
46
|
+
else
|
47
|
+
[default_dir]
|
48
|
+
end
|
42
49
|
end
|
43
50
|
|
44
51
|
##
|
45
52
|
# Deduce Ruby's --program-prefix and --program-suffix from its install name
|
46
53
|
|
47
54
|
def self.default_exec_format
|
48
|
-
|
49
|
-
|
55
|
+
exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'
|
56
|
+
|
57
|
+
unless exec_format =~ /%s/ then
|
58
|
+
raise Gem::Exception,
|
59
|
+
"[BUG] invalid exec_format #{exec_format.inspect}, no %s"
|
60
|
+
end
|
61
|
+
|
62
|
+
exec_format
|
50
63
|
end
|
51
64
|
|
52
65
|
##
|
data/lib/rubygems/dependency.rb
CHANGED
@@ -72,7 +72,7 @@ class Gem::Dependency
|
|
72
72
|
alias requirements_list requirement_list
|
73
73
|
|
74
74
|
def normalize
|
75
|
-
ver = @version_requirement.
|
75
|
+
ver = @version_requirement.instance_variable_get :@version
|
76
76
|
@version_requirements = Gem::Requirement.new([ver])
|
77
77
|
@version_requirement = nil
|
78
78
|
end
|
@@ -81,6 +81,21 @@ class Gem::Dependency
|
|
81
81
|
"#{name} (#{version_requirements}, #{@type || :runtime})"
|
82
82
|
end
|
83
83
|
|
84
|
+
def pretty_print(q) # :nodoc:
|
85
|
+
q.group 1, 'Gem::Dependency.new(', ')' do
|
86
|
+
q.pp @name
|
87
|
+
q.text ','
|
88
|
+
q.breakable
|
89
|
+
|
90
|
+
q.pp @version_requirements
|
91
|
+
|
92
|
+
q.text ','
|
93
|
+
q.breakable
|
94
|
+
|
95
|
+
q.pp @type
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
84
99
|
def ==(other) # :nodoc:
|
85
100
|
self.class === other &&
|
86
101
|
self.name == other.name &&
|
@@ -89,15 +104,22 @@ class Gem::Dependency
|
|
89
104
|
end
|
90
105
|
|
91
106
|
##
|
92
|
-
# Uses this dependency as a pattern to compare to
|
93
|
-
#
|
94
|
-
#
|
107
|
+
# Uses this dependency as a pattern to compare to +other+. This dependency
|
108
|
+
# will match if the name matches the other's name, and other has only an
|
109
|
+
# equal version requirement that satisfies this dependency.
|
95
110
|
|
96
111
|
def =~(other)
|
97
|
-
|
112
|
+
other = if self.class === other then
|
113
|
+
other
|
114
|
+
else
|
115
|
+
return false unless other.respond_to? :name and
|
116
|
+
other.respond_to? :version
|
117
|
+
|
118
|
+
Gem::Dependency.new other.name, other.version
|
119
|
+
end
|
98
120
|
|
99
121
|
pattern = @name
|
100
|
-
pattern = /\A#{@name}\Z/ unless Regexp === pattern
|
122
|
+
pattern = /\A#{Regexp.escape @name}\Z/ unless Regexp === pattern
|
101
123
|
|
102
124
|
return false unless pattern =~ other.name
|
103
125
|
|
@@ -111,9 +133,18 @@ class Gem::Dependency
|
|
111
133
|
version_requirements.satisfied_by? version
|
112
134
|
end
|
113
135
|
|
114
|
-
|
136
|
+
##
|
137
|
+
# A dependency's hash is the sum of the hash of the #name, #type and
|
138
|
+
# #version_requirements
|
139
|
+
|
140
|
+
def hash
|
115
141
|
name.hash + type.hash + version_requirements.hash
|
116
142
|
end
|
117
143
|
|
144
|
+
def inspect # :nodoc:
|
145
|
+
"<%s type=%p name=%p requirements=%p>" % [self.class, @type, @name,
|
146
|
+
version_requirements.to_s]
|
147
|
+
end
|
148
|
+
|
118
149
|
end
|
119
150
|
|
@@ -20,8 +20,9 @@ class Gem::DependencyInstaller
|
|
20
20
|
:force => false,
|
21
21
|
:format_executable => false, # HACK dup
|
22
22
|
:ignore_dependencies => false,
|
23
|
+
:prerelease => false,
|
23
24
|
:security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
|
24
|
-
:wrappers => true
|
25
|
+
:wrappers => true,
|
25
26
|
}
|
26
27
|
|
27
28
|
##
|
@@ -37,6 +38,7 @@ class Gem::DependencyInstaller
|
|
37
38
|
# :format_executable:: See Gem::Installer#initialize.
|
38
39
|
# :ignore_dependencies:: Don't install any dependencies.
|
39
40
|
# :install_dir:: See Gem::Installer#install.
|
41
|
+
# :prerelease:: Allow prerelease versions
|
40
42
|
# :security_policy:: See Gem::Installer::new and Gem::Security.
|
41
43
|
# :user_install:: See Gem::Installer.new
|
42
44
|
# :wrappers:: See Gem::Installer::new
|
@@ -58,6 +60,7 @@ class Gem::DependencyInstaller
|
|
58
60
|
@force = options[:force]
|
59
61
|
@format_executable = options[:format_executable]
|
60
62
|
@ignore_dependencies = options[:ignore_dependencies]
|
63
|
+
@prerelease = options[:prerelease]
|
61
64
|
@security_policy = options[:security_policy]
|
62
65
|
@user_install = options[:user_install]
|
63
66
|
@wrappers = options[:wrappers]
|
@@ -90,10 +93,10 @@ class Gem::DependencyInstaller
|
|
90
93
|
req
|
91
94
|
end
|
92
95
|
|
93
|
-
all = requirements.length > 1 ||
|
94
|
-
(requirements.first != ">=" and requirements.first != ">")
|
96
|
+
all = !@prerelease && (requirements.length > 1 ||
|
97
|
+
(requirements.first != ">=" and requirements.first != ">"))
|
95
98
|
|
96
|
-
found = Gem::SpecFetcher.fetcher.fetch dep, all
|
99
|
+
found = Gem::SpecFetcher.fetcher.fetch dep, all, true, @prerelease
|
97
100
|
gems_and_sources.push(*found)
|
98
101
|
|
99
102
|
rescue Gem::RemoteFetcher::FetchError => e
|
@@ -1,40 +1,49 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
#--
|
3
2
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
4
3
|
# All rights reserved.
|
5
4
|
# See LICENSE.txt for permissions.
|
6
5
|
#++
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# methods, we will return ourself as the instance.
|
26
|
-
def new
|
27
|
-
self
|
28
|
-
end
|
29
|
-
|
30
|
-
# Return the digest of +string+ as a hex string.
|
31
|
-
def hexdigest(string)
|
32
|
-
@digest_class.new(string).hexdigest
|
33
|
-
end
|
34
|
-
|
35
|
-
# Return the digest of +string+ as a binary string.
|
36
|
-
def digest(string)
|
37
|
-
@digest_class.new(string).digest
|
38
|
-
end
|
7
|
+
require 'rubygems'
|
8
|
+
|
9
|
+
##
|
10
|
+
# There is an incompatibility between the way Ruby 1.8.5 and 1.8.6 handles
|
11
|
+
# digests. This DigestAdapter will take a pre-1.8.6 digest and adapt it to
|
12
|
+
# the 1.8.6 API.
|
13
|
+
#
|
14
|
+
# Note that only the digest and hexdigest methods are adapted, since these
|
15
|
+
# are the only functions used by RubyGems.
|
16
|
+
|
17
|
+
class Gem::DigestAdapter
|
18
|
+
|
19
|
+
##
|
20
|
+
# Initialize a digest adapter.
|
21
|
+
|
22
|
+
def initialize(digest_class)
|
23
|
+
@digest_class = digest_class
|
39
24
|
end
|
40
|
-
|
25
|
+
|
26
|
+
##
|
27
|
+
# Return a new digester. Since we are only implementing the stateless
|
28
|
+
# methods, we will return ourself as the instance.
|
29
|
+
|
30
|
+
def new
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Return the digest of +string+ as a hex string.
|
36
|
+
|
37
|
+
def hexdigest(string)
|
38
|
+
@digest_class.new(string).hexdigest
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Return the digest of +string+ as a binary string.
|
43
|
+
|
44
|
+
def digest(string)
|
45
|
+
@digest_class.new(string).digest
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|