rubygems-update 1.3.1 → 1.3.2
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.tar.gz.sig +0 -0
- data/.autotest +24 -0
- data/.document +4 -3
- data/ChangeLog +382 -1
- data/Manifest.txt +214 -0
- data/README +1 -49
- data/Rakefile +124 -191
- data/bin/gem +1 -4
- data/cruise_config.rb +22 -0
- data/doc/release_notes/rel_1_3_1.rdoc +3 -3
- data/doc/release_notes/rel_1_3_2.rdoc +119 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rubygems.rb +250 -25
- data/lib/rubygems/builder.rb +62 -60
- data/lib/rubygems/command.rb +421 -319
- data/lib/rubygems/command_manager.rb +153 -125
- data/lib/rubygems/commands/check_command.rb +12 -7
- data/lib/rubygems/commands/cleanup_command.rb +11 -2
- data/lib/rubygems/commands/contents_command.rb +42 -18
- data/lib/rubygems/commands/generate_index_command.rb +91 -15
- data/lib/rubygems/commands/install_command.rb +33 -47
- data/lib/rubygems/commands/query_command.rb +36 -20
- data/lib/rubygems/commands/rdoc_command.rb +62 -68
- data/lib/rubygems/commands/search_command.rb +26 -32
- data/lib/rubygems/commands/setup_command.rb +353 -0
- data/lib/rubygems/commands/sources_command.rb +5 -0
- data/lib/rubygems/commands/specification_command.rb +23 -3
- data/lib/rubygems/commands/uninstall_command.rb +71 -61
- data/lib/rubygems/commands/unpack_command.rb +14 -12
- data/lib/rubygems/commands/update_command.rb +26 -5
- data/lib/rubygems/defaults.rb +16 -3
- data/lib/rubygems/dependency.rb +38 -7
- data/lib/rubygems/dependency_installer.rb +7 -4
- data/lib/rubygems/digest/digest_adapter.rb +42 -33
- data/lib/rubygems/digest/sha1.rb +6 -1
- data/lib/rubygems/digest/sha2.rb +5 -0
- data/lib/rubygems/doc_manager.rb +31 -11
- data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
- data/lib/rubygems/ext/rake_builder.rb +6 -2
- data/lib/rubygems/format.rb +63 -63
- data/lib/rubygems/gem_openssl.rb +14 -2
- data/lib/rubygems/gem_path_searcher.rb +7 -3
- data/lib/rubygems/gem_runner.rb +59 -39
- data/lib/rubygems/indexer.rb +450 -109
- data/lib/rubygems/install_update_options.rb +13 -1
- data/lib/rubygems/installer.rb +25 -22
- data/lib/rubygems/local_remote_options.rb +5 -3
- data/lib/rubygems/old_format.rb +124 -120
- data/lib/rubygems/package/tar_header.rb +25 -3
- data/lib/rubygems/package/tar_input.rb +5 -5
- data/lib/rubygems/package/tar_output.rb +2 -0
- data/lib/rubygems/package/tar_reader.rb +19 -0
- data/lib/rubygems/package/tar_reader/entry.rb +43 -0
- data/lib/rubygems/package/tar_writer.rb +65 -3
- data/lib/rubygems/package_task.rb +117 -0
- data/lib/rubygems/platform.rb +12 -8
- data/lib/rubygems/remote_fetcher.rb +43 -24
- data/lib/rubygems/require_paths_builder.rb +14 -12
- data/lib/rubygems/requirement.rb +15 -6
- data/lib/rubygems/rubygems_version.rb +14 -1
- data/lib/rubygems/source_index.rb +38 -16
- data/lib/rubygems/source_info_cache_entry.rb +2 -2
- data/lib/rubygems/spec_fetcher.rb +43 -20
- data/lib/rubygems/specification.rb +1122 -947
- data/lib/rubygems/text.rb +30 -0
- data/lib/rubygems/timer.rb +14 -11
- data/lib/rubygems/uninstaller.rb +25 -5
- data/lib/rubygems/user_interaction.rb +294 -264
- data/lib/rubygems/validator.rb +70 -36
- data/lib/rubygems/version.rb +97 -33
- data/lib/rubygems/version_option.rb +1 -0
- data/setup.rb +11 -306
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +22 -11
- data/test/gem_package_tar_test_case.rb +0 -14
- data/test/gemutilities.rb +89 -8
- data/test/mockgemui.rb +2 -1
- data/test/rubygems_plugin.rb +16 -0
- data/test/test_gem.rb +107 -36
- data/test/test_gem_command.rb +3 -13
- data/test/test_gem_command_manager.rb +1 -14
- data/test/test_gem_commands_cert_command.rb +1 -1
- data/test/test_gem_commands_contents_command.rb +63 -0
- data/test/test_gem_commands_environment_command.rb +1 -1
- data/test/test_gem_commands_generate_index_command.rb +104 -1
- data/test/test_gem_commands_install_command.rb +95 -0
- data/test/test_gem_commands_pristine_command.rb +3 -3
- data/test/test_gem_commands_query_command.rb +46 -0
- data/test/test_gem_commands_sources_command.rb +9 -5
- data/test/test_gem_commands_specification_command.rb +31 -0
- data/test/test_gem_commands_uninstall_command.rb +3 -2
- data/test/test_gem_commands_unpack_command.rb +3 -2
- data/test/test_gem_commands_update_command.rb +12 -7
- data/test/test_gem_dependency.rb +62 -11
- data/test/test_gem_dependency_installer.rb +18 -5
- data/test/test_gem_dependency_list.rb +6 -6
- data/test/test_gem_doc_manager.rb +7 -1
- data/test/test_gem_ext_configure_builder.rb +8 -10
- data/test/test_gem_ext_ext_conf_builder.rb +14 -8
- data/test/test_gem_gem_path_searcher.rb +1 -1
- data/test/test_gem_gem_runner.rb +11 -0
- data/test/test_gem_indexer.rb +398 -21
- data/test/test_gem_install_update_options.rb +20 -6
- data/test/test_gem_installer.rb +22 -14
- data/test/test_gem_local_remote_options.rb +2 -1
- data/test/test_gem_package_tar_header.rb +3 -3
- data/test/test_gem_package_tar_input.rb +3 -3
- data/test/test_gem_package_tar_output.rb +2 -2
- data/test/test_gem_package_task.rb +70 -0
- data/test/test_gem_platform.rb +12 -6
- data/test/test_gem_remote_fetcher.rb +23 -1
- data/test/test_gem_source_index.rb +32 -21
- data/test/test_gem_spec_fetcher.rb +77 -5
- data/test/test_gem_specification.rb +274 -1
- data/test/test_gem_uninstaller.rb +34 -4
- data/test/test_gem_version.rb +94 -4
- data/test/test_gem_version_option.rb +13 -0
- data/test/test_kernel.rb +4 -4
- data/util/CL2notes +56 -0
- data/util/gem_prelude.rb.template +251 -0
- metadata +30 -20
- metadata.gz.sig +3 -4
- data/TODO +0 -1
- data/scripts/buildtests.rb +0 -31
- data/scripts/gemdoc.rb +0 -67
- data/scripts/runtest.rb +0 -40
- data/scripts/specdoc.rb +0 -171
- data/scripts/upload_gemdoc.rb +0 -140
@@ -1,55 +1,131 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems/indexer'
|
3
3
|
|
4
|
+
##
|
5
|
+
# Generates a index files for use as a gem server.
|
6
|
+
#
|
7
|
+
# See `gem help generate_index`
|
8
|
+
|
4
9
|
class Gem::Commands::GenerateIndexCommand < Gem::Command
|
5
10
|
|
6
11
|
def initialize
|
7
12
|
super 'generate_index',
|
8
13
|
'Generates the index files for a gem server directory',
|
9
|
-
:directory => '.'
|
14
|
+
:directory => '.', :build_legacy => true, :build_modern => true
|
10
15
|
|
11
16
|
add_option '-d', '--directory=DIRNAME',
|
12
17
|
'repository base dir containing gems subdir' do |dir, options|
|
13
18
|
options[:directory] = File.expand_path dir
|
14
19
|
end
|
20
|
+
|
21
|
+
add_option '--[no-]legacy',
|
22
|
+
'Generate indexes for RubyGems older than',
|
23
|
+
'1.2.0' do |value, options|
|
24
|
+
unless options[:build_modern] or value then
|
25
|
+
raise OptionParser::InvalidOption, 'no indicies will be built'
|
26
|
+
end
|
27
|
+
|
28
|
+
options[:build_legacy] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
add_option '--[no-]modern',
|
32
|
+
'Generate indexes for RubyGems newer',
|
33
|
+
'than 1.2.0' do |value, options|
|
34
|
+
unless options[:build_legacy] or value then
|
35
|
+
raise OptionParser::InvalidOption, 'no indicies will be built'
|
36
|
+
end
|
37
|
+
|
38
|
+
options[:build_modern] = value
|
39
|
+
end
|
40
|
+
|
41
|
+
add_option '--update',
|
42
|
+
'Update modern indexes with gems added',
|
43
|
+
'since the last update' do |value, options|
|
44
|
+
options[:update] = value
|
45
|
+
end
|
46
|
+
|
47
|
+
add_option :RSS, '--rss-gems-host=GEM_HOST',
|
48
|
+
'Host name where gems are served from,',
|
49
|
+
'used for GUID and enclosure values' do |value, options|
|
50
|
+
options[:rss_gems_host] = value
|
51
|
+
end
|
52
|
+
|
53
|
+
add_option :RSS, '--rss-host=HOST',
|
54
|
+
'Host name for more gems information,',
|
55
|
+
'used for RSS feed link' do |value, options|
|
56
|
+
options[:rss_host] = value
|
57
|
+
end
|
58
|
+
|
59
|
+
add_option :RSS, '--rss-title=TITLE',
|
60
|
+
'Set title for RSS feed' do |value, options|
|
61
|
+
options[:rss_title] = value
|
62
|
+
end
|
15
63
|
end
|
16
64
|
|
17
65
|
def defaults_str # :nodoc:
|
18
|
-
"--directory ."
|
66
|
+
"--directory . --legacy --modern"
|
19
67
|
end
|
20
68
|
|
21
69
|
def description # :nodoc:
|
22
70
|
<<-EOF
|
23
71
|
The generate_index command creates a set of indexes for serving gems
|
24
72
|
statically. The command expects a 'gems' directory under the path given to
|
25
|
-
the --directory option.
|
73
|
+
the --directory option. The given directory will be the directory you serve
|
74
|
+
as the gem repository.
|
75
|
+
|
76
|
+
For `gem generate_index --directory /path/to/repo`, expose /path/to/repo via
|
77
|
+
your HTTP server configuration (not /path/to/repo/gems).
|
78
|
+
|
79
|
+
When done, it will generate a set of files like this:
|
80
|
+
|
81
|
+
gems/*.gem # .gem files you want to
|
82
|
+
# index
|
83
|
+
|
84
|
+
specs.<version>.gz # specs index
|
85
|
+
latest_specs.<version>.gz # latest specs index
|
86
|
+
prerelease_specs.<version>.gz # prerelease specs index
|
87
|
+
quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal quick index file
|
26
88
|
|
27
|
-
|
89
|
+
# these files support legacy RubyGems
|
28
90
|
quick/index
|
29
91
|
quick/index.rz # quick index manifest
|
30
|
-
quick/<gemname>.gemspec.rz # legacy YAML quick index
|
31
|
-
|
92
|
+
quick/<gemname>.gemspec.rz # legacy YAML quick index
|
93
|
+
# file
|
32
94
|
Marshal.<version>
|
33
|
-
Marshal.<version>.Z
|
95
|
+
Marshal.<version>.Z # Marshal full index
|
34
96
|
yaml
|
35
|
-
yaml.Z
|
97
|
+
yaml.Z # legacy YAML full index
|
98
|
+
|
99
|
+
The .Z and .rz extension files are compressed with the inflate algorithm.
|
100
|
+
The Marshal version number comes from ruby's Marshal::MAJOR_VERSION and
|
101
|
+
Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
|
102
|
+
The yaml indexes exist for legacy RubyGems clients and fallback in case of
|
103
|
+
Marshal version changes.
|
36
104
|
|
37
|
-
|
38
|
-
|
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.
|
105
|
+
If --rss-host and --rss-gem-host are given an RSS feed will be generated at
|
106
|
+
index.rss containing gems released in the last two days.
|
42
107
|
EOF
|
43
108
|
end
|
44
109
|
|
45
110
|
def execute
|
111
|
+
if options[:update] and
|
112
|
+
(options[:rss_host] or options[:rss_gems_host]) then
|
113
|
+
alert_error '--update not compatible with RSS generation'
|
114
|
+
terminate_interaction 1
|
115
|
+
end
|
116
|
+
|
46
117
|
if not File.exist?(options[:directory]) or
|
47
118
|
not File.directory?(options[:directory]) then
|
48
119
|
alert_error "unknown directory name #{directory}."
|
49
120
|
terminate_interaction 1
|
50
121
|
else
|
51
|
-
indexer = Gem::Indexer.new options
|
52
|
-
|
122
|
+
indexer = Gem::Indexer.new options.delete(:directory), options
|
123
|
+
|
124
|
+
if options[:update] then
|
125
|
+
indexer.update_index
|
126
|
+
else
|
127
|
+
indexer.generate_index
|
128
|
+
end
|
53
129
|
end
|
54
130
|
end
|
55
131
|
|
@@ -6,6 +6,11 @@ require 'rubygems/local_remote_options'
|
|
6
6
|
require 'rubygems/validator'
|
7
7
|
require 'rubygems/version_option'
|
8
8
|
|
9
|
+
##
|
10
|
+
# Gem installer command line tool
|
11
|
+
#
|
12
|
+
# See `gem help install`
|
13
|
+
|
9
14
|
class Gem::Commands::InstallCommand < Gem::Command
|
10
15
|
|
11
16
|
include Gem::VersionOption
|
@@ -14,11 +19,11 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
14
19
|
|
15
20
|
def initialize
|
16
21
|
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
|
17
|
-
:generate_rdoc
|
18
|
-
:generate_ri
|
22
|
+
:generate_rdoc => true,
|
23
|
+
:generate_ri => true,
|
19
24
|
:format_executable => false,
|
20
|
-
:test
|
21
|
-
:version
|
25
|
+
:test => false,
|
26
|
+
:version => Gem::Requirement.default,
|
22
27
|
})
|
23
28
|
|
24
29
|
super 'install', 'Install a gem into the local repository', defaults
|
@@ -43,7 +48,7 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
43
48
|
The install command installs local or remote gem into a gem repository.
|
44
49
|
|
45
50
|
For gems with executables ruby installs a wrapper file into the executable
|
46
|
-
directory by
|
51
|
+
directory by default. This can be overridden with the --no-wrappers option.
|
47
52
|
The wrapper allows you to choose among alternate gem versions using _version_.
|
48
53
|
|
49
54
|
For example `rake _0.7.3_ --version` will run rake version 0.7.3 if a newer
|
@@ -65,24 +70,11 @@ version is also installed.
|
|
65
70
|
|
66
71
|
ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
|
67
72
|
|
68
|
-
install_options = {
|
69
|
-
:env_shebang => options[:env_shebang],
|
70
|
-
:domain => options[:domain],
|
71
|
-
:force => options[:force],
|
72
|
-
:format_executable => options[:format_executable],
|
73
|
-
:ignore_dependencies => options[:ignore_dependencies],
|
74
|
-
:install_dir => options[:install_dir],
|
75
|
-
:security_policy => options[:security_policy],
|
76
|
-
:wrappers => options[:wrappers],
|
77
|
-
:bin_dir => options[:bin_dir],
|
78
|
-
:development => options[:development],
|
79
|
-
}
|
80
|
-
|
81
73
|
exit_code = 0
|
82
74
|
|
83
75
|
get_all_gem_names.each do |gem_name|
|
84
76
|
begin
|
85
|
-
inst = Gem::DependencyInstaller.new
|
77
|
+
inst = Gem::DependencyInstaller.new options
|
86
78
|
inst.install gem_name, options[:version]
|
87
79
|
|
88
80
|
inst.installed_gems.each do |spec|
|
@@ -96,46 +88,40 @@ version is also installed.
|
|
96
88
|
rescue Gem::GemNotFoundException => e
|
97
89
|
alert_error e.message
|
98
90
|
exit_code |= 2
|
99
|
-
# rescue => e
|
100
|
-
# # TODO: Fix this handle to allow the error to propagate to
|
101
|
-
# # the top level handler. Examine the other errors as
|
102
|
-
# # well. This implementation here looks suspicious to me --
|
103
|
-
# # JimWeirich (4/Jan/05)
|
104
|
-
# alert_error "Error installing gem #{gem_name}: #{e.message}"
|
105
|
-
# return
|
106
91
|
end
|
107
92
|
end
|
108
93
|
|
109
94
|
unless installed_gems.empty? then
|
110
95
|
gems = installed_gems.length == 1 ? 'gem' : 'gems'
|
111
96
|
say "#{installed_gems.length} #{gems} installed"
|
112
|
-
end
|
113
97
|
|
114
|
-
|
115
|
-
|
116
|
-
|
98
|
+
# NOTE: *All* of the RI documents must be generated first. For some
|
99
|
+
# reason, RI docs cannot be generated after any RDoc documents are
|
100
|
+
# generated.
|
117
101
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
102
|
+
if options[:generate_ri] then
|
103
|
+
installed_gems.each do |gem|
|
104
|
+
Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
|
105
|
+
end
|
122
106
|
|
123
|
-
|
124
|
-
|
107
|
+
Gem::DocManager.update_ri_cache
|
108
|
+
end
|
125
109
|
|
126
|
-
|
127
|
-
|
128
|
-
|
110
|
+
if options[:generate_rdoc] then
|
111
|
+
installed_gems.each do |gem|
|
112
|
+
Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
|
113
|
+
end
|
129
114
|
end
|
130
|
-
end
|
131
115
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
116
|
+
if options[:test] then
|
117
|
+
installed_gems.each do |spec|
|
118
|
+
gem_spec = Gem::SourceIndex.from_installed_gems.search(spec.name, spec.version.version).first
|
119
|
+
result = Gem::Validator.new.unit_test(gem_spec)
|
120
|
+
if result and not result.passed?
|
121
|
+
unless ask_yes_no("...keep Gem?", true)
|
122
|
+
require 'rubygems/uninstaller'
|
123
|
+
Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall
|
124
|
+
end
|
139
125
|
end
|
140
126
|
end
|
141
127
|
end
|
@@ -2,9 +2,11 @@ require 'rubygems/command'
|
|
2
2
|
require 'rubygems/local_remote_options'
|
3
3
|
require 'rubygems/spec_fetcher'
|
4
4
|
require 'rubygems/version_option'
|
5
|
+
require 'rubygems/text'
|
5
6
|
|
6
7
|
class Gem::Commands::QueryCommand < Gem::Command
|
7
8
|
|
9
|
+
include Gem::Text
|
8
10
|
include Gem::LocalRemoteOptions
|
9
11
|
include Gem::VersionOption
|
10
12
|
|
@@ -145,6 +147,12 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
145
147
|
version
|
146
148
|
end.reverse
|
147
149
|
|
150
|
+
platforms = Hash.new { |h,version| h[version] = [] }
|
151
|
+
|
152
|
+
matching_tuples.map do |(name, version, platform,_),_|
|
153
|
+
platforms[version] << platform if platform
|
154
|
+
end
|
155
|
+
|
148
156
|
seen = {}
|
149
157
|
|
150
158
|
matching_tuples.delete_if do |(name, version,_),_|
|
@@ -174,6 +182,28 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
174
182
|
end
|
175
183
|
|
176
184
|
entry << "\n"
|
185
|
+
|
186
|
+
non_ruby = platforms.any? do |_, pls|
|
187
|
+
pls.any? { |pl| pl != Gem::Platform::RUBY }
|
188
|
+
end
|
189
|
+
|
190
|
+
if non_ruby then
|
191
|
+
if platforms.length == 1 then
|
192
|
+
title = platforms.values.length == 1 ? 'Platform' : 'Platforms'
|
193
|
+
entry << " #{title}: #{platforms.values.sort.join ', '}\n"
|
194
|
+
else
|
195
|
+
entry << " Platforms:\n"
|
196
|
+
platforms.sort_by do |version,|
|
197
|
+
version
|
198
|
+
end.each do |version, pls|
|
199
|
+
label = " #{version}: "
|
200
|
+
data = format_text pls.sort.join(', '), 68, label.length
|
201
|
+
data[0, label.length] = label
|
202
|
+
entry << data << "\n"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
177
207
|
authors = "Author#{spec.authors.length > 1 ? 's' : ''}: "
|
178
208
|
authors << spec.authors.join(', ')
|
179
209
|
entry << format_text(authors, 68, 4)
|
@@ -187,6 +217,12 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
187
217
|
entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4)
|
188
218
|
end
|
189
219
|
|
220
|
+
if spec.license and not spec.license.empty? then
|
221
|
+
licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: "
|
222
|
+
licenses << spec.licenses.join(', ')
|
223
|
+
entry << "\n" << format_text(licenses, 68, 4)
|
224
|
+
end
|
225
|
+
|
190
226
|
if spec.loaded_from then
|
191
227
|
if matching_tuples.length == 1 then
|
192
228
|
loaded_from = File.dirname File.dirname(spec.loaded_from)
|
@@ -209,25 +245,5 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
209
245
|
say output.join(options[:details] ? "\n\n" : "\n")
|
210
246
|
end
|
211
247
|
|
212
|
-
##
|
213
|
-
# Used for wrapping and indenting text
|
214
|
-
|
215
|
-
def format_text(text, wrap, indent=0)
|
216
|
-
result = []
|
217
|
-
work = text.dup
|
218
|
-
|
219
|
-
while work.length > wrap
|
220
|
-
if work =~ /^(.{0,#{wrap}})[ \n]/o then
|
221
|
-
result << $1
|
222
|
-
work.slice!(0, $&.length)
|
223
|
-
else
|
224
|
-
result << work.slice!(0, wrap)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
result << work if work.length.nonzero?
|
229
|
-
result.join("\n").gsub(/^/, " " * indent)
|
230
|
-
end
|
231
|
-
|
232
248
|
end
|
233
249
|
|
@@ -2,81 +2,75 @@ require 'rubygems/command'
|
|
2
2
|
require 'rubygems/version_option'
|
3
3
|
require 'rubygems/doc_manager'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
class RdocCommand < Command
|
8
|
-
include VersionOption
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
super('rdoc',
|
12
|
-
'Generates RDoc for pre-installed gems',
|
13
|
-
{
|
14
|
-
:version => Gem::Requirement.default,
|
15
|
-
:include_rdoc => true,
|
16
|
-
:include_ri => true,
|
17
|
-
})
|
18
|
-
add_option('--all',
|
19
|
-
'Generate RDoc/RI documentation for all',
|
20
|
-
'installed gems') do |value, options|
|
21
|
-
options[:all] = value
|
22
|
-
end
|
23
|
-
add_option('--[no-]rdoc',
|
24
|
-
'Include RDoc generated documents') do
|
25
|
-
|value, options|
|
26
|
-
options[:include_rdoc] = value
|
27
|
-
end
|
28
|
-
add_option('--[no-]ri',
|
29
|
-
'Include RI generated documents'
|
30
|
-
) do |value, options|
|
31
|
-
options[:include_ri] = value
|
32
|
-
end
|
33
|
-
add_version_option
|
34
|
-
end
|
5
|
+
class Gem::Commands::RdocCommand < Gem::Command
|
6
|
+
include Gem::VersionOption
|
35
7
|
|
36
|
-
|
37
|
-
|
38
|
-
|
8
|
+
def initialize
|
9
|
+
super 'rdoc', 'Generates RDoc for pre-installed gems',
|
10
|
+
:version => Gem::Requirement.default,
|
11
|
+
:include_rdoc => true, :include_ri => true
|
39
12
|
|
40
|
-
|
41
|
-
|
42
|
-
|
13
|
+
add_option('--all',
|
14
|
+
'Generate RDoc/RI documentation for all',
|
15
|
+
'installed gems') do |value, options|
|
16
|
+
options[:all] = value
|
17
|
+
end
|
18
|
+
|
19
|
+
add_option('--[no-]rdoc',
|
20
|
+
'Include RDoc generated documents') do |value, options|
|
21
|
+
options[:include_rdoc] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
add_option('--[no-]ri',
|
25
|
+
'Include RI generated documents') do |value, options|
|
26
|
+
options[:include_ri] = value
|
27
|
+
end
|
28
|
+
|
29
|
+
add_version_option
|
30
|
+
end
|
31
|
+
|
32
|
+
def arguments # :nodoc:
|
33
|
+
"GEMNAME gem to generate documentation for (unless --all)"
|
34
|
+
end
|
43
35
|
|
44
|
-
|
45
|
-
|
36
|
+
def defaults_str # :nodoc:
|
37
|
+
"--version '#{Gem::Requirement.default}' --rdoc --ri"
|
38
|
+
end
|
39
|
+
|
40
|
+
def usage # :nodoc:
|
41
|
+
"#{program_name} [args]"
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute
|
45
|
+
if options[:all] then
|
46
|
+
specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec|
|
47
|
+
spec
|
48
|
+
}
|
49
|
+
else
|
50
|
+
gem_name = get_one_gem_name
|
51
|
+
dep = Gem::Dependency.new gem_name, options[:version]
|
52
|
+
specs = Gem::SourceIndex.from_installed_gems.search dep
|
53
|
+
end
|
54
|
+
|
55
|
+
if specs.empty?
|
56
|
+
fail "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
|
57
|
+
end
|
58
|
+
|
59
|
+
if options[:include_ri]
|
60
|
+
specs.each do |spec|
|
61
|
+
Gem::DocManager.new(spec).generate_ri
|
46
62
|
end
|
47
63
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
gem_name = get_one_gem_name
|
55
|
-
specs = Gem::SourceIndex.from_installed_gems.search(
|
56
|
-
gem_name, options[:version])
|
57
|
-
end
|
58
|
-
|
59
|
-
if specs.empty?
|
60
|
-
fail "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
|
61
|
-
end
|
62
|
-
|
63
|
-
if options[:include_ri]
|
64
|
-
specs.each do |spec|
|
65
|
-
Gem::DocManager.new(spec).generate_ri
|
66
|
-
end
|
67
|
-
|
68
|
-
Gem::DocManager.update_ri_cache
|
69
|
-
end
|
70
|
-
|
71
|
-
if options[:include_rdoc]
|
72
|
-
specs.each do |spec|
|
73
|
-
Gem::DocManager.new(spec).generate_rdoc
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
true
|
64
|
+
Gem::DocManager.update_ri_cache
|
65
|
+
end
|
66
|
+
|
67
|
+
if options[:include_rdoc]
|
68
|
+
specs.each do |spec|
|
69
|
+
Gem::DocManager.new(spec).generate_rdoc
|
78
70
|
end
|
79
71
|
end
|
80
72
|
|
73
|
+
true
|
81
74
|
end
|
82
75
|
end
|
76
|
+
|