rubygems-update 1.2.0 → 1.3.0

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.

Files changed (65) hide show
  1. data.tar.gz.sig +2 -4
  2. data/ChangeLog +155 -0
  3. data/Rakefile +20 -5
  4. data/doc/release_notes/rel_1_3_0.rdoc +125 -0
  5. data/lib/rubygems.rb +107 -15
  6. data/lib/rubygems/commands/contents_command.rb +1 -1
  7. data/lib/rubygems/commands/environment_command.rb +40 -0
  8. data/lib/rubygems/commands/help_command.rb +2 -2
  9. data/lib/rubygems/commands/install_command.rb +15 -0
  10. data/lib/rubygems/commands/lock_command.rb +15 -6
  11. data/lib/rubygems/commands/outdated_command.rb +1 -1
  12. data/lib/rubygems/commands/pristine_command.rb +1 -1
  13. data/lib/rubygems/commands/query_command.rb +14 -9
  14. data/lib/rubygems/commands/rdoc_command.rb +5 -1
  15. data/lib/rubygems/commands/specification_command.rb +2 -2
  16. data/lib/rubygems/commands/unpack_command.rb +1 -1
  17. data/lib/rubygems/commands/update_command.rb +23 -14
  18. data/lib/rubygems/commands/which_command.rb +4 -3
  19. data/lib/rubygems/config_file.rb +25 -3
  20. data/lib/rubygems/defaults.rb +42 -11
  21. data/lib/rubygems/dependency_installer.rb +19 -15
  22. data/lib/rubygems/doc_manager.rb +162 -115
  23. data/lib/rubygems/ext/builder.rb +2 -2
  24. data/lib/rubygems/ext/rake_builder.rb +1 -1
  25. data/lib/rubygems/gem_path_searcher.rb +35 -19
  26. data/lib/rubygems/indexer.rb +15 -6
  27. data/lib/rubygems/install_update_options.rb +7 -0
  28. data/lib/rubygems/installer.rb +85 -9
  29. data/lib/rubygems/local_remote_options.rb +7 -0
  30. data/lib/rubygems/package/tar_reader.rb +7 -7
  31. data/lib/rubygems/platform.rb +1 -18
  32. data/lib/rubygems/remote_fetcher.rb +45 -54
  33. data/lib/rubygems/rubygems_version.rb +1 -1
  34. data/lib/rubygems/source_index.rb +22 -7
  35. data/lib/rubygems/source_info_cache.rb +9 -0
  36. data/lib/rubygems/spec_fetcher.rb +18 -20
  37. data/lib/rubygems/specification.rb +502 -293
  38. data/lib/rubygems/test_utilities.rb +19 -8
  39. data/lib/rubygems/uninstaller.rb +60 -26
  40. data/setup.rb +15 -7
  41. data/test/gemutilities.rb +84 -0
  42. data/test/mockgemui.rb +22 -2
  43. data/test/test_gem.rb +118 -13
  44. data/test/test_gem_commands_dependency_command.rb +1 -1
  45. data/test/test_gem_commands_list_command.rb +37 -0
  46. data/test/test_gem_commands_lock_command.rb +69 -0
  47. data/test/test_gem_commands_query_command.rb +40 -1
  48. data/test/test_gem_commands_uninstall_command.rb +60 -0
  49. data/test/test_gem_config_file.rb +51 -17
  50. data/test/test_gem_ext_configure_builder.rb +9 -9
  51. data/test/test_gem_ext_rake_builder.rb +21 -12
  52. data/test/test_gem_gem_path_searcher.rb +15 -7
  53. data/test/test_gem_indexer.rb +35 -1
  54. data/test/test_gem_install_update_options.rb +26 -5
  55. data/test/test_gem_installer.rb +93 -21
  56. data/test/test_gem_local_remote_options.rb +12 -0
  57. data/test/test_gem_platform.rb +6 -13
  58. data/test/test_gem_remote_fetcher.rb +121 -31
  59. data/test/test_gem_source_index.rb +74 -21
  60. data/test/test_gem_source_info_cache.rb +2 -1
  61. data/test/test_gem_spec_fetcher.rb +13 -3
  62. data/test/test_gem_specification.rb +13 -7
  63. data/test/test_gem_uninstaller.rb +25 -2
  64. metadata +6 -2
  65. metadata.gz.sig +0 -0
@@ -38,9 +38,17 @@ class Gem::DependencyInstaller
38
38
  # :ignore_dependencies:: Don't install any dependencies.
