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
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/local_remote_options'
|
3
|
+
require 'rubygems/version_option'
|
4
|
+
require 'rubygems/source_info_cache'
|
5
|
+
|
6
|
+
class Gem::Commands::FetchCommand < Gem::Command
|
7
|
+
|
8
|
+
include Gem::LocalRemoteOptions
|
9
|
+
include Gem::VersionOption
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super 'fetch', 'Download a gem and place it in the current directory'
|
13
|
+
|
14
|
+
add_bulk_threshold_option
|
15
|
+
add_proxy_option
|
16
|
+
add_source_option
|
17
|
+
|
18
|
+
add_version_option
|
19
|
+
add_platform_option
|
20
|
+
end
|
21
|
+
|
22
|
+
def arguments # :nodoc:
|
23
|
+
'GEMNAME name of gem to download'
|
24
|
+
end
|
25
|
+
|
26
|
+
def defaults_str # :nodoc:
|
27
|
+
"--version '#{Gem::Requirement.default}'"
|
28
|
+
end
|
29
|
+
|
30
|
+
def usage # :nodoc:
|
31
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute
|
35
|
+
version = options[:version] || Gem::Requirement.default
|
36
|
+
|
37
|
+
gem_names = get_all_gem_names
|
38
|
+
|
39
|
+
gem_names.each do |gem_name|
|
40
|
+
dep = Gem::Dependency.new gem_name, version
|
41
|
+
specs_and_sources = Gem::SourceInfoCache.search_with_source dep, true
|
42
|
+
|
43
|
+
specs_and_sources.sort_by { |spec,| spec.version }
|
44
|
+
|
45
|
+
spec, source_uri = specs_and_sources.last
|
46
|
+
|
47
|
+
gem_file = "#{spec.full_name}.gem"
|
48
|
+
|
49
|
+
gem_path = File.join source_uri, 'gems', gem_file
|
50
|
+
|
51
|
+
gem = Gem::RemoteFetcher.fetcher.fetch_path gem_path
|
52
|
+
|
53
|
+
File.open gem_file, 'wb' do |fp|
|
54
|
+
fp.write gem
|
55
|
+
end
|
56
|
+
|
57
|
+
say "Downloaded #{gem_file}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/indexer'
|
3
|
+
|
4
|
+
class Gem::Commands::GenerateIndexCommand < Gem::Command
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super 'generate_index',
|
8
|
+
'Generates the index files for a gem server directory',
|
9
|
+
:directory => '.'
|
10
|
+
|
11
|
+
add_option '-d', '--directory=DIRNAME',
|
12
|
+
'repository base dir containing gems subdir' do |dir, options|
|
13
|
+
options[:directory] = File.expand_path dir
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def defaults_str # :nodoc:
|
18
|
+
"--directory ."
|
19
|
+
end
|
20
|
+
|
21
|
+
def description # :nodoc:
|
22
|
+
<<-EOF
|
23
|
+
The generate_index command creates a set of indexes for serving gems
|
24
|
+
statically. The command expects a 'gems' directory under the path given to
|
25
|
+
the --directory option. When done, it will generate a set of files like this:
|
26
|
+
|
27
|
+
gems/ # .gem files you want to index
|
28
|
+
quick/index
|
29
|
+
quick/index.rz # quick index manifest
|
30
|
+
quick/<gemname>.gemspec.rz # legacy YAML quick index file
|
31
|
+
quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal quick index file
|
32
|
+
Marshal.<version>
|
33
|
+
Marshal.<version>.Z # Marshal full index
|
34
|
+
yaml
|
35
|
+
yaml.Z # legacy YAML full index
|
36
|
+
|
37
|
+
The .Z and .rz extension files are compressed with the inflate algorithm. The
|
38
|
+
Marshal version number comes from ruby's Marshal::MAJOR_VERSION and
|
39
|
+
Marshal::MINOR_VERSION constants. It is used to ensure compatibility. The
|
40
|
+
yaml indexes exist for legacy RubyGems clients and fallback in case of Marshal
|
41
|
+
version changes.
|
42
|
+
EOF
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute
|
46
|
+
if not File.exist?(options[:directory]) or
|
47
|
+
not File.directory?(options[:directory]) then
|
48
|
+
alert_error "unknown directory name #{directory}."
|
49
|
+
terminate_interaction 1
|
50
|
+
else
|
51
|
+
indexer = Gem::Indexer.new options[:directory]
|
52
|
+
indexer.generate_index
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
@@ -1,82 +1,172 @@
|
|
1
|
-
|
2
|
-
module Commands
|
3
|
-
class HelpCommand < Command
|
4
|
-
include CommandAids
|
1
|
+
require 'rubygems/command'
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
class Gem::Commands::HelpCommand < Gem::Command
|
4
|
+
|
5
|
+
# :stopdoc:
|
6
|
+
EXAMPLES = <<-EOF
|
7
|
+
Some examples of 'gem' usage.
|
8
|
+
|
9
|
+
* Install 'rake', either from local directory or remote server:
|
10
|
+
|
11
|
+
gem install rake
|
12
|
+
|
13
|
+
* Install 'rake', only from remote server:
|
14
|
+
|
15
|
+
gem install rake --remote
|
16
|
+
|
17
|
+
* Install 'rake' from remote server, and run unit tests,
|
18
|
+
and generate RDocs:
|
19
|
+
|
20
|
+
gem install --remote rake --test --rdoc --ri
|
21
|
+
|
22
|
+
* Install 'rake', but only version 0.3.1, even if dependencies
|
23
|
+
are not met, and into a specific directory:
|
24
|
+
|
25
|
+
gem install rake --version 0.3.1 --force --install-dir $HOME/.gems
|
26
|
+
|
27
|
+
* List local gems whose name begins with 'D':
|
28
|
+
|
29
|
+
gem list D
|
30
|
+
|
31
|
+
* List local and remote gems whose name contains 'log':
|
32
|
+
|
33
|
+
gem search log --both
|
34
|
+
|
35
|
+
* List only remote gems whose name contains 'log':
|
36
|
+
|
37
|
+
gem search log --remote
|
38
|
+
|
39
|
+
* Uninstall 'rake':
|
40
|
+
|
41
|
+
gem uninstall rake
|
42
|
+
|
43
|
+
* Create a gem:
|
44
|
+
|
45
|
+
See http://rubygems.rubyforge.org/wiki/wiki.pl?CreateAGemInTenMinutes
|
46
|
+
|
47
|
+
* See information about RubyGems:
|
48
|
+
|
49
|
+
gem environment
|
50
|
+
|
51
|
+
* Update all gems on your system:
|
52
|
+
|
53
|
+
gem update
|
54
|
+
EOF
|
55
|
+
|
56
|
+
PLATFORMS = <<-'EOF'
|
57
|
+
RubyGems platforms are composed of three parts, a CPU, an OS, and a
|
58
|
+
version. These values are taken from values in rbconfig.rb. You can view
|
59
|
+
your current platform by running `gem environment`.
|
60
|
+
|
61
|
+
RubyGems matches platforms as follows:
|
9
62
|
|
10
|
-
|
11
|
-
|
63
|
+
* The CPU must match exactly, unless one of the platforms has
|
64
|
+
"universal" as the CPU.
|
65
|
+
* The OS must match exactly.
|
66
|
+
* The versions must match exactly unless one of the versions is nil.
|
67
|
+
|
68
|
+
For commands that install, uninstall and list gems, you can override what
|
69
|
+
RubyGems thinks your platform is with the --platform option. The platform
|
70
|
+
you pass must match "#{cpu}-#{os}" or "#{cpu}-#{os}-#{version}". On mswin
|
71
|
+
platforms, the version is the compiler version, not the OS version. (Ruby
|
72
|
+
compiled with VC6 uses "60" as the compiler version, VC8 uses "80".)
|
73
|
+
|
74
|
+
Example platforms:
|
75
|
+
|
76
|
+
x86-freebsd # Any FreeBSD version on an x86 CPU
|
77
|
+
universal-darwin-8 # Darwin 8 only gems that run on any CPU
|
78
|
+
x86-mswin32-80 # Windows gems compiled with VC8
|
79
|
+
|
80
|
+
When building platform gems, set the platform in the gem specification to
|
81
|
+
Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's
|
82
|
+
platform.
|
83
|
+
EOF
|
84
|
+
# :startdoc:
|
85
|
+
|
86
|
+
def initialize
|
87
|
+
super 'help', "Provide help on the 'gem' command"
|
88
|
+
end
|
89
|
+
|
90
|
+
def arguments # :nodoc:
|
91
|
+
args = <<-EOF
|
92
|
+
commands List all 'gem' commands
|
93
|
+
examples Show examples of 'gem' usage
|
94
|
+
<command> Show specific help for <command>
|
95
|
+
EOF
|
96
|
+
return args.gsub(/^\s+/, '')
|
97
|
+
end
|
98
|
+
|
99
|
+
def usage # :nodoc:
|
100
|
+
"#{program_name} ARGUMENT"
|
101
|
+
end
|
102
|
+
|
103
|
+
def execute
|
104
|
+
command_manager = Gem::CommandManager.instance
|
105
|
+
arg = options[:args][0]
|
106
|
+
|
107
|
+
if begins? "commands", arg then
|
108
|
+
out = []
|
109
|
+
out << "GEM commands are:"
|
110
|
+
out << nil
|
111
|
+
|
112
|
+
margin_width = 4
|
113
|
+
|
114
|
+
desc_width = command_manager.command_names.map { |n| n.size }.max + 4
|
115
|
+
|
116
|
+
summary_width = 80 - margin_width - desc_width
|
117
|
+
wrap_indent = ' ' * (margin_width + desc_width)
|
118
|
+
format = "#{' ' * margin_width}%-#{desc_width}s%s"
|
119
|
+
|
120
|
+
command_manager.command_names.each do |cmd_name|
|
121
|
+
summary = command_manager[cmd_name].summary
|
122
|
+
summary = wrap(summary, summary_width).split "\n"
|
123
|
+
out << sprintf(format, cmd_name, summary.shift)
|
124
|
+
until summary.empty? do
|
125
|
+
out << "#{wrap_indent}#{summary.shift}"
|
126
|
+
end
|
12
127
|
end
|
13
128
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
129
|
+
out << nil
|
130
|
+
out << "For help on a particular command, use 'gem help COMMAND'."
|
131
|
+
out << nil
|
132
|
+
out << "Commands may be abbreviated, so long as they are unambiguous."
|
133
|
+
out << "e.g. 'gem i rake' is short for 'gem install rake'."
|
134
|
+
|
135
|
+
say out.join("\n")
|
136
|
+
|
137
|
+
elsif begins? "options", arg then
|
138
|
+
say Gem::Command::HELP
|
139
|
+
|
140
|
+
elsif begins? "examples", arg then
|
141
|
+
say EXAMPLES
|
142
|
+
|
143
|
+
elsif begins? "platforms", arg then
|
144
|
+
say PLATFORMS
|
145
|
+
|
146
|
+
elsif options[:help] then
|
147
|
+
command = command_manager[options[:help]]
|
148
|
+
if command
|
149
|
+
# help with provided command
|
150
|
+
command.invoke("--help")
|
151
|
+
else
|
152
|
+
alert_error "Unknown command #{options[:help]}. Try 'gem help commands'"
|
21
153
|
end
|
22
154
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
summary_width = 80 - margin_width - desc_width
|
33
|
-
wrap_indent = ' ' * (margin_width + desc_width)
|
34
|
-
format = "#{' ' * margin_width}%-#{desc_width}s%s"
|
35
|
-
|
36
|
-
command_manager.command_names.each do |cmd_name|
|
37
|
-
summary = command_manager[cmd_name].summary
|
38
|
-
summary = wrap(summary, summary_width).split "\n"
|
39
|
-
out << sprintf(format, cmd_name, summary.shift)
|
40
|
-
until summary.empty? do
|
41
|
-
out << "#{wrap_indent}#{summary.shift}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
out << nil
|
46
|
-
out << "For help on a particular command, use 'gem help COMMAND'."
|
47
|
-
out << nil
|
48
|
-
out << "Commands may be abbreviated, so long as they are unambiguous."
|
49
|
-
out << "e.g. 'gem i rake' is short for 'gem install rake'."
|
50
|
-
|
51
|
-
say out.join("\n")
|
52
|
-
|
53
|
-
elsif begins?("options", arg)
|
54
|
-
say Gem::HELP
|
55
|
-
elsif begins?("examples", arg)
|
56
|
-
say Gem::EXAMPLES
|
57
|
-
elsif options[:help]
|
58
|
-
command = command_manager[options[:help]]
|
59
|
-
if command
|
60
|
-
# help with provided command
|
61
|
-
command.invoke("--help")
|
62
|
-
else
|
63
|
-
alert_error "Unknown command #{options[:help]}. Try 'gem help commands'"
|
64
|
-
end
|
65
|
-
elsif arg
|
66
|
-
possibilities = command_manager.find_command_possibilities(arg.downcase)
|
67
|
-
if possibilities.size == 1
|
68
|
-
command = command_manager[possibilities.first]
|
69
|
-
command.invoke("--help")
|
70
|
-
elsif possibilities.size > 1
|
71
|
-
alert_warning "Ambiguous command #{arg} (#{possibilities.join(', ')})"
|
72
|
-
else
|
73
|
-
alert_warning "Unknown command #{arg}. Try gem help commands"
|
74
|
-
end
|
75
|
-
else
|
76
|
-
say Gem::HELP
|
77
|
-
end
|
155
|
+
elsif arg then
|
156
|
+
possibilities = command_manager.find_command_possibilities(arg.downcase)
|
157
|
+
if possibilities.size == 1
|
158
|
+
command = command_manager[possibilities.first]
|
159
|
+
command.invoke("--help")
|
160
|
+
elsif possibilities.size > 1
|
161
|
+
alert_warning "Ambiguous command #{arg} (#{possibilities.join(', ')})"
|
162
|
+
else
|
163
|
+
alert_warning "Unknown command #{arg}. Try gem help commands"
|
78
164
|
end
|
165
|
+
|
166
|
+
else
|
167
|
+
say Gem::Command::HELP
|
79
168
|
end
|
80
|
-
|
81
169
|
end
|
82
|
-
|
170
|
+
|
171
|
+
end
|
172
|
+
|
@@ -1,139 +1,125 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
super(
|
11
|
-
'install',
|
12
|
-
'Install a gem into the local repository',
|
13
|
-
{
|
14
|
-
:domain => :both,
|
15
|
-
:generate_rdoc => true,
|
16
|
-
:generate_ri => true,
|
17
|
-
:force => false,
|
18
|
-
:test => false,
|
19
|
-
:wrappers => true,
|
20
|
-
:version => "> 0",
|
21
|
-
:install_dir => Gem.dir,
|
22
|
-
:security_policy => nil,
|
23
|
-
})
|
24
|
-
add_version_option('install')
|
25
|
-
add_local_remote_options
|
26
|
-
add_install_update_options
|
27
|
-
end
|
28
|
-
|
29
|
-
def usage
|
30
|
-
"#{program_name} GEMNAME [options]
|
31
|
-
or: #{program_name} GEMNAME [options] -- --build-flags"
|
32
|
-
end
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/doc_manager'
|
3
|
+
require 'rubygems/install_update_options'
|
4
|
+
require 'rubygems/dependency_installer'
|
5
|
+
require 'rubygems/local_remote_options'
|
6
|
+
require 'rubygems/validator'
|
7
|
+
require 'rubygems/version_option'
|
33
8
|
|
34
|
-
|
35
|
-
"GEMNAME name of gem to install"
|
36
|
-
end
|
9
|
+
class Gem::Commands::InstallCommand < Gem::Command
|
37
10
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
11
|
+
include Gem::VersionOption
|
12
|
+
include Gem::LocalRemoteOptions
|
13
|
+
include Gem::InstallUpdateOptions
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
|
17
|
+
:generate_rdoc => true,
|
18
|
+
:generate_ri => true,
|
19
|
+
:install_dir => Gem.dir,
|
20
|
+
:test => false,
|
21
|
+
:version => Gem::Requirement.default,
|
22
|
+
})
|
23
|
+
|
24
|
+
super 'install', 'Install a gem into the local repository', defaults
|
25
|
+
|
26
|
+
add_install_update_options
|
27
|
+
add_local_remote_options
|
28
|
+
add_platform_option
|
29
|
+
add_version_option
|
30
|
+
end
|
31
|
+
|
32
|
+
def arguments # :nodoc:
|
33
|
+
"GEMNAME name of gem to install"
|
34
|
+
end
|
35
|
+
|
36
|
+
def defaults_str # :nodoc:
|
37
|
+
"--both --version '#{Gem::Requirement.default}' --rdoc --ri --no-force\n" \
|
38
|
+
"--no-test --install-dir #{Gem.dir}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def usage # :nodoc:
|
42
|
+
"#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags"
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute
|
46
|
+
if options[:include_dependencies] then
|
47
|
+
alert "`gem install -y` is now default and will be removed"
|
48
|
+
alert "use --ignore-dependencies to install only the gems you list"
|
49
|
+
end
|
50
|
+
|
51
|
+
installed_gems = []
|
52
|
+
|
53
|
+
ENV['GEM_PATH'] = options[:install_dir] # HACK what does this do?
|
54
|
+
|
55
|
+
install_options = {
|
56
|
+
:env_shebang => options[:env_shebang],
|
57
|
+
:domain => options[:domain],
|
58
|
+
:force => options[:force],
|
59
|
+
:ignore_dependencies => options[:ignore_dependencies],
|
60
|
+
:install_dir => options[:install_dir],
|
61
|
+
:security_policy => options[:security_policy],
|
62
|
+
:wrappers => options[:wrappers],
|
63
|
+
}
|
42
64
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
65
|
+
get_all_gem_names.each do |gem_name|
|
66
|
+
begin
|
67
|
+
inst = Gem::DependencyInstaller.new gem_name, options[:version],
|
68
|
+
install_options
|
69
|
+
inst.install
|
70
|
+
|
71
|
+
inst.installed_gems.each do |spec|
|
72
|
+
say "Successfully installed #{spec.full_name}"
|
48
73
|
end
|
49
|
-
options[:args].each do |gem_name|
|
50
|
-
if local?
|
51
|
-
begin
|
52
|
-
entries = []
|
53
|
-
if(File.exist?(gem_name) && !File.directory?(gem_name))
|
54
|
-
entries << gem_name
|
55
|
-
else
|
56
|
-
filepattern = gem_name + "*.gem"
|
57
|
-
entries = Dir[filepattern]
|
58
|
-
end
|
59
|
-
unless entries.size > 0
|
60
|
-
if options[:domain] == :local
|
61
|
-
alert_error "Local gem file not found: #{filepattern}"
|
62
|
-
end
|
63
|
-
else
|
64
|
-
result = Gem::Installer.new(entries.last, options).install(options[:force], options[:install_dir])
|
65
|
-
installed_gems = [result].flatten
|
66
|
-
say "Successfully installed #{installed_gems[0].name}, " +
|
67
|
-
"version #{installed_gems[0].version}" if installed_gems
|
68
|
-
end
|
69
|
-
rescue LocalInstallationError => e
|
70
|
-
say " -> Local installation can't proceed: #{e.message}"
|
71
|
-
rescue Gem::LoadError => e
|
72
|
-
say " -> Local installation can't proceed due to LoadError: #{e.message}"
|
73
|
-
rescue Gem::InstallError => e
|
74
|
-
raise "Error instaling #{gem_name}:\n\t#{e.message}"
|
75
|
-
rescue => e
|
76
|
-
# TODO: Fix this handle to allow the error to propagate to
|
77
|
-
# the top level handler. Examine the other errors as
|
78
|
-
# well. This implementation here looks suspicious to me --
|
79
|
-
# JimWeirich (4/Jan/05)
|
80
|
-
alert_error "Error installing gem #{gem_name}[.gem]: #{e.message}"
|
81
|
-
return
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
if remote? && installed_gems.nil?
|
86
|
-
installer = Gem::RemoteInstaller.new(options)
|
87
|
-
installed_gems = installer.install(
|
88
|
-
gem_name,
|
89
|
-
options[:version],
|
90
|
-
options[:force],
|
91
|
-
options[:install_dir])
|
92
|
-
if installed_gems
|
93
|
-
installed_gems.compact!
|
94
|
-
installed_gems.each do |spec|
|
95
|
-
say "Successfully installed #{spec.full_name}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
unless installed_gems
|
101
|
-
alert_error "Could not install a local " +
|
102
|
-
"or remote copy of the gem: #{gem_name}"
|
103
|
-
terminate_interaction(1)
|
104
|
-
end
|
105
|
-
|
106
|
-
# NOTE: *All* of the RI documents must be generated first.
|
107
|
-
# For some reason, RI docs cannot be generated after any RDoc
|
108
|
-
# documents are generated.
|
109
|
-
|
110
|
-
if options[:generate_ri]
|
111
|
-
installed_gems.each do |gem|
|
112
|
-
Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
|
113
|
-
end
|
114
|
-
end
|
115
74
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
75
|
+
installed_gems.push(*inst.installed_gems)
|
76
|
+
rescue Gem::InstallError => e
|
77
|
+
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
|
78
|
+
rescue Gem::GemNotFoundException => e
|
79
|
+
alert_error e.message
|
80
|
+
# rescue => e
|
81
|
+
# # TODO: Fix this handle to allow the error to propagate to
|
82
|
+
# # the top level handler. Examine the other errors as
|
83
|
+
# # well. This implementation here looks suspicious to me --
|
84
|
+
# # JimWeirich (4/Jan/05)
|
85
|
+
# alert_error "Error installing gem #{gem_name}: #{e.message}"
|
86
|
+
# return
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
unless installed_gems.empty? then
|
91
|
+
gems = installed_gems.length == 1 ? 'gem' : 'gems'
|
92
|
+
say "#{installed_gems.length} #{gems} installed"
|
93
|
+
end
|
121
94
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
95
|
+
# NOTE: *All* of the RI documents must be generated first.
|
96
|
+
# For some reason, RI docs cannot be generated after any RDoc
|
97
|
+
# documents are generated.
|
98
|
+
|
99
|
+
if options[:generate_ri] then
|
100
|
+
installed_gems.each do |gem|
|
101
|
+
Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if options[:generate_rdoc] then
|
106
|
+
installed_gems.each do |gem|
|
107
|
+
Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
if options[:test] then
|
112
|
+
installed_gems.each do |spec|
|
113
|
+
gem_spec = Gem::SourceIndex.from_installed_gems.search(spec.name, spec.version.version).first
|
114
|
+
result = Gem::Validator.new.unit_test(gem_spec)
|
115
|
+
if result and not result.passed?
|
116
|
+
unless ask_yes_no("...keep Gem?", true) then
|
117
|
+
Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall
|
132
118
|
end
|
133
119
|
end
|
134
120
|
end
|
135
|
-
|
136
121
|
end
|
137
|
-
|
138
122
|
end
|
139
|
-
|
123
|
+
|
124
|
+
end
|
125
|
+
|