rubygems-update 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +24 -0
  3. data/.document +4 -3
  4. data/ChangeLog +382 -1
  5. data/Manifest.txt +214 -0
  6. data/README +1 -49
  7. data/Rakefile +124 -191
  8. data/bin/gem +1 -4
  9. data/cruise_config.rb +22 -0
  10. data/doc/release_notes/rel_1_3_1.rdoc +3 -3
  11. data/doc/release_notes/rel_1_3_2.rdoc +119 -0
  12. data/lib/gauntlet_rubygems.rb +50 -0
  13. data/lib/rubygems.rb +250 -25
  14. data/lib/rubygems/builder.rb +62 -60
  15. data/lib/rubygems/command.rb +421 -319
  16. data/lib/rubygems/command_manager.rb +153 -125
  17. data/lib/rubygems/commands/check_command.rb +12 -7
  18. data/lib/rubygems/commands/cleanup_command.rb +11 -2
  19. data/lib/rubygems/commands/contents_command.rb +42 -18
  20. data/lib/rubygems/commands/generate_index_command.rb +91 -15
  21. data/lib/rubygems/commands/install_command.rb +33 -47
  22. data/lib/rubygems/commands/query_command.rb +36 -20
  23. data/lib/rubygems/commands/rdoc_command.rb +62 -68
  24. data/lib/rubygems/commands/search_command.rb +26 -32
  25. data/lib/rubygems/commands/setup_command.rb +353 -0
  26. data/lib/rubygems/commands/sources_command.rb +5 -0
  27. data/lib/rubygems/commands/specification_command.rb +23 -3
  28. data/lib/rubygems/commands/uninstall_command.rb +71 -61
  29. data/lib/rubygems/commands/unpack_command.rb +14 -12
  30. data/lib/rubygems/commands/update_command.rb +26 -5
  31. data/lib/rubygems/defaults.rb +16 -3
  32. data/lib/rubygems/dependency.rb +38 -7
  33. data/lib/rubygems/dependency_installer.rb +7 -4
  34. data/lib/rubygems/digest/digest_adapter.rb +42 -33
  35. data/lib/rubygems/digest/sha1.rb +6 -1
  36. data/lib/rubygems/digest/sha2.rb +5 -0
  37. data/lib/rubygems/doc_manager.rb +31 -11
  38. data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
  39. data/lib/rubygems/ext/rake_builder.rb +6 -2
  40. data/lib/rubygems/format.rb +63 -63
  41. data/lib/rubygems/gem_openssl.rb +14 -2
  42. data/lib/rubygems/gem_path_searcher.rb +7 -3
  43. data/lib/rubygems/gem_runner.rb +59 -39
  44. data/lib/rubygems/indexer.rb +450 -109
  45. data/lib/rubygems/install_update_options.rb +13 -1
  46. data/lib/rubygems/installer.rb +25 -22
  47. data/lib/rubygems/local_remote_options.rb +5 -3
  48. data/lib/rubygems/old_format.rb +124 -120
  49. data/lib/rubygems/package/tar_header.rb +25 -3
  50. data/lib/rubygems/package/tar_input.rb +5 -5
  51. data/lib/rubygems/package/tar_output.rb +2 -0
  52. data/lib/rubygems/package/tar_reader.rb +19 -0
  53. data/lib/rubygems/package/tar_reader/entry.rb +43 -0
  54. data/lib/rubygems/package/tar_writer.rb +65 -3
  55. data/lib/rubygems/package_task.rb +117 -0
  56. data/lib/rubygems/platform.rb +12 -8
  57. data/lib/rubygems/remote_fetcher.rb +43 -24
  58. data/lib/rubygems/require_paths_builder.rb +14 -12
  59. data/lib/rubygems/requirement.rb +15 -6
  60. data/lib/rubygems/rubygems_version.rb +14 -1
  61. data/lib/rubygems/source_index.rb +38 -16
  62. data/lib/rubygems/source_info_cache_entry.rb +2 -2
  63. data/lib/rubygems/spec_fetcher.rb +43 -20
  64. data/lib/rubygems/specification.rb +1122 -947
  65. data/lib/rubygems/text.rb +30 -0
  66. data/lib/rubygems/timer.rb +14 -11
  67. data/lib/rubygems/uninstaller.rb +25 -5
  68. data/lib/rubygems/user_interaction.rb +294 -264
  69. data/lib/rubygems/validator.rb +70 -36
  70. data/lib/rubygems/version.rb +97 -33
  71. data/lib/rubygems/version_option.rb +1 -0
  72. data/setup.rb +11 -306
  73. data/test/foo/discover.rb +0 -0
  74. data/test/gem_installer_test_case.rb +22 -11
  75. data/test/gem_package_tar_test_case.rb +0 -14
  76. data/test/gemutilities.rb +89 -8
  77. data/test/mockgemui.rb +2 -1
  78. data/test/rubygems_plugin.rb +16 -0
  79. data/test/test_gem.rb +107 -36
  80. data/test/test_gem_command.rb +3 -13
  81. data/test/test_gem_command_manager.rb +1 -14
  82. data/test/test_gem_commands_cert_command.rb +1 -1
  83. data/test/test_gem_commands_contents_command.rb +63 -0
  84. data/test/test_gem_commands_environment_command.rb +1 -1
  85. data/test/test_gem_commands_generate_index_command.rb +104 -1
  86. data/test/test_gem_commands_install_command.rb +95 -0
  87. data/test/test_gem_commands_pristine_command.rb +3 -3
  88. data/test/test_gem_commands_query_command.rb +46 -0
  89. data/test/test_gem_commands_sources_command.rb +9 -5
  90. data/test/test_gem_commands_specification_command.rb +31 -0
  91. data/test/test_gem_commands_uninstall_command.rb +3 -2
  92. data/test/test_gem_commands_unpack_command.rb +3 -2
  93. data/test/test_gem_commands_update_command.rb +12 -7
  94. data/test/test_gem_dependency.rb +62 -11
  95. data/test/test_gem_dependency_installer.rb +18 -5
  96. data/test/test_gem_dependency_list.rb +6 -6
  97. data/test/test_gem_doc_manager.rb +7 -1
  98. data/test/test_gem_ext_configure_builder.rb +8 -10
  99. data/test/test_gem_ext_ext_conf_builder.rb +14 -8
  100. data/test/test_gem_gem_path_searcher.rb +1 -1
  101. data/test/test_gem_gem_runner.rb +11 -0
  102. data/test/test_gem_indexer.rb +398 -21
  103. data/test/test_gem_install_update_options.rb +20 -6
  104. data/test/test_gem_installer.rb +22 -14
  105. data/test/test_gem_local_remote_options.rb +2 -1
  106. data/test/test_gem_package_tar_header.rb +3 -3
  107. data/test/test_gem_package_tar_input.rb +3 -3
  108. data/test/test_gem_package_tar_output.rb +2 -2
  109. data/test/test_gem_package_task.rb +70 -0
  110. data/test/test_gem_platform.rb +12 -6
  111. data/test/test_gem_remote_fetcher.rb +23 -1
  112. data/test/test_gem_source_index.rb +32 -21
  113. data/test/test_gem_spec_fetcher.rb +77 -5
  114. data/test/test_gem_specification.rb +274 -1
  115. data/test/test_gem_uninstaller.rb +34 -4
  116. data/test/test_gem_version.rb +94 -4
  117. data/test/test_gem_version_option.rb +13 -0
  118. data/test/test_kernel.rb +4 -4
  119. data/util/CL2notes +56 -0
  120. data/util/gem_prelude.rb.template +251 -0
  121. metadata +30 -20
  122. metadata.gz.sig +3 -4
  123. data/TODO +0 -1
  124. data/scripts/buildtests.rb +0 -31
  125. data/scripts/gemdoc.rb +0 -67
  126. data/scripts/runtest.rb +0 -40
  127. data/scripts/specdoc.rb +0 -171
  128. 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