39
39
  # :install_dir:: See Gem::Installer#install.
40
40
  # :security_policy:: See Gem::Installer::new and Gem::Security.
41
+ # :user_install:: See Gem::Installer.new
41
42
  # :wrappers:: See Gem::Installer::new
42
43
 
43
44
  def initialize(options = {})
45
+ if options[:install_dir] then
46
+ spec_dir = options[:install_dir], 'specifications'
47
+ @source_index = Gem::SourceIndex.from_gems_in spec_dir
48
+ else
49
+ @source_index = Gem.source_index
50
+ end
51
+
44
52
  options = DEFAULT_OPTIONS.merge options
45
53
 
46
54
  @bin_dir = options[:bin_dir]
@@ -51,19 +59,13 @@ class Gem::DependencyInstaller
51
59
  @format_executable = options[:format_executable]
52
60
  @ignore_dependencies = options[:ignore_dependencies]
53
61
  @security_policy = options[:security_policy]
62
+ @user_install = options[:user_install]
54
63
  @wrappers = options[:wrappers]
55
64
 
56
65
  @installed_gems = []
57
66
 
58
67
  @install_dir = options[:install_dir] || Gem.dir
59
68
  @cache_dir = options[:cache_dir] || @install_dir
60
-
61
- if options[:install_dir] then
62
- spec_dir = File.join @install_dir, 'specifications'
63
- @source_index = Gem::SourceIndex.from_gems_in spec_dir
64
- else
65
- @source_index = Gem.source_index
66
- end
67
69
  end
68
70
 
69
71
  ##
@@ -232,15 +234,17 @@ class Gem::DependencyInstaller
232
234
  end
233
235
 
234
236
  inst = Gem::Installer.new local_gem_path,
235
- :env_shebang => @env_shebang,
236
- :force => @force,
237
- :format_executable => @format_executable,
237
+ :bin_dir => @bin_dir,
238
+ :development => @development,
239
+ :env_shebang => @env_shebang,
240
+ :force => @force,
241
+ :format_executable => @format_executable,
238
242
  :ignore_dependencies => @ignore_dependencies,
239
- :install_dir => @install_dir,
240
- :security_policy => @security_policy,
241
- :wrappers => @wrappers,
242
- :bin_dir => @bin_dir,
243
- :development => @development
243
+ :install_dir => @install_dir,
244
+ :security_policy => @security_policy,
245
+ :source_index => @source_index,
246
+ :user_install => @user_install,
247
+ :wrappers => @wrappers
244
248
 
245
249
  spec = inst.install
246
250
 
@@ -5,132 +5,194 @@
5
5
  #++
6
6
 
7
7
  require 'fileutils'
8
+ require 'rubygems'
8
9
 
9
- module Gem
10
+ ##
11
+ # The documentation manager generates RDoc and RI for RubyGems.
10
12
 
11
- class DocManager
13
+ class Gem::DocManager
12
14
 
13
- include UserInteraction
15
+ include Gem::UserInteraction
14
16
 
15
- # Create a document manager for the given gem spec.
16
- #
17
- # spec:: The Gem::Specification object representing the gem.
18
- # rdoc_args:: Optional arguments for RDoc (template etc.) as a String.
19
- #
20
- def initialize(spec, rdoc_args="")
21
- @spec = spec
22
- @doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
23
- @rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
17
+ @configured_args = []
18
+
19
+ def self.configured_args
20
+ @configured_args ||= []
21
+ end
22
+
23
+ def self.configured_args=(args)
24
+ case args
25
+ when Array
26
+ @configured_args = args
27
+ when String
28
+ @configured_args = args.split
24
29
  end
30
+ end
31
+
32
+ ##
33
+ # Load RDoc from a gem if it is available, otherwise from Ruby's stdlib
25
34
 
26
- # Is the RDoc documentation installed?
27
- def rdoc_installed?
28
- return File.exist?(File.join(@doc_dir, "rdoc"))
35
+ def self.load_rdoc
36
+ begin
37
+ gem 'rdoc'
38
+ rescue Gem::LoadError
39
+ # use built-in RDoc
29
40
  end
30
41
 
