rubygems-update 0.9.5 → 1.0.0

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.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (53) hide show
  1. data/ChangeLog +135 -0
  2. data/Rakefile +3 -1
  3. data/lib/rubygems.rb +27 -38
  4. data/lib/rubygems/commands/install_command.rb +2 -0
  5. data/lib/rubygems/commands/mirror_command.rb +8 -2
  6. data/lib/rubygems/commands/query_command.rb +3 -1
  7. data/lib/rubygems/commands/server_command.rb +3 -3
  8. data/lib/rubygems/commands/unpack_command.rb +11 -4
  9. data/lib/rubygems/commands/update_command.rb +114 -108
  10. data/lib/rubygems/defaults.rb +46 -0
  11. data/lib/rubygems/dependency_installer.rb +13 -2
  12. data/lib/rubygems/indexer.rb +1 -1
  13. data/lib/rubygems/install_update_options.rb +7 -0
  14. data/lib/rubygems/installer.rb +66 -11
  15. data/lib/rubygems/package.rb +2 -1
  16. data/lib/rubygems/platform.rb +24 -30
  17. data/lib/rubygems/remote_fetcher.rb +7 -3
  18. data/lib/rubygems/require_paths_builder.rb +15 -0
  19. data/lib/rubygems/rubygems_version.rb +1 -1
  20. data/lib/rubygems/security.rb +1 -1
  21. data/lib/rubygems/server.rb +18 -3
  22. data/lib/rubygems/source_index.rb +20 -23
  23. data/lib/rubygems/source_info_cache.rb +3 -3
  24. data/lib/rubygems/specification.rb +64 -31
  25. data/lib/rubygems/uninstaller.rb +1 -1
  26. data/lib/rubygems/validator.rb +3 -2
  27. data/lib/rubygems/version.rb +10 -3
  28. data/setup.rb +30 -6
  29. data/test/gemutilities.rb +23 -13
  30. data/test/gemutilities.rbc +0 -0
  31. data/test/mockgemui.rbc +0 -0
  32. data/test/test_gem.rb +46 -76
  33. data/test/test_gem.rbc +0 -0
  34. data/test/test_gem_commands_build_command.rb +12 -12
  35. data/test/test_gem_commands_dependency_command.rb +10 -10
  36. data/test/test_gem_commands_mirror_command.rb +9 -4
  37. data/test/test_gem_commands_query_command.rb +7 -3
  38. data/test/test_gem_commands_server_command.rb +27 -0
  39. data/test/test_gem_commands_unpack_command.rb +20 -2
  40. data/test/test_gem_format.rb +1 -1
  41. data/test/test_gem_indexer.rb +5 -5
  42. data/test/test_gem_install_update_options.rb +1 -1
  43. data/test/test_gem_installer.rb +149 -60
  44. data/test/test_gem_platform.rb +19 -0
  45. data/test/test_gem_remote_fetcher.rb +19 -2
  46. data/test/test_gem_server.rb +44 -1
  47. data/test/test_gem_source_index.rb +2 -2
  48. data/test/test_gem_specification.rb +300 -168
  49. data/test/test_gem_version.rb +15 -0
  50. data/test/test_kernel.rb +19 -19
  51. metadata +46 -42
  52. data/lib/rubygems/remote_installer.rb +0 -195
  53. data/test/test_gem_remote_installer.rb +0 -161
