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.

Files changed (128) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +24 -0
  3. data/.document +4 -3
  4. data/ChangeLog +382 -1
  5. data/Manifest.txt +214 -0
  6. data/README +1 -49
  7. data/Rakefile +124 -191
  8. data/bin/gem +1 -4
  9. data/cruise_config.rb +22 -0
  10. data/doc/release_notes/rel_1_3_1.rdoc +3 -3
  11. data/doc/release_notes/rel_1_3_2.rdoc +119 -0
  12. data/lib/gauntlet_rubygems.rb +50 -0
  13. data/lib/rubygems.rb +250 -25
  14. data/lib/rubygems/builder.rb +62 -60
  15. data/lib/rubygems/command.rb +421 -319
  16. data/lib/rubygems/command_manager.rb +153 -125
  17. data/lib/rubygems/commands/check_command.rb +12 -7
  18. data/lib/rubygems/commands/cleanup_command.rb +11 -2
  19. data/lib/rubygems/commands/contents_command.rb +42 -18
  20. data/lib/rubygems/commands/generate_index_command.rb +91 -15
  21. data/lib/rubygems/commands/install_command.rb +33 -47
  22. data/lib/rubygems/commands/query_command.rb +36 -20
  23. data/lib/rubygems/commands/rdoc_command.rb +62 -68
  24. data/lib/rubygems/commands/search_command.rb +26 -32
  25. data/lib/rubygems/commands/setup_command.rb +353 -0
  26. data/lib/rubygems/commands/sources_command.rb +5 -0
  27. data/lib/rubygems/commands/specification_command.rb +23 -3
  28. data/lib/rubygems/commands/uninstall_command.rb +71 -61
  29. data/lib/rubygems/commands/unpack_command.rb +14 -12
  30. data/lib/rubygems/commands/update_command.rb +26 -5
  31. data/lib/rubygems/defaults.rb +16 -3
  32. data/lib/rubygems/dependency.rb +38 -7
  33. data/lib/rubygems/dependency_installer.rb +7 -4
  34. data/lib/rubygems/digest/digest_adapter.rb +42 -33
  35. data/lib/rubygems/digest/sha1.rb +6 -1
  36. data/lib/rubygems/digest/sha2.rb +5 -0
  37. data/lib/rubygems/doc_manager.rb +31 -11
  38. data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
  39. data/lib/rubygems/ext/rake_builder.rb +6 -2
  40. data/lib/rubygems/format.rb +63 -63
  41. data/lib/rubygems/gem_openssl.rb +14 -2
  42. data/lib/rubygems/gem_path_searcher.rb +7 -3
  43. data/lib/rubygems/gem_runner.rb +59 -39
  44. data/lib/rubygems/indexer.rb +450 -109
  45. data/lib/rubygems/install_update_options.rb +13 -1
  46. data/lib/rubygems/installer.rb +25 -22
  47. data/lib/rubygems/local_remote_options.rb +5 -3
  48. data/lib/rubygems/old_format.rb +124 -120
  49. data/lib/rubygems/package/tar_header.rb +25 -3
  50. data/lib/rubygems/package/tar_input.rb +5 -5
  51. data/lib/rubygems/package/tar_output.rb +2 -0
  52. data/lib/rubygems/package/tar_reader.rb +19 -0
  53. data/lib/rubygems/package/tar_reader/entry.rb +43 -0
  54. data/lib/rubygems/package/tar_writer.rb +65 -3
  55. data/lib/rubygems/package_task.rb +117 -0
  56. data/lib/rubygems/platform.rb +12 -8
  57. data/lib/rubygems/remote_fetcher.rb +43 -24
  58. data/lib/rubygems/require_paths_builder.rb +14 -12
  59. data/lib/rubygems/requirement.rb +15 -6
  60. data/lib/rubygems/rubygems_version.rb +14 -1
  61. data/lib/rubygems/source_index.rb +38 -16
  62. data/lib/rubygems/source_info_cache_entry.rb +2 -2
  63. data/lib/rubygems/spec_fetcher.rb +43 -20
  64. data/lib/rubygems/specification.rb +1122 -947
  65. data/lib/rubygems/text.rb +30 -0
  66. data/lib/rubygems/timer.rb +14 -11
  67. data/lib/rubygems/uninstaller.rb +25 -5
  68. data/lib/rubygems/user_interaction.rb +294 -264
  69. data/lib/rubygems/validator.rb +70 -36
  70. data/lib/rubygems/version.rb +97 -33
  71. data/lib/rubygems/version_option.rb +1 -0
  72. data/setup.rb +11 -306
  73. data/test/foo/discover.rb +0 -0
  74. data/test/gem_installer_test_case.rb +22 -11
  75. data/test/gem_package_tar_test_case.rb +0 -14
  76. data/test/gemutilities.rb +89 -8
  77. data/test/mockgemui.rb +2 -1
  78. data/test/rubygems_plugin.rb +16 -0
  79. data/test/test_gem.rb +107 -36
  80. data/test/test_gem_command.rb +3 -13
  81. data/test/test_gem_command_manager.rb +1 -14
  82. data/test/test_gem_commands_cert_command.rb +1 -1
  83. data/test/test_gem_commands_contents_command.rb +63 -0
  84. data/test/test_gem_commands_environment_command.rb +1 -1
  85. data/test/test_gem_commands_generate_index_command.rb +104 -1
  86. data/test/test_gem_commands_install_command.rb +95 -0
  87. data/test/test_gem_commands_pristine_command.rb +3 -3
  88. data/test/test_gem_commands_query_command.rb +46 -0
  89. data/test/test_gem_commands_sources_command.rb +9 -5
  90. data/test/test_gem_commands_specification_command.rb +31 -0
  91. data/test/test_gem_commands_uninstall_command.rb +3 -2
  92. data/test/test_gem_commands_unpack_command.rb +3 -2
  93. data/test/test_gem_commands_update_command.rb +12 -7
  94. data/test/test_gem_dependency.rb +62 -11
  95. data/test/test_gem_dependency_installer.rb +18 -5
  96. data/test/test_gem_dependency_list.rb +6 -6
  97. data/test/test_gem_doc_manager.rb +7 -1
  98. data/test/test_gem_ext_configure_builder.rb +8 -10
  99. data/test/test_gem_ext_ext_conf_builder.rb +14 -8
  100. data/test/test_gem_gem_path_searcher.rb +1 -1
  101. data/test/test_gem_gem_runner.rb +11 -0
  102. data/test/test_gem_indexer.rb +398 -21
  103. data/test/test_gem_install_update_options.rb +20 -6
  104. data/test/test_gem_installer.rb +22 -14
  105. data/test/test_gem_local_remote_options.rb +2 -1
  106. data/test/test_gem_package_tar_header.rb +3 -3
  107. data/test/test_gem_package_tar_input.rb +3 -3
  108. data/test/test_gem_package_tar_output.rb +2 -2
  109. data/test/test_gem_package_task.rb +70 -0
  110. data/test/test_gem_platform.rb +12 -6
  111. data/test/test_gem_remote_fetcher.rb +23 -1
  112. data/test/test_gem_source_index.rb +32 -21
  113. data/test/test_gem_spec_fetcher.rb +77 -5
  114. data/test/test_gem_specification.rb +274 -1
  115. data/test/test_gem_uninstaller.rb +34 -4
  116. data/test/test_gem_version.rb +94 -4
  117. data/test/test_gem_version_option.rb +13 -0
  118. data/test/test_kernel.rb +4 -4
  119. data/util/CL2notes +56 -0
  120. data/util/gem_prelude.rb.template +251 -0
  121. metadata +30 -20
  122. metadata.gz.sig +3 -4
  123. data/TODO +0 -1
  124. data/scripts/buildtests.rb +0 -31
  125. data/scripts/gemdoc.rb +0 -67
  126. data/scripts/runtest.rb +0 -40
  127. data/scripts/specdoc.rb +0 -171
  128. 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. When done, it will generate a set of files like this:
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
- gems/ # .gem files you want to index
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 file
31
- quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal quick index file
92
+ quick/<gemname>.gemspec.rz # legacy YAML quick index
93
+ # file
32
94
  Marshal.<version>