31
- # Generate the RI documents for this gem spec.
32
- #
33
- # Note that if both RI and RDoc documents are generated from the
34
- # same process, the RI docs should be done first (a likely bug in
35
- # RDoc will cause RI docs generation to fail if run after RDoc).
36
- def generate_ri
37
- if @spec.has_rdoc then
38
- load_rdoc
39
- install_ri # RDoc bug, ri goes first
40
- end
42
+ begin
43
+ require 'rdoc/rdoc'
44
+ rescue LoadError => e
45
+ raise Gem::DocumentError,
46
+ "ERROR: RDoc documentation generator not installed!"
47
+ end
48
+ end
49
+
50
+ ##
51
+ # Updates the RI cache for RDoc 2 if it is installed
52
+
53
+ def self.update_ri_cache
54
+ load_rdoc rescue return
55
+
56
+ return unless defined? RDoc::VERSION # RDoc 1 does not have VERSION
41
57
 
42
- FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
58
+ require 'rdoc/ri/driver'
59
+
60
+ options = {
61
+ :use_cache => true,
62
+ :use_system => true,
63
+ :use_site => true,
64
+ :use_home => true,
65
+ :use_gems => true,
66
+ :formatter => RDoc::RI::Formatter,
67
+ }
68
+
69
+ driver = RDoc::RI::Driver.new(options).class_cache
70
+ end
71
+
72
+ ##
73
+ # Create a document manager for +spec+. +rdoc_args+ contains arguments for
74
+ # RDoc (template etc.) as a String.
75
+
76
+ def initialize(spec, rdoc_args="")
77
+ @spec = spec
78
+ @doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
79
+ @rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
80
+ end
81
+
82
+ ##
83
+ # Is the RDoc documentation installed?
84
+
85
+ def rdoc_installed?
86
+ File.exist?(File.join(@doc_dir, "rdoc"))
87
+ end
88
+
89
+ ##
90
+ # Generate the RI documents for this gem spec.
91
+ #
92
+ # Note that if both RI and RDoc documents are generated from the same
93
+ # process, the RI docs should be done first (a likely bug in RDoc will cause
94
+ # RI docs generation to fail if run after RDoc).
95
+
96
+ def generate_ri
97
+ if @spec.has_rdoc then
98
+ setup_rdoc
99
+ install_ri # RDoc bug, ri goes first
43
100
  end
44
101
 
45
- # Generate the RDoc documents for this gem spec.
46
- #
47
- # Note that if both RI and RDoc documents are generated from the
48
- # same process, the RI docs should be done first (a likely bug in
49
- # RDoc will cause RI docs generation to fail if run after RDoc).
50
- def generate_rdoc
51
- if @spec.has_rdoc then
52
- load_rdoc
53
- install_rdoc
54
- end
102
+ FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
103
+ end
55
104
 
56
- FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
105
+ ##
106
+ # Generate the RDoc documents for this gem spec.
107
+ #
108
+ # Note that if both RI and RDoc documents are generated from the same
109
+ # process, the RI docs should be done first (a likely bug in RDoc will cause
110
+ # RI docs generation to fail if run after RDoc).
111
+
112
+ def generate_rdoc
113
+ if @spec.has_rdoc then
114
+ setup_rdoc
115
+ install_rdoc
57
116
  end
58
117
 
59
- # Load the RDoc documentation generator library.
60
- def load_rdoc
61
- if File.exist?(@doc_dir) && !File.writable?(@doc_dir) then
62
- raise Gem::FilePermissionError.new(@doc_dir)
63
- end
118
+ FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
119
+ end
64
120
 
65
- FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
121
+ ##
122
+ # Generate and install RDoc into the documentation directory
66
123
 
67
- begin
68
- gem 'rdoc'
69
- rescue Gem::LoadError
70
- # use built-in RDoc
71
- end
124
+ def install_rdoc
125
+ rdoc_dir = File.join @doc_dir, 'rdoc'
72
126
 
73
- begin
74
- require 'rdoc/rdoc'
75
- rescue LoadError => e
76
- raise Gem::DocumentError,
77
- "ERROR: RDoc documentation generator not installed!"
78
- end
79
- end
127
+ FileUtils.rm_rf rdoc_dir
80
128
 
81
- def install_rdoc
82
- rdoc_dir = File.join @doc_dir, 'rdoc'
129
+ say "Installing RDoc documentation for #{@spec.full_name}..."
130
+ run_rdoc '--op', rdoc_dir
131
+ end
83
132
 
84
- FileUtils.rm_rf rdoc_dir
133
+ ##
134
+ # Generate and install RI into the documentation directory
85
135
 