data/ChangeLog CHANGED
@@ -1,3 +1,138 @@
1
+ 2007-12-19 Eric Hodel <drbrain@segment7.net>
2
+
3
+ * lib/rubygems/installer.rb: Revert change that only wrapped
4
+ executables with #!.
5
+ * lib/rubygems/specification.rb: Warn about a lot of things that
6
+ could be wrong with gemspecs on build, including missing #!. Use
7
+ 'x86-mswin32' for legacy 'mswin32' platform, fix CURRENT platform.
8
+ Paired with Luis Lavena.
9
+ * lib/rubygems/remote_installer.rb: Deleted.
10
+ * lib/rubygems.rb: Removed Kernel#require_gem.
11
+ * doc/release_notes/rel_1_0_0.rdoc: RubyGems 1.0 release notes.
12
+ * lib/rubygems/rubygems_version.rb: 1.0.0.
13
+
14
+ 2007-12-18 Luis Lavena <luislavena@gmail.com>
15
+
16
+ * lib/rubygems/commands/mirror_command.rb: Work around URI::parse
17
+ processing file:// scheme and drive paths on Windows.
18
+ * test/test_gem_commands_mirror_command.rb: ditto.
19
+
20
+ 2007-12-17 Eric Hodel <drbrain@segment7.net>
21
+
22
+ * lib/rubygems/installer.rb: Copy files into bindir if they don't
23
+ have a shebang. Bug reported by Luis Lavena.
24
+ * lib/rubygems/server.rb: Handle platforms in Gem::Server#quick.
25
+ Exactly match gem names. Bugs reported by Chad Woolley.
26
+ * lib/rubygems/platform.rb: Remove platform constants in favor of
27
+ Gem::Platform::CURRENT. Bug reported by Luis Lavena.
28
+ * lib/rubygems/dependency_installer.rb: Work around Dir::glob not
29
+ understanding File::ALT_SEPARATOR. Bug submitted by Luis Lavena.
30
+
31
+ 2007-12-16 Eric Hodel <drbrain@segment7.net>
32
+
33
+ * lib/rubygems/remote_fetcher.rb: Be more verbose in error messages
34
+ from OpenURI.
35
+ * lib/rubygems/server.rb: Be more verbose in error/missing responses.
36
+
37
+ 2007-12-15 Eric Hodel <drbrain@segment7.net>
38
+
39
+ * lib/rubygems/installer.rb: Output extension build results when
40
+ really verbose. From bug #15853 John Croisant.
41
+ * lib/rubygems/specification.rb: Fix backwards compatibility with
42
+ 0.9.4, don't allow the platform to be nil or an empty string. Bug
43
+ #16177 by Dan Manges.
44
+ * setup.rb: Re-exec setup.rb if rubygems is loaded and RUBYOPT is
45
+ set. Fixes bug #15974 by Joshua Sierles.
46
+ * lib/rubygems/update_command.rb: Tweak formatting of updated
47
+ message. Bug #15625 by Bil Kleb.
48
+ * lib/rubygems/remote_fetcher.rb: Add URI to exception message for
49
+ Gem::RemoteFetcher#fetch_size. Bug #14801 by Bil Kleb.
50
+
51
+ 2007-12-14 Eric Hodel <drbrain@segment7.net>
52
+
53
+ * lib/rubygems/commands/query_command.rb: Don't display duplicate
54
+ version numbers. Bug #15828 by Tim Fletcher.
55
+ * setup.rb: Fix my stupidity with --help. Patch #16308 by Stephen
56
+ Bannasch. Fix --prefix= argument. Bug #16002 by Piglop.
57
+
58
+ 2007-12-13 Eric Hodel <drbrain@segment7.net>
59
+
60
+ * lib/rubygems/commands/server_command.rb: Fix --no-daemon. Bug by
61
+ Chad Woolley.
62
+ * lib/rubygems/server.rb: Fix Marshal quick index. Bug by Chad
63
+ Woolley.
64
+ * lib/rubygems/installer.rb: Respect Gem::Specification#bindir. Bug
65
+ #16202 by Suraj Kurapati.
66
+ * lib/rubygems/commands/update_command.rb: Fix `gem update mysql`.
67
+ Bug #16244 by Stephen Bannasch.
68
+
69
+ 2007-12-12 Eric Hodel <drbrain@segment7.net>
70
+
71
+ * lib/rubygems/installer.rb: Add --format-executable option to
72
+ install executables with ruby's program-suffix and prefix. Patch
73
+ #14688 by Jeremy Kemper. Also, installing in really-verbose mode
74
+ prints out written files.
75
+ * setup.rb: Add --format-executable option to install gem with ruby's
76
+ program-suffix and prefix. Add --help. Fixes bug #16056 by Chad
77
+ Woolley.
78
+ * lib/rubygems/uninstaller.rb: Fallback to original_platform_name
79
+ correctly. Patch #15960 by Nicola Piccinini's friend.
80
+
81
+ 2007-12-11 Eric Hodel <drbrain@segment7.net>
82
+
83
+ * lib/rubygems/validator.rb: Correct test run failures when no tests
84
+ are provided. Patch #15701 by Jérémy Zurcher.
85
+ * lib/rubygems/commands/mirror_command.rb: Don't File.join a
86
+ URI::HTTP. Patch #16116 by Morgan Nelson.
87
+ * lib/rubygems/commands/unpack_command.rb: Add --target option to
88
+ `gem unpack`. Patch #16154 by Kevin Barnes.
89
+
90
+ 2007-12-10 Eric Hodel <drbrain@segment7.net>
91
+
92
+ * lib/rubygems/dependency_installer.rb: Revert to nil for the default
93
+ security policy to avoid requiring OpenSSL.
94
+ * lib/rubygems/defaults.rb: Consolidate defaults for easier editing.
95
+ Patch #15150 by Donavan Pantke.
96
+
97
+ 2007-11-27 Eric Hodel <drbrain@segment7.net>
98
+
99
+ * lib/rubygems/source_index.rb: Remove dependency on forwadable.
100
+ Patch by Koichi Sasada.
101
+ * lib/rubygems/specification.rb: Reduce dependency on time.rb. Patch
102
+ by Koichi Sasada.
103
+
104
+ 2007-11-26 Rich Kilmer <rich@infoether.com>
105
+
106
+ * lib/rubygems/version.rb: Fix bug 15948 with version bump
107
+ * test/test_gem_version.rb: Test for bug 15948 with version bump
108
+ * util/gem_prelude.rb: wrap init code with exception handler
109
+ and skip badly formed directory names
110
+
111
+ 2007-11-23 Rich Kilmer <rich@infoether.com>
112
+
113
+ * lib/rubygems.rb: Centralize all CONFIG options into Hash
114
+ Gem::ConfigMap with keys as symbols, change all references
115
+ to CONFIG to ConfigMap
116
+ * lib/rubygems/require_paths_builder.rb: Added to support
117
+ building .require_paths file
118
+ * lib/rubygems/installer.rb: Add building of .require_paths if
119
+ needed
120
+ * lib/rubygems/platform.rb: Use new ConfigMap hash for arch
121
+ * lib/rubygems
122
+ * util/gem_prelude.rb: new gem prelude for Ruby 1.9
123
+ * test/test_gem_installer.rb: change to use ConfigMap hash
124
+ * test/gemutilities.rb: change to use ConfigMap hash
125
+
126
+ 2007-11-21 Daniel Berger <djberg96@gmail.com>
127
+
128
+ * lib/rubygems/platform.rb: Gem::Platform.new now returns
129
+ Gem::Platform.local if the arch matches Gem::Platform::CURRENT.
130
+ Bugs #15815 and #15782 submitted by Daniel Berger.
131
+
132
+ 2007-11-20 Eric Hodel <drbrain@segment7.net>
133
+
134
+ * lib/rubygems/platform.rb: Handle bare 'mswin32' platform's CPU.
135
+
1
136
  2007-11-19 Eric Hodel <drbrain@segment7.net>