33
- Marshal.<version>.Z # Marshal full index
95
+ Marshal.<version>.Z # Marshal full index
34
96
  yaml
35
- yaml.Z # legacy YAML full index
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
- 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.
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[:directory]
52
- indexer.generate_index
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 => true,
18
- :generate_ri => true,
22
+ :generate_rdoc => true,
23
+ :generate_ri => true,
19
24
  :format_executable => false,
20
- :test => false,
21
- :version => Gem::Requirement.default,
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 deault. This can be overridden with the --no-wrappers option.
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 install_options
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
- # NOTE: *All* of the RI documents must be generated first.
115
- # For some reason, RI docs cannot be generated after any RDoc
116
- # documents are generated.
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
- if options[:generate_ri] then
119
- installed_gems.each do |gem|
120
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
121
- end
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
- Gem::DocManager.update_ri_cache
124
- end
107
+ Gem::DocManager.update_ri_cache
108
+ end
125
109
 
126
- if options[:generate_rdoc] then
127
- installed_gems.each do |gem|
128
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
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
- if options[:test] then
133
- installed_gems.each do |spec|
134
- gem_spec = Gem::SourceIndex.from_installed_gems.search(spec.name, spec.version.version).first
135
- result = Gem::Validator.new.unit_test(gem_spec)
136
- if result and not result.passed?
137
- unless ask_yes_no("...keep Gem?", true) then
138
- Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall
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
- module Gem
6
- module Commands
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
- def arguments # :nodoc:
37
- "GEMNAME gem to generate documentation for (unless --all)"
38
- end
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
- def defaults_str # :nodoc:
41
- "--version '#{Gem::Requirement.default}' --rdoc --ri"
42
- end
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
- def usage # :nodoc:
45
- "#{program_name} [args]"
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
- def execute
49
- if options[:all]
50
- specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec|
51
- spec
52
- }
53
- else
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
+