86
- say "Installing RDoc documentation for #{@spec.full_name}..."
87
- run_rdoc '--op', rdoc_dir
88
- end
136
+ def install_ri
137
+ ri_dir = File.join @doc_dir, 'ri'
89
138
 
90
- def install_ri
91
- ri_dir = File.join @doc_dir, 'ri'
139
+ FileUtils.rm_rf ri_dir
92
140
 
93
- FileUtils.rm_rf ri_dir
141
+ say "Installing ri documentation for #{@spec.full_name}..."
142
+ run_rdoc '--ri', '--op', ri_dir
143
+ end
94
144
 
95
- say "Installing ri documentation for #{@spec.full_name}..."
96
- run_rdoc '--ri', '--op', ri_dir
145
+ ##
146
+ # Run RDoc with +args+, which is an ARGV style argument list
147
+
148
+ def run_rdoc(*args)
149
+ args << @spec.rdoc_options
150
+ args << self.class.configured_args
151
+ args << '--quiet'
152
+ args << @spec.require_paths.clone
153
+ args << @spec.extra_rdoc_files
154
+ args = args.flatten.map do |arg| arg.to_s end
155
+
156
+ r = RDoc::RDoc.new
157
+
158
+ old_pwd = Dir.pwd
159
+ Dir.chdir(@spec.full_gem_path)
160
+ begin
161
+ r.document args
162
+ rescue Errno::EACCES => e
163
+ dirname = File.dirname e.message.split("-")[1].strip
164
+ raise Gem::FilePermissionError.new(dirname)
165
+ rescue RuntimeError => ex
166
+ alert_error "While generating documentation for #{@spec.full_name}"
167
+ ui.errs.puts "... MESSAGE: #{ex}"
168
+ ui.errs.puts "... RDOC args: #{args.join(' ')}"
169
+ ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
170
+ Gem.configuration.backtrace
171
+ ui.errs.puts "(continuing with the rest of the installation)"
172
+ ensure
173
+ Dir.chdir(old_pwd)
97
174
  end
175
+ end
98
176
 
99
- def run_rdoc(*args)
100
- args << @spec.rdoc_options
101
- args << DocManager.configured_args
102
- args << '--quiet'
103
- args << @spec.require_paths.clone
104
- args << @spec.extra_rdoc_files
105
- args = args.flatten.map do |arg| arg.to_s end
106
-
107
- r = RDoc::RDoc.new
108
-
109
- old_pwd = Dir.pwd
110
- Dir.chdir(@spec.full_gem_path)
111
- begin
112
- r.document args
113
- rescue Errno::EACCES => e
114
- dirname = File.dirname e.message.split("-")[1].strip
115
- raise Gem::FilePermissionError.new(dirname)
116
- rescue RuntimeError => ex
117
- alert_error "While generating documentation for #{@spec.full_name}"
118
- ui.errs.puts "... MESSAGE: #{ex}"
119
- ui.errs.puts "... RDOC args: #{args.join(' ')}"
120
- ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
121
- Gem.configuration.backtrace
122
- ui.errs.puts "(continuing with the rest of the installation)"
123
- ensure
124
- Dir.chdir(old_pwd)
125
- end
177
+ def setup_rdoc
178
+ if File.exist?(@doc_dir) && !File.writable?(@doc_dir) then
179
+ raise Gem::FilePermissionError.new(@doc_dir)
126
180
  end
127
181
 
128
- def uninstall_doc
129
- raise Gem::FilePermissionError.new(@spec.installation_path) unless
130
- File.writable? @spec.installation_path
182
+ FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
131
183
 
132
- original_name = [
133
- @spec.name, @spec.version, @spec.original_platform].join '-'
184
+ self.class.load_rdoc
185
+ end
186
+
187
+ ##
188
+ # Remove RDoc and RI documentation
189
+
190
+ def uninstall_doc
191
+ raise Gem::FilePermissionError.new(@spec.installation_path) unless
192
+ File.writable? @spec.installation_path
193
+
194
+ original_name = [
195
+ @spec.name, @spec.version, @spec.original_platform].join '-'
134
196
 
135
197
  doc_dir = File.join @spec.installation_path, 'doc', @spec.full_name
136
198
  unless File.directory? doc_dir then
@@ -146,22 +208,7 @@ module Gem
146
208
  end
147
209
 
148
210
  FileUtils.rm_rf ri_dir