2
137
 
3
138
  * lib/rubygems/rubygems_version.rb: 0.9.5.
data/Rakefile CHANGED
@@ -384,13 +384,14 @@ task :update_ruby do
384
384
  sh "rsync #{options} bin/gem #{ruby_dir}/bin/gem"
385
385
  sh "rsync #{options} lib/ #{ruby_dir}/lib"
386
386
  sh "rsync #{options} test/ #{ruby_dir}/test/rubygems"
387
+ sh "rsync #{options} util/gem_prelude.rb #{ruby_dir}/gem_prelude.rb"
387
388
  end
388
389
 
389
390
  desc "Diffs Ruby HEAD with the currently checked-out copy of RubyGems."
390
391
  task :diff_ruby do
391
392
  ruby_dir = ENV['RUBY_PATH'] || '../../ruby/trunk'
392
393
 
393
- options = "-urpN --exclude '*svn*' --exclude '*swp'"
394
+ options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
394
395
 
395
396
  sh "diff #{options} bin/gem #{ruby_dir}/bin/gem; true"
396
397
  sh "diff #{options} lib/ubygems.rb #{ruby_dir}/lib/ubygems.rb; true"
@@ -398,5 +399,6 @@ task :diff_ruby do
398
399
  sh "diff #{options} lib/rubygems #{ruby_dir}/lib/rubygems; true"
