rubygems-update 0.9.4 → 0.9.5
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/ChangeLog +587 -0
- data/README +0 -1
- data/Rakefile +39 -12
- data/TODO +0 -5
- data/bin/gem +7 -7
- data/bin/update_rubygems +1 -1
- data/examples/application/an-app.gemspec +1 -1
- data/gemspecs/cgikit-1.1.0.gemspec +1 -2
- data/gemspecs/jabber4r.gemspec +1 -1
- data/gemspecs/linguistics.gemspec +1 -1
- data/gemspecs/ook.gemspec +1 -1
- data/gemspecs/progressbar.gemspec +1 -1
- data/gemspecs/redcloth.gemspec +1 -1
- data/gemspecs/rublog.gemspec +1 -1
- data/gemspecs/ruby-doom.gemspec +1 -1
- data/gemspecs/rubyjdwp.gemspec +1 -1
- data/gemspecs/statistics.gemspec +1 -1
- data/lib/rubygems.rb +167 -105
- data/lib/rubygems/builder.rb +12 -10
- data/lib/rubygems/command.rb +177 -60
- data/lib/rubygems/command_manager.rb +30 -38
- data/lib/rubygems/commands/build_command.rb +42 -46
- data/lib/rubygems/commands/cert_command.rb +72 -69
- data/lib/rubygems/commands/check_command.rb +63 -63
- data/lib/rubygems/commands/cleanup_command.rb +25 -7
- data/lib/rubygems/commands/contents_command.rb +70 -62
- data/lib/rubygems/commands/dependency_command.rb +131 -86
- data/lib/rubygems/commands/environment_command.rb +67 -46
- data/lib/rubygems/commands/fetch_command.rb +62 -0
- data/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/lib/rubygems/commands/help_command.rb +163 -73
- data/lib/rubygems/commands/install_command.rb +114 -128
- data/lib/rubygems/commands/list_command.rb +10 -8
- data/lib/rubygems/commands/lock_command.rb +101 -0
- data/lib/rubygems/commands/mirror_command.rb +105 -0
- data/lib/rubygems/commands/outdated_command.rb +24 -15
- data/lib/rubygems/commands/pristine_command.rb +118 -88
- data/lib/rubygems/commands/query_command.rb +109 -77
- data/lib/rubygems/commands/rdoc_command.rb +13 -10
- data/lib/rubygems/commands/search_command.rb +10 -8
- data/lib/rubygems/commands/server_command.rb +48 -0
- data/lib/rubygems/commands/sources_command.rb +104 -83
- data/lib/rubygems/commands/specification_command.rb +65 -51
- data/lib/rubygems/commands/uninstall_command.rb +17 -12
- data/lib/rubygems/commands/unpack_command.rb +68 -68
- data/lib/rubygems/commands/update_command.rb +72 -25
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +202 -78
- data/lib/rubygems/custom_require.rb +7 -88
- data/lib/rubygems/dependency.rb +65 -0
- data/lib/rubygems/dependency_installer.rb +232 -0
- data/lib/rubygems/dependency_list.rb +133 -105
- data/lib/rubygems/digest/md5.rb +4 -1
- data/lib/rubygems/digest/sha2.rb +1 -1
- data/lib/rubygems/doc_manager.rb +41 -19
- data/lib/rubygems/exceptions.rb +63 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +24 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/lib/rubygems/ext/rake_builder.rb +27 -0
- data/lib/rubygems/format.rb +16 -6
- data/lib/rubygems/gem_openssl.rb +43 -6
- data/lib/rubygems/gem_path_searcher.rb +84 -0
- data/lib/rubygems/gem_runner.rb +20 -5
- data/lib/rubygems/indexer.rb +163 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
- data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/lib/rubygems/indexer/master_index_builder.rb +53 -0
- data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
- data/lib/rubygems/install_update_options.rb +87 -0
- data/lib/rubygems/installer.rb +316 -562
- data/lib/rubygems/local_remote_options.rb +106 -0
- data/lib/rubygems/old_format.rb +5 -13
- data/lib/rubygems/open-uri.rb +2 -0
- data/lib/rubygems/package.rb +28 -32
- data/lib/rubygems/platform.rb +187 -0
- data/lib/rubygems/remote_fetcher.rb +46 -29
- data/lib/rubygems/remote_installer.rb +11 -18
- data/lib/rubygems/requirement.rb +157 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +715 -457
- data/lib/rubygems/server.rb +77 -59
- data/lib/rubygems/source_index.rb +154 -83
- data/lib/rubygems/source_info_cache.rb +73 -30
- data/lib/rubygems/source_info_cache_entry.rb +12 -3
- data/lib/rubygems/specification.rb +378 -145
- data/lib/rubygems/uninstaller.rb +183 -0
- data/lib/rubygems/user_interaction.rb +38 -9
- data/lib/rubygems/validator.rb +53 -24
- data/lib/rubygems/version.rb +126 -289
- data/lib/rubygems/version_option.rb +49 -0
- data/pkgs/sources/lib/sources.rb +1 -4
- data/pkgs/sources/sources.gemspec +3 -3
- data/scripts/gemdoc.rb +0 -1
- data/setup.rb +166 -1505
- data/test/bogussources.rb +0 -1
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/functional.rb +3 -105
- data/test/gemutilities.rb +145 -24
- data/test/insure_session.rb +0 -1
- data/test/{test_datadir.rb → test_config.rb} +7 -13
- data/test/test_gem.rb +360 -9
- data/test/test_gem_builder.rb +34 -0
- data/test/{test_command.rb → test_gem_command.rb} +119 -62
- data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
- data/test/test_gem_commands_build_command.rb +75 -0
- data/test/test_gem_commands_cert_command.rb +122 -0
- data/test/test_gem_commands_check_command.rb +25 -0
- data/test/test_gem_commands_contents_command.rb +92 -0
- data/test/test_gem_commands_dependency_command.rb +108 -0
- data/test/test_gem_commands_environment_command.rb +117 -0
- data/test/test_gem_commands_fetch_command.rb +34 -0
- data/test/test_gem_commands_generate_index_command.rb +32 -0
- data/test/test_gem_commands_install_command.rb +160 -0
- data/test/test_gem_commands_mirror_command.rb +56 -0
- data/test/test_gem_commands_pristine_command.rb +100 -0
- data/test/test_gem_commands_query_command.rb +82 -0
- data/test/test_gem_commands_sources_command.rb +147 -0
- data/test/test_gem_commands_specification_command.rb +93 -0
- data/test/test_gem_commands_unpack_command.rb +55 -0
- data/test/test_gem_config_file.rb +210 -0
- data/test/test_gem_dependency.rb +89 -0
- data/test/test_gem_dependency_installer.rb +542 -0
- data/test/test_gem_dependency_list.rb +212 -0
- data/test/test_gem_doc_manager.rb +32 -0
- data/test/test_gem_ext_configure_builder.rb +13 -17
- data/test/test_gem_ext_ext_conf_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +23 -11
- data/test/test_gem_format.rb +69 -0
- data/test/test_gem_gem_path_searcher.rb +57 -0
- data/test/test_gem_gem_runner.rb +35 -0
- data/test/test_gem_indexer.rb +119 -0
- data/test/test_gem_install_update_options.rb +40 -0
- data/test/test_gem_installer.rb +796 -0
- data/test/test_gem_local_remote_options.rb +84 -0
- data/test/test_gem_outdated_command.rb +11 -9
- data/test/test_gem_platform.rb +240 -0
- data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
- data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
- data/test/test_gem_requirement.rb +223 -0
- data/test/test_gem_server.rb +71 -0
- data/test/test_gem_source_index.rb +429 -0
- data/test/test_gem_source_info_cache.rb +79 -17
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_specification.rb +738 -0
- data/test/test_gem_stream_ui.rb +117 -0
- data/test/test_gem_validator.rb +70 -0
- data/test/test_gem_version.rb +191 -0
- data/test/test_gem_version_option.rb +77 -0
- data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
- data/test/test_open_uri.rb +1 -2
- data/test/test_package.rb +45 -34
- metadata +116 -141
- data/Releases +0 -127
- data/bin/gem_mirror +0 -73
- data/bin/gem_server +0 -6
- data/bin/gemlock +0 -127
- data/bin/gemri +0 -24
- data/bin/gemwhich +0 -89
- data/bin/index_gem_repository.rb +0 -302
- data/lib/gemconfigure.rb +0 -24
- data/lib/rubygems/gem_commands.rb +0 -273
- data/pkgs/sources/sources-0.0.1.gem +0 -0
- data/post-install.rb +0 -121
- data/test/brokenbuildgem.rb +0 -35
- data/test/data/PostMessage-0.0.1.gem +0 -0
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/broken-1.0.0.gem +0 -0
- data/test/data/broken_build/broken-build.gemspec +0 -20
- data/test/data/broken_build/ext/extconf.rb +0 -3
- data/test/data/broken_build/ext/foo.c +0 -1
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
- data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
- data/test/data/lib/code.rb +0 -1
- data/test/data/one/README.one +0 -1
- data/test/data/one/lib/one.rb +0 -9
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/data/one/one.gemspec +0 -17
- data/test/data/one/one.yaml +0 -40
- data/test/data/post_install.gemspec +0 -19
- data/test/functional_extension_gems.rb +0 -48
- data/test/functional_generate_yaml_index.rb +0 -104
- data/test/gemenvironment.rb +0 -59
- data/test/io_capture.rb +0 -33
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
- data/test/onegem.rb +0 -35
- data/test/test_builder.rb +0 -34
- data/test/test_check_command.rb +0 -34
- data/test/test_configfile.rb +0 -42
- data/test/test_dependency_list.rb +0 -169
- data/test/test_file_list.rb +0 -101
- data/test/test_format.rb +0 -49
- data/test/test_gem_sources_command.rb +0 -135
- data/test/test_gemloadpaths.rb +0 -51
- data/test/test_gempaths.rb +0 -170
- data/test/test_installer.rb +0 -369
- data/test/test_loadmanager.rb +0 -48
- data/test/test_process_commands.rb +0 -52
- data/test/test_source_index.rb +0 -231
- data/test/test_specific_extras.rb +0 -46
- data/test/test_specification.rb +0 -565
- data/test/test_user_interaction.rb +0 -48
- data/test/test_validator.rb +0 -59
- data/test/test_version_comparison.rb +0 -321
- data/test/testgem.rc +0 -7
- data/test/user_capture.rb +0 -7
- data/test/yaml_data.rb +0 -63
@@ -1,58 +1,72 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
include CommandAids
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
super('specification', 'Display gem specification (in yaml)',
|
10
|
-
{:domain=>:local, :version=>"> 0.0.0"})
|
11
|
-
add_version_option('examine')
|
12
|
-
add_local_remote_options
|
13
|
-
add_option('--all', 'Output specifications for all versions of',
|
14
|
-
'the gem') do |value, options|
|
15
|
-
options[:all] = true
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require 'yaml'
|
2
|
+
require 'rubygems/command'
|
3
|
+
require 'rubygems/local_remote_options'
|
4
|
+
require 'rubygems/version_option'
|
5
|
+
require 'rubygems/source_info_cache'
|
18
6
|
|
19
|
-
|
20
|
-
"--local --version '(latest)'"
|
21
|
-
end
|
7
|
+
class Gem::Commands::SpecificationCommand < Gem::Command
|
22
8
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
9
|
+
include Gem::LocalRemoteOptions
|
10
|
+
include Gem::VersionOption
|
26
11
|
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
def initialize
|
13
|
+
super 'specification', 'Display gem specification (in yaml)',
|
14
|
+
:domain => :local, :version => Gem::Requirement.default
|
15
|
+
|
16
|
+
add_version_option('examine')
|
17
|
+
add_platform_option
|
18
|
+
|
19
|
+
add_option('--all', 'Output specifications for all versions of',
|
20
|
+
'the gem') do |value, options|
|
21
|
+
options[:all] = true
|
22
|
+
end
|
23
|
+
|
24
|
+
add_local_remote_options
|
25
|
+
end
|
26
|
+
|
27
|
+
def arguments # :nodoc:
|
28
|
+
"GEMFILE name of gem to show the gemspec for"
|
29
|
+
end
|
30
|
+
|
31
|
+
def defaults_str # :nodoc:
|
32
|
+
"--local --version '#{Gem::Requirement.default}'"
|
33
|
+
end
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
if remote?
|
50
|
-
say "(Remote 'info' operation is not yet implemented.)"
|
51
|
-
# NOTE: when we do implement remote info, make sure we don't
|
52
|
-
# duplicate huge swabs of local data. If it's the same, just
|
53
|
-
# say it's the same.
|
54
|
-
end
|
35
|
+
def usage # :nodoc:
|
36
|
+
"#{program_name} [GEMFILE]"
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute
|
40
|
+
specs = []
|
41
|
+
gem = get_one_gem_name
|
42
|
+
|
43
|
+
if local? then
|
44
|
+
source_index = Gem::SourceIndex.from_installed_gems
|
45
|
+
specs.push(*source_index.search(/\A#{gem}\z/, options[:version]))
|
46
|
+
end
|
47
|
+
|
48
|
+
if remote? then
|
49
|
+
alert_warning "Remote information is not complete\n\n"
|
50
|
+
|
51
|
+
Gem::SourceInfoCache.cache_data.each do |_,sice|
|
52
|
+
specs.push(*sice.source_index.search(gem, options[:version]))
|
55
53
|
end
|
56
54
|
end
|
55
|
+
|
56
|
+
if specs.empty? then
|
57
|
+
alert_error "Unknown gem '#{gem}'"
|
58
|
+
terminate_interaction 1
|
59
|
+
end
|
60
|
+
|
61
|
+
output = lambda { |spec| say spec.to_yaml; say "\n" }
|
62
|
+
|
63
|
+
if options[:all] then
|
64
|
+
specs.each(&output)
|
65
|
+
else
|
66
|
+
spec = specs.sort_by { |spec| spec.version }.last
|
67
|
+
output[spec]
|
68
|
+
end
|
57
69
|
end
|
58
|
-
|
70
|
+
|
71
|
+
end
|
72
|
+
|
@@ -1,12 +1,16 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/version_option'
|
3
|
+
require 'rubygems/uninstaller'
|
4
|
+
|
1
5
|
module Gem
|
2
6
|
module Commands
|
3
7
|
class UninstallCommand < Command
|
8
|
+
|
4
9
|
include VersionOption
|
5
|
-
include CommandAids
|
6
10
|
|
7
11
|
def initialize
|
8
|
-
super
|
9
|
-
|
12
|
+
super 'uninstall', 'Uninstall gems from the local repository',
|
13
|
+
:version => Gem::Requirement.default
|
10
14
|
|
11
15
|
add_option('-a', '--[no-]all',
|
12
16
|
'Uninstall all matching versions'
|
@@ -26,19 +30,20 @@ module Gem
|
|
26
30
|
options[:executables] = value
|
27
31
|
end
|
28
32
|
|
29
|
-
add_version_option
|
33
|
+
add_version_option
|
34
|
+
add_platform_option
|
30
35
|
end
|
31
36
|
|
32
|
-
def
|
33
|
-
"
|
37
|
+
def arguments # :nodoc:
|
38
|
+
"GEMNAME name of gem to uninstall"
|
34
39
|
end
|
35
|
-
|
36
|
-
def
|
37
|
-
"#{
|
40
|
+
|
41
|
+
def defaults_str # :nodoc:
|
42
|
+
"--version '#{Gem::Requirement.default}' --no-force"
|
38
43
|
end
|
39
44
|
|
40
|
-
def
|
41
|
-
"GEMNAME
|
45
|
+
def usage # :nodoc:
|
46
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
42
47
|
end
|
43
48
|
|
44
49
|
def execute
|
@@ -48,4 +53,4 @@ module Gem
|
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
51
|
-
end
|
56
|
+
end
|
@@ -1,76 +1,76 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
include CommandAids
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rubygems/command'
|
3
|
+
require 'rubygems/installer'
|
4
|
+
require 'rubygems/version_option'
|
6
5
|
|
7
|
-
|
8
|
-
super(
|
9
|
-
'unpack',
|
10
|
-
'Unpack an installed gem to the current directory',
|
11
|
-
{ :version => '> 0' }
|
12
|
-
)
|
13
|
-
add_version_option('unpack')
|
14
|
-
end
|
6
|
+
class Gem::Commands::UnpackCommand < Gem::Command
|
15
7
|
|
16
|
-
|
17
|
-
"--version '> 0'"
|
18
|
-
end
|
8
|
+
include Gem::VersionOption
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
def initialize
|
11
|
+
super 'unpack', 'Unpack an installed gem to the current directory',
|
12
|
+
:version => Gem::Requirement.default
|
13
|
+
add_version_option
|
14
|
+
end
|
15
|
+
|
16
|
+
def arguments # :nodoc:
|
17
|
+
"GEMNAME name of gem to unpack"
|
18
|
+
end
|
19
|
+
|
20
|
+
def defaults_str # :nodoc:
|
21
|
+
"--version '#{Gem::Requirement.default}'"
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def usage # :nodoc:
|
25
|
+
"#{program_name} GEMNAME"
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
28
|
+
#--
|
29
|
+
# TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for
|
30
|
+
# this, so that it works for uninstall as well. (And check other commands
|
31
|
+
# at the same time.)
|
32
|
+
def execute
|
33
|
+
gemname = get_one_gem_name
|
34
|
+
path = get_path(gemname, options[:version])
|
35
|
+
if path
|
36
|
+
target_dir = File.basename(path).sub(/\.gem$/, '')
|
37
|
+
FileUtils.mkdir_p target_dir
|
38
|
+
Gem::Installer.new(path).unpack(File.expand_path(target_dir))
|
39
|
+
say "Unpacked gem: '#{target_dir}'"
|
40
|
+
else
|
41
|
+
alert_error "Gem '#{gemname}' not installed."
|
42
|
+
end
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
45
|
+
# Return the full path to the cached gem file matching the given
|
46
|
+
# name and version requirement. Returns 'nil' if no match.
|
47
|
+
#
|
48
|
+
# Example:
|
49
|
+
#
|
50
|
+
# get_path('rake', '> 0.4') # -> '/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem'
|
51
|
+
# get_path('rake', '< 0.1') # -> nil
|
52
|
+
# get_path('rak') # -> nil (exact name required)
|
53
|
+
#--
|
54
|
+
# TODO: This should be refactored so that it's a general service. I don't
|
55
|
+
# think any of our existing classes are the right place though. Just maybe
|
56
|
+
# 'Cache'?
|
57
|
+
#
|
58
|
+
# TODO: It just uses Gem.dir for now. What's an easy way to get the list of
|
59
|
+
# source directories?
|
60
|
+
def get_path(gemname, version_req)
|
61
|
+
return gemname if gemname =~ /\.gem$/i
|
62
|
+
specs = Gem::SourceIndex.from_installed_gems.search(/\A#{gemname}\z/, version_req)
|
63
|
+
selected = specs.sort_by { |s| s.version }.last
|
64
|
+
return nil if selected.nil?
|
65
|
+
# We expect to find (basename).gem in the 'cache' directory.
|
66
|
+
# Furthermore, the name match must be exact (ignoring case).
|
67
|
+
if gemname =~ /^#{selected.name}$/i
|
68
|
+
filename = selected.full_name + '.gem'
|
69
|
+
return File.join(Gem.dir, 'cache', filename)
|
70
|
+
else
|
71
|
+
return nil
|
74
72
|
end
|
75
73
|
end
|
76
|
-
|
74
|
+
|
75
|
+
end
|
76
|
+
|
@@ -1,12 +1,21 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/install_update_options'
|
3
|
+
require 'rubygems/local_remote_options'
|
4
|
+
require 'rubygems/source_info_cache'
|
5
|
+
require 'rubygems/version_option'
|
6
|
+
|
1
7
|
module Gem
|
2
8
|
module Commands
|
3
9
|
class UpdateCommand < Command
|
4
|
-
|
10
|
+
|
11
|
+
include Gem::InstallUpdateOptions
|
12
|
+
include Gem::LocalRemoteOptions
|
13
|
+
include Gem::VersionOption
|
5
14
|
|
6
15
|
def initialize
|
7
16
|
super(
|
8
17
|
'update',
|
9
|
-
'Update the named
|
18
|
+
'Update the named gems (or all installed gems) in the local repository',
|
10
19
|
{
|
11
20
|
:generate_rdoc => true,
|
12
21
|
:generate_ri => true,
|
@@ -14,73 +23,111 @@ module Gem
|
|
14
23
|
:test => false,
|
15
24
|
:install_dir => Gem.dir
|
16
25
|
})
|
26
|
+
|
17
27
|
add_install_update_options
|
28
|
+
|
18
29
|
add_option('--system',
|
19
30
|
'Update the RubyGems system software') do |value, options|
|
20
31
|
options[:system] = value
|
21
32
|
end
|
33
|
+
|
34
|
+
add_local_remote_options
|
35
|
+
|
36
|
+
add_platform_option
|
37
|
+
end
|
38
|
+
|
39
|
+
def arguments # :nodoc:
|
40
|
+
"GEMNAME name of gem to update"
|
22
41
|
end
|
23
|
-
|
24
|
-
def defaults_str
|
42
|
+
|
43
|
+
def defaults_str # :nodoc:
|
25
44
|
"--rdoc --ri --no-force --no-test\n" +
|
26
45
|
"--install-dir #{Gem.dir}"
|
27
46
|
end
|
28
47
|
|
29
|
-
def
|
30
|
-
"GEMNAME
|
48
|
+
def usage # :nodoc:
|
49
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
31
50
|
end
|
32
51
|
|
33
52
|
def execute
|
34
|
-
if options[:system]
|
53
|
+
if options[:system] then
|
35
54
|
say "Updating RubyGems..."
|
36
|
-
|
55
|
+
|
56
|
+
unless options[:args].empty? then
|
37
57
|
fail "No gem names are allowed with the --system option"
|
38
58
|
end
|
59
|
+
|
39
60
|
options[:args] = ["rubygems-update"]
|
40
61
|
else
|
41
62
|
say "Updating installed gems..."
|
42
63
|
end
|
64
|
+
|
43
65
|
hig = highest_installed_gems = {}
|
66
|
+
|
44
67
|
Gem::SourceIndex.from_installed_gems.each do |name, spec|
|
45
68
|
if hig[spec.name].nil? or hig[spec.name].version < spec.version
|
46
69
|
hig[spec.name] = spec
|
47
70
|
end
|
48
71
|
end
|
72
|
+
|
49
73
|
remote_gemspecs = Gem::SourceInfoCache.search(//)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
74
|
+
|
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
|
80
|
+
|
55
81
|
options[:domain] = :remote # install from remote source
|
56
|
-
|
82
|
+
|
83
|
+
# HACK use the real API
|
84
|
+
install_command = Gem::CommandManager.instance['install']
|
85
|
+
|
57
86
|
gems_to_update.uniq.sort.each do |name|
|
58
87
|
say "Attempting remote update of #{name}"
|
59
88
|
options[:args] = [name]
|
89
|
+
options[:ignore_dependencies] = true # HACK skip seen gems instead
|
60
90
|
install_command.merge_options(options)
|
61
91
|
install_command.execute
|
62
92
|
end
|
63
|
-
|
93
|
+
|
94
|
+
if gems_to_update.include?("rubygems-update") then
|
64
95
|
latest_ruby_gem = remote_gemspecs.select { |s|
|
65
|
-
s.name == 'rubygems-update'
|
96
|
+
s.name == 'rubygems-update'
|
66
97
|
}.sort_by { |s|
|
67
98
|
s.version
|
68
99
|
}.last
|
100
|
+
|
69
101
|
say "Updating version of RubyGems to #{latest_ruby_gem.version}"
|
70
|
-
do_rubygems_update(latest_ruby_gem.version.to_s)
|
71
|
-
|
72
|
-
|
73
|
-
say "RubyGems system software updated"
|
102
|
+
installed = do_rubygems_update(latest_ruby_gem.version.to_s)
|
103
|
+
|
104
|
+
say "RubyGems system software updated" if installed
|
74
105
|
else
|
75
106
|
say "Gems: [#{gems_to_update.uniq.sort.collect{|g| g.to_s}.join(', ')}] updated"
|
76
107
|
end
|
77
108
|
end
|
78
109
|
|
79
110
|
def do_rubygems_update(version_string)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
+
|
116
|
+
update_dir = File.join(Gem.dir, 'gems',
|
117
|
+
"rubygems-update-#{version_string}")
|
118
|
+
|
119
|
+
success = false
|
120
|
+
|
121
|
+
Dir.chdir update_dir do
|
122
|
+
say "Installing RubyGems #{version_string}"
|
123
|
+
setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
|
124
|
+
|
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
|
84
131
|
end
|
85
132
|
end
|
86
133
|
|
@@ -99,4 +146,4 @@ module Gem
|
|
99
146
|
end
|
100
147
|
end
|
101
148
|
end
|
102
|
-
end
|
149
|
+
end
|