149
- end
150
-
151
- class << self
152
- def configured_args
153
- @configured_args ||= []
154
- end
155
-
156
- def configured_args=(args)
157
- case args
158
- when Array
159
- @configured_args = args
160
- when String
161
- @configured_args = args.split
162
- end
163
- end
164
- end
165
-
166
211
  end
212
+
167
213
  end
214
+
@@ -35,7 +35,7 @@ class Gem::Ext::Builder
35
35
  results << `#{cmd} #{redirector}`
36
36
 
37
37
  raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless
38
- $?.exitstatus.zero?
38
+ $?.success?
39
39
  end
40
40
  end
41
41
 
@@ -47,7 +47,7 @@ class Gem::Ext::Builder
47
47
  results << command
48
48
  results << `#{command} #{redirector}`
49
49
 
50
- unless $?.exitstatus.zero? then
50
+ unless $?.success? then
51
51
  raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}"
52
52
  end
53
53
  end
@@ -16,7 +16,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
16
16
  end
17
17
 
18
18
  cmd = ENV['rake'] || 'rake'
19
- cmd << " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"
19
+ cmd += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
20
20
 
21
21
  run cmd, results
22
22
 
@@ -6,15 +6,15 @@
6
6
 
7
7
  require 'rubygems'
8
8
 
9
- #
9
+ ##
10
10
  # GemPathSearcher has the capability to find loadable files inside
11
11
  # gems. It generates data up front to speed up searches later.
12
- #
12
+
13
13
  class Gem::GemPathSearcher
14
14
 
15
- #
15
+ ##
16
16
  # Initialise the data we need to make searches later.
17
- #
17
+
18
18
  def initialize
19
19
  # We want a record of all the installed gemspecs, in the order
20
20
  # we wish to examine them.
@@ -27,7 +27,7 @@ class Gem::GemPathSearcher
27
27
  end
28
28
  end
29
29
 
30
- #
30
+ ##
31
31
  # Look in all the installed gems until a matching _path_ is found.
32
32
  # Return the _gemspec_ of the gem where it was found. If no match
33
33
  # is found, return nil.
@@ -46,36 +46,52 @@ class Gem::GemPathSearcher
46
46
  # others), which may or may not already be attached to _file_.
47
47
  # This method doesn't care about the full filename that matches;
48
48
  # only that there is a match.
49
- #
49
+
50
50
  def find(path)
51
- @gemspecs.each do |spec|
52
- return spec if matching_file(spec, path)
51
+ @gemspecs.find do |spec| matching_file? spec, path end
52
+ end
53
+
54
+ ##
55
+ # Works like #find, but finds all gemspecs matching +path+.
56
+
57
+ def find_all(path)
58
+ @gemspecs.select do |spec|
59
+ matching_file? spec, path
53
60
  end
54
- nil
55
61
  end
56
62
 
57
- private
63
+ ##
64
+ # Attempts to find a matching path using the require_paths of the given
65
+ # +spec+.
58
66
 
59
- # Attempts to find a matching path using the require_paths of the
60
- # given _spec_.
61
- #
62
- # Some of the intermediate results are cached in @lib_dirs for
63
- # speed.
64
- def matching_file(spec, path) # :doc:
67
+ def matching_file?(spec, path)
68
+ !matching_files(spec, path).empty?
69
+ end
70
+
71
+ ##
72
+ # Returns files matching +path+ in +spec+.
73
+ #--
74
+ # Some of the intermediate results are cached in @lib_dirs for speed.
75
+
76
+ def matching_files(spec, path)
65
77
  glob = File.join @lib_dirs[spec.object_id], "#{path}#{Gem.suffix_pattern}"
66
- return true unless Dir[glob].select { |f| File.file?(f.untaint) }.empty?
78
+ Dir[glob].select { |f| File.file? f.untaint }
67
79
  end
68
80
 
69
- # Return a list of all installed gemspecs, sorted by alphabetical
70
- # order and in reverse version order.
81
+ ##
82
+ # Return a list of all installed gemspecs, sorted by alphabetical order and
83
+ # in reverse version order.
84
+
71
85
  def init_gemspecs
72
86
  Gem.source_index.map { |_, spec| spec }.sort { |a,b|
73
87
  (a.name <=> b.name).nonzero? || (b.version <=> a.version)
74
88
  }
75
89
  end
76
90
 
91
+ ##
77
92
  # Returns library directories glob for a gemspec. For example,
78
93
  # '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'
94
+
79
95
  def lib_dirs_for(spec)
80
96
  "#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}"
81
97
  end