399
400
  sh "diff #{options} lib/rbconfig #{ruby_dir}/lib/rbconfig; true"
400
401
  sh "diff #{options} test #{ruby_dir}/test/rubygems; true"
402
+ sh "diff #{options} util/gem_prelude.rb #{ruby_dir}/gem_prelude.rb; true"
401
403
  end
402
404
 
@@ -5,8 +5,8 @@
5
5
  # See LICENSE.txt for permissions.
6
6
  #++
7
7
 
8
- require 'rbconfig'
9
8
  require 'rubygems/rubygems_version'
9
+ require 'rubygems/defaults'
10
10
  require 'thread'
11
11
 
12
12
  module Gem
@@ -30,8 +30,8 @@ module Kernel
30
30
  # version).
31
31
  #
32
32
  # You can define the environment variable GEM_SKIP as a way to not
33
- # load specified gems. you might do this to test out changes that
34
- # haven't been intsalled yet. Example:
33
+ # load specified gems. You might do this to test out changes that
34
+ # haven't been installed yet. Example:
35
35
  #
36
36
  # GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
37
37
  #
@@ -50,17 +50,6 @@ module Kernel
50
50
  active_gem_with_options(gem_name, version_requirements)
51
51
  end
52
52
 
53
- # Same as the +gem+ command, but will also require a file if the gem
54
- # provides an auto-required file name.
55
- #
56
- # DEPRECATED! Use +gem+ instead.
57
- #
58
- def require_gem(gem_name, *version_requirements)
59
- file, lineno = location_of_caller
60
- warn "#{file}:#{lineno}:Warning: require_gem is obsolete. Use gem instead."
61
- active_gem_with_options(gem_name, version_requirements, :auto_require=>true)
62
- end
63
-
64
53
  # Return the file name (string) and line number (integer) of the caller of
65
54
  # the caller of this method.
66
55
  def location_of_caller
@@ -82,11 +71,27 @@ end
82
71
  #
83
72
  module Gem
84
73
 
74
+ ConfigMap = {} unless defined?(ConfigMap)
75
+ require 'rbconfig'
76
+ ConfigMap.merge!(
77
+ :BASERUBY => RbConfig::CONFIG["BASERUBY"],
78
+ :EXEEXT => RbConfig::CONFIG["EXEEXT"],
79
+ :RUBY_INSTALL_NAME => RbConfig::CONFIG["RUBY_INSTALL_NAME"],
80
+ :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
81
+ :arch => RbConfig::CONFIG["arch"],
82
+ :bindir => RbConfig::CONFIG["bindir"],
83
+ :libdir => RbConfig::CONFIG["libdir"],
84
+ :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
85
+ :ruby_version => RbConfig::CONFIG["ruby_version"],
86
+ :sitedir => RbConfig::CONFIG["sitedir"],
87
+ :sitelibdir => RbConfig::CONFIG["sitelibdir"]
88
+ )
89
+
85
90
  MUTEX = Mutex.new
86
91
 
87
92
  RubyGemsPackageVersion = RubyGemsVersion
88
93
 
89
- DIRECTORIES = %w[cache doc gems specifications]
94
+ DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
90
95
 
91
96
  @@source_index = nil
92
97
  @@win_platform = nil
@@ -120,7 +125,7 @@ module Gem
120
125
 
121
126
  def self.prefix
122
127
  prefix = File.dirname File.expand_path(__FILE__)
123
- if prefix == Config::CONFIG['sitelibdir'] then
128
+ if prefix == ConfigMap[:sitelibdir] then
124
129
  nil
125
130
  else
126
131
  File.dirname prefix
@@ -194,10 +199,6 @@ module Gem
194
199
  @sources
195
200
  end
196
201
 