- module Gem
6
- module Commands
7
- class UninstallCommand < Command
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
- def arguments # :nodoc:
48
- "GEMNAME name of gem to uninstall"
49
- end
10
+ class Gem::Commands::UninstallCommand < Gem::Command
50
11
 
51
- def defaults_str # :nodoc:
52
- "--version '#{Gem::Requirement.default}' --no-force " \
53
- "--install-dir #{Gem.dir}"
54
- end
12
+ include Gem::VersionOption
55
13
 
56
- def usage # :nodoc:
57
- "#{program_name} GEMNAME [GEMNAME ...]"
58
- end
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
- def execute
61
- get_all_gem_names.each do |gem_name|
62
- begin
63
- Gem::Uninstaller.new(gem_name, options).uninstall
64
- rescue Gem::GemNotInHomeException => e
65
- spec = e.spec
66
- alert("In order to remove #{spec.name}, please execute:\n" \
67
- "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
68
- end
69
- end
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
- gemname = get_one_gem_name
40
- path = get_path(gemname, options[:version])
41
-
42
- if path then
43
- basename = File.basename(path).sub(/\.gem$/, '')
44
- target_dir = File.expand_path File.join(options[:target], basename)
45
- FileUtils.mkdir_p target_dir
46
- Gem::Installer.new(path, :unpack => true).unpack target_dir
47
- say "Unpacked gem: '#{target_dir}'"
48
- else
49
- alert_error "Gem '#{gemname}' not installed."
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 => true,
20
- :force => false,
21
- :test => false
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
- installer.install name
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
@@ -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
- [user_dir, default_dir]
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
- baseruby = ConfigMap[:BASERUBY] || 'ruby'
49
- ConfigMap[:RUBY_INSTALL_NAME].sub(baseruby, '%s') rescue '%s'
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
  ##
@@ -72,7 +72,7 @@ class Gem::Dependency
72
72
  alias requirements_list requirement_list
73
73
 
74
74
  def normalize
75
- ver = @version_requirement.instance_eval { @version }
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 the dependency +other+.
93
- # This dependency will match if the name matches the other's name, and other
94
- # has only an equal version requirement that satisfies this dependency.
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
- return false unless self.class === other
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
- def hash # :nodoc:
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
- module Gem
9
-
10
- # There is an incompatibility between the way Ruby 1.8.5 and 1.8.6
11
- # handles digests. This DigestAdapter will take a pre-1.8.6 digest
12
- # and adapt it to the 1.8.6 API.
13
- #
14
- # Note that only the digest and hexdigest methods are adapted,
15
- # since these are the only functions used by Gems.
16
- #
17
- class DigestAdapter
18
-
19
- # Initialize a digest adapter.
20
- def initialize(digest_class)
21
- @digest_class = digest_class
22
- end
23
-
24
- # Return a new digester. Since we are only implementing the stateless
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
- end
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
+