197
- # An Array of the default sources that come with RubyGems.
198
- def default_sources
199
- %w[http://gems.rubyforge.org]
200
- end
201
202
 
202
203
  # Provide an alias for the old name.
203
204
  alias cache source_index
@@ -221,7 +222,7 @@ module Gem
221
222
  if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
222
223
  '/usr/bin'
223
224
  else # generic install
224
- Config::CONFIG['bindir']
225
+ ConfigMap[:bindir]
225
226
  end
226
227
  end
227
228
 
@@ -280,9 +281,9 @@ module Gem
280
281
  # Return the Ruby command to use to execute the Ruby interpreter.
281
282
  def ruby
282
283
  if @ruby.nil? then
283
- @ruby = File.join(Config::CONFIG['bindir'],
284
- Config::CONFIG['ruby_install_name'])
285
- @ruby << Config::CONFIG['EXEEXT']
284
+ @ruby = File.join(ConfigMap[:bindir],
285
+ ConfigMap[:ruby_install_name])
286
+ @ruby << ConfigMap[:EXEEXT]
286
287
  end
287
288
 
288
289
  @ruby
@@ -342,7 +343,7 @@ module Gem
342
343
  File.join spec.full_gem_path, path
343
344
  end
344
345
 
345
- sitelibdir = Config::CONFIG['sitelibdir']
346
+ sitelibdir = ConfigMap[:sitelibdir]
346
347
 
347
348
  # gem directories must come after -I and ENV['RUBYLIB']
348
349
  $:.insert($:.index(sitelibdir), *require_paths)
@@ -523,18 +524,6 @@ module Gem
523
524
  end
524
525
  end
525
526
 
526
- public
527
-
528
- # Default home directory path to be used if an alternate value is
529
- # not specified in the environment.
530
- def default_dir
531
- if defined? RUBY_FRAMEWORK_VERSION
532
- return File.join(File.dirname(Config::CONFIG["sitedir"]), "Gems", Config::CONFIG['ruby_version'])
533
- else
534
- File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])
535
- end
536
- end
537
-
538
527
  end
539
528
 
540
529
  end
@@ -549,7 +538,7 @@ module Config # :nodoc:
549
538
  # Return the path to the data directory associated with the named
550
539
  # package. If the package is loaded as a gem, return the gem
551
540
  # specific data directory. Otherwise return a path to the share
552
- # area as define by "#{Config::CONFIG['datadir']}/#{package_name}".
541
+ # area as define by "#{ConfigMap[:datadir]}/#{package_name}".
553
542
  def datadir(package_name)
554
543
  Gem.datadir(package_name) || Config.gem_original_datadir(package_name)
555
544
  end
@@ -17,6 +17,7 @@ class Gem::Commands::InstallCommand < Gem::Command
17
17
  :generate_rdoc => true,
18
18
  :generate_ri => true,
19
19
  :install_dir => Gem.dir,
20
+ :format_executable => false,
20
21
  :test => false,
21
22
  :version => Gem::Requirement.default,
22
23
  })
@@ -56,6 +57,7 @@ class Gem::Commands::InstallCommand < Gem::Command
56
57
  :env_shebang => options[:env_shebang],
57
58
  :domain => options[:domain],
58
59
  :force => options[:force],
60
+ :format_executable => options[:format_executable],
59
61
  :ignore_dependencies => options[:ignore_dependencies],
60
62
  :install_dir => options[:install_dir],
61
63
  :security_policy => options[:security_policy],
@@ -60,10 +60,16 @@ Multiple sources and destinations may be specified.
60
60
  if get_from.scheme.nil? then
61
61
  get_from = get_from.to_s
62
62
  elsif get_from.scheme == 'file' then
63
- get_from = get_from.to_s[5..-1]
63
+ # check if specified URI contains a drive letter (file:/D:/Temp)
64
+ get_from = get_from.to_s
65
+ get_from = if get_from =~ /^file:.*[a-z]:/i then
66
+ get_from[6..-1]
67
+ else
68
+ get_from[5..-1]
69
+ end
64
70
  end
65
71
 
66
- open File.join(get_from, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
72
+ open File.join(get_from.to_s, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
67
73
  sourceindex_data = Zlib::Inflate.inflate y.read
68
74
  open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
69
75
  out.write sourceindex_data
@@ -82,8 +82,10 @@ class Gem::Commands::QueryCommand < Gem::Command
82
82
  end
83
83
 
84
84
  entry = gem_name.dup
85
+
85
86
  if options[:versions] then
86
- entry << " (#{list_of_matching.map{|gem| gem.version.to_s}.join(", ")})"
87
+ versions = list_of_matching.map { |s| s.version }.uniq
88
+ entry << " (#{versions.join ', '})"
87
89
  end
88
90
 
89
91
  entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
@@ -7,17 +7,17 @@ class Gem::Commands::ServerCommand < Gem::Command
7
7
  super 'server', 'Documentation and gem repository HTTP server',
8
8
  :port => 8808, :gemdir => Gem.dir, :daemon => false
9
9
 
10
- add_option '-p', '--port=PORT',
10
+ add_option '-p', '--port=PORT', Integer,
11
11
  'port to listen on' do |port, options|
12
12
  options[:port] = port
13
13
  end
14
14
 
15
15
  add_option '-d', '--dir=GEMDIR',
16
16
  'directory from which to serve gems' do |gemdir, options|
17
- options[:gemdir] = gemdir
17
+ options[:gemdir] = File.expand_path gemdir
18
18
  end
19
19
 
20
- add_option '--[no]-daemon', 'run as a daemon' do |daemon, options|
20
+ add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
21
21
  options[:daemon] = daemon
22
22
  end
23
23
  end
@@ -9,7 +9,13 @@ class Gem::Commands::UnpackCommand < Gem::Command
9
9
 
10
10
  def initialize
11
11
  super 'unpack', 'Unpack an installed gem to the current directory',
12
- :version => Gem::Requirement.default
12
+ :version => Gem::Requirement.default,
13
+ :target => Dir.pwd
14
+
15
+ add_option('--target', 'target directory for unpacking') do |value, options|
16
+ options[:target] = value
17
+ end
18
+
13
19
  add_version_option
14
20
  end
15
21
 
@@ -32,10 +38,11 @@ class Gem::Commands::UnpackCommand < Gem::Command
32
38
  def execute
33
39
  gemname = get_one_gem_name
34
40
  path = get_path(gemname, options[:version])
35
- if path
36
- target_dir = File.basename(path).sub(/\.gem$/, '')
41
+ if path then
42
+ basename = File.basename(path).sub(/\.gem$/, '')
43
+ target_dir = File.expand_path File.join(options[:target], basename)
37
44
  FileUtils.mkdir_p target_dir
38
- Gem::Installer.new(path).unpack(File.expand_path(target_dir))
45
+ Gem::Installer.new(path).unpack target_dir
39
46
  say "Unpacked gem: '#{target_dir}'"
40
47
  else
41
48
  alert_error "Gem '#{gemname}' not installed."
@@ -4,146 +4,152 @@ require 'rubygems/local_remote_options'
4
4
  require 'rubygems/source_info_cache'
5
5
  require 'rubygems/version_option'
6
6
 
7
- module Gem
8
- module Commands
9
- class UpdateCommand < Command
7
+ class Gem::Commands::UpdateCommand < Gem::Command
10
8
 
11
- include Gem::InstallUpdateOptions
12
- include Gem::LocalRemoteOptions
13
- include Gem::VersionOption
9
+ include Gem::InstallUpdateOptions
10
+ include Gem::LocalRemoteOptions
11
+ include Gem::VersionOption
14
12
 
15
- def initialize
16
- super(
17
- 'update',
13
+ def initialize
14
+ super 'update',
18
15
  'Update the named gems (or all installed gems) in the local repository',
19
- {
20
- :generate_rdoc => true,
21
- :generate_ri => true,
22
- :force => false,
23
- :test => false,
24
- :install_dir => Gem.dir
25
- })
26
-
27
- add_install_update_options
28
-
29
- add_option('--system',
30
- 'Update the RubyGems system software') do |value, options|
31
- options[:system] = value
32
- end
16
+ :generate_rdoc => true,
17
+ :generate_ri => true,
18
+ :force => false,
19
+ :test => false,
20
+ :install_dir => Gem.dir
33
21
 
34
- add_local_remote_options
22
+ add_install_update_options
35
23
 
36
- add_platform_option
37
- end
24
+ add_option('--system',
25
+ 'Update the RubyGems system software') do |value, options|
26
+ options[:system] = value
27
+ end
38
28
 
39
- def arguments # :nodoc:
40
- "GEMNAME name of gem to update"
41
- end
29
+ add_local_remote_options
42
30
 
43
- def defaults_str # :nodoc:
44
- "--rdoc --ri --no-force --no-test\n" +
45
- "--install-dir #{Gem.dir}"
46
- end
31
+ add_platform_option
32
+ end
33
+
34
+ def arguments # :nodoc:
35
+ "GEMNAME name of gem to update"
36
+ end
47
37
 
48
- def usage # :nodoc:
49
- "#{program_name} GEMNAME [GEMNAME ...]"
38
+ def defaults_str # :nodoc:
39
+ "--rdoc --ri --no-force --no-test --install-dir #{Gem.dir}"
40
+ end
41
+
42
+ def usage # :nodoc:
43
+ "#{program_name} GEMNAME [GEMNAME ...]"
44
+ end
45
+
46
+ def execute
47
+ if options[:system] then
48
+ say "Updating RubyGems..."
49
+
50
+ unless options[:args].empty? then
51
+ fail "No gem names are allowed with the --system option"
50
52
  end
51
53
 
52
- def execute
53
- if options[:system] then
54
- say "Updating RubyGems..."
54
+ options[:args] = ["rubygems-update"]
55
+ else
56
+ say "Updating installed gems..."
57
+ end
55
58
 
56
- unless options[:args].empty? then
57
- fail "No gem names are allowed with the --system option"
58
- end
59
+ hig = highest_installed_gems = {}
59
60
 
60
- options[:args] = ["rubygems-update"]
61
- else
62
- say "Updating installed gems..."
63
- end
61
+ Gem::SourceIndex.from_installed_gems.each do |name, spec|
62
+ if hig[spec.name].nil? or hig[spec.name].version < spec.version then
63
+ hig[spec.name] = spec
64
+ end
65
+ end
64
66
 
65
- hig = highest_installed_gems = {}
67
+ remote_gemspecs = Gem::SourceInfoCache.search(//)
66
68
 
67
- Gem::SourceIndex.from_installed_gems.each do |name, spec|
68
- if hig[spec.name].nil? or hig[spec.name].version < spec.version
69
- hig[spec.name] = spec
70
- end
71
- end
69
+ gems_to_update = if options[:args].empty? then
70
+ which_to_update(highest_installed_gems, remote_gemspecs)
71
+ else
72
+ options[:args]
73
+ end
72
74
 
73
- remote_gemspecs = Gem::SourceInfoCache.search(//)
75
+ options[:domain] = :remote # install from remote source
74
76
 
75
- gems_to_update = if options[:args].empty? then
76
- which_to_update(highest_installed_gems, remote_gemspecs)
77
- else
78
- options[:args]
79
- end
77
+ # HACK use the real API
78
+ install_command = Gem::CommandManager.instance['install']
80
79
 
81
- options[:domain] = :remote # install from remote source
80
+ gems_to_update.uniq.sort.each do |name|
81
+ say "Attempting remote update of #{name}"
82
+ options[:args] = [name]
83
+ options[:ignore_dependencies] = true # HACK skip seen gems instead
84
+ install_command.merge_options(options)
85
+ install_command.execute
86
+ end
82
87
 
83
- # HACK use the real API
84
- install_command = Gem::CommandManager.instance['install']
88
+ if gems_to_update.include? "rubygems-update" then
89
+ latest_ruby_gem = remote_gemspecs.select do |s|
90
+ s.name == 'rubygems-update'
91
+ end
85
92
 
86
- gems_to_update.uniq.sort.each do |name|
87
- say "Attempting remote update of #{name}"
88
- options[:args] = [name]
89
- options[:ignore_dependencies] = true # HACK skip seen gems instead
90
- install_command.merge_options(options)
91
- install_command.execute
92
- end
93
+ latest_ruby_gem = latest_ruby_gem.sort_by { |s| s.version }.last
93
94
 
94
- if gems_to_update.include?("rubygems-update") then
95
- latest_ruby_gem = remote_gemspecs.select { |s|
96
- s.name == 'rubygems-update'
97
- }.sort_by { |s|
98
- s.version
99
- }.last
95
+ say "Updating version of RubyGems to #{latest_ruby_gem.version}"
96
+ installed = do_rubygems_update latest_ruby_gem.version
100
97
 
101
- say "Updating version of RubyGems to #{latest_ruby_gem.version}"
102
- installed = do_rubygems_update(latest_ruby_gem.version.to_s)
98
+ say "RubyGems system software updated" if installed
99
+ else
100
+ updated = gems_to_update.uniq.sort.collect { |g| g.to_s }
103
101
 
104
- say "RubyGems system software updated" if installed
105
- else
106
- say "Gems: [#{gems_to_update.uniq.sort.collect{|g| g.to_s}.join(', ')}] updated"
107
- end
102
+ if updated.empty? then
103
+ say "Nothing to update"
104
+ else
105
+ say "Gems updated: #{updated.join ', '}"
108
106
  end
107
+ end
108
+ end
109
109
 
110
- def do_rubygems_update(version_string)
111
- args = []
112
- args.push '--prefix', Gem.prefix unless Gem.prefix.nil?
113
- args << '--no-rdoc' unless options[:generate_rdoc]
114
- args << '--no-ri' unless options[:generate_ri]
110
+ def do_rubygems_update(version)
111
+ args = []
112
+ args.push '--prefix', Gem.prefix unless Gem.prefix.nil?
113
+ args << '--no-rdoc' unless options[:generate_rdoc]
114
+ args << '--no-ri' unless options[:generate_ri]
115
115
 
116
- update_dir = File.join(Gem.dir, 'gems',
117
- "rubygems-update-#{version_string}")
116
+ update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
118
117
 
119
- success = false
118
+ success = false
120
119
 
121
- Dir.chdir update_dir do
122
- say "Installing RubyGems #{version_string}"
123
- setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
120
+ Dir.chdir update_dir do
121
+ say "Installing RubyGems #{version}"
122
+ setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
124
123
 
125
- # Make sure old rubygems isn't loaded
126
- if Gem.win_platform? then
127
- system "set RUBYOPT= & #{setup_cmd}"
128
- else
129
- system "RUBYOPT=\"\" #{setup_cmd}"
130
- end
131
- end
124
+ # Make sure old rubygems isn't loaded
125
+ if Gem.win_platform? then
126
+ system "set RUBYOPT= & #{setup_cmd}"
127
+ else
128
+ system "RUBYOPT=\"\" #{setup_cmd}"
132
129
  end
130
+ end
131
+ end
132
+
133
+ def which_to_update(highest_installed_gems, remote_gemspecs)
134
+ result = []
133
135
 
134
- def which_to_update(highest_installed_gems, remote_gemspecs)
135
- result = []
136
- highest_installed_gems.each do |l_name, l_spec|
137
- highest_remote_gem =
138
- remote_gemspecs.select { |spec| spec.name == l_name }.
139
- sort_by { |spec| spec.version }.
140
- last
141
- if highest_remote_gem and l_spec.version < highest_remote_gem.version
142
- result << l_name
143
- end
136
+ highest_installed_gems.each do |l_name, l_spec|
137
+ matching_gems = remote_gemspecs.select do |spec|
138
+ spec.name == l_name and Gem.platforms.any? do |platform|
139
+ platform == spec.platform
144
140
  end
145
- result
141
+ end
142
+
143
+ highest_remote_gem = matching_gems.sort_by { |spec| spec.version }.last
144
+
145
+ if highest_remote_gem and
146
+ l_spec.version < highest_remote_gem.version then
147
+ result << l_name
146
148
  end
147
149
  end
150
+
151
+ result
148
152
  end
153
+
149
154
  end
155
+