libgems 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/ChangeLog +5811 -0
  2. data/History.txt +887 -0
  3. data/LICENSE.txt +51 -0
  4. data/README.md +87 -0
  5. data/Rakefile +113 -0
  6. data/lib/gauntlet_libgems.rb +50 -0
  7. data/lib/libgems.rb +1246 -0
  8. data/lib/libgems/builder.rb +102 -0
  9. data/lib/libgems/command.rb +534 -0
  10. data/lib/libgems/command_manager.rb +182 -0
  11. data/lib/libgems/commands/build_command.rb +53 -0
  12. data/lib/libgems/commands/cert_command.rb +86 -0
  13. data/lib/libgems/commands/check_command.rb +80 -0
  14. data/lib/libgems/commands/cleanup_command.rb +106 -0
  15. data/lib/libgems/commands/contents_command.rb +98 -0
  16. data/lib/libgems/commands/dependency_command.rb +195 -0
  17. data/lib/libgems/commands/environment_command.rb +133 -0
  18. data/lib/libgems/commands/fetch_command.rb +67 -0
  19. data/lib/libgems/commands/generate_index_command.rb +133 -0
  20. data/lib/libgems/commands/help_command.rb +172 -0
  21. data/lib/libgems/commands/install_command.rb +178 -0
  22. data/lib/libgems/commands/list_command.rb +35 -0
  23. data/lib/libgems/commands/lock_command.rb +110 -0
  24. data/lib/libgems/commands/mirror_command.rb +111 -0
  25. data/lib/libgems/commands/outdated_command.rb +33 -0
  26. data/lib/libgems/commands/owner_command.rb +75 -0
  27. data/lib/libgems/commands/pristine_command.rb +93 -0
  28. data/lib/libgems/commands/push_command.rb +56 -0
  29. data/lib/libgems/commands/query_command.rb +280 -0
  30. data/lib/libgems/commands/rdoc_command.rb +91 -0
  31. data/lib/libgems/commands/search_command.rb +31 -0
  32. data/lib/libgems/commands/server_command.rb +86 -0
  33. data/lib/libgems/commands/sources_command.rb +157 -0
  34. data/lib/libgems/commands/specification_command.rb +125 -0
  35. data/lib/libgems/commands/stale_command.rb +27 -0
  36. data/lib/libgems/commands/uninstall_command.rb +83 -0
  37. data/lib/libgems/commands/unpack_command.rb +121 -0
  38. data/lib/libgems/commands/update_command.rb +160 -0
  39. data/lib/libgems/commands/which_command.rb +86 -0
  40. data/lib/libgems/config_file.rb +345 -0
  41. data/lib/libgems/custom_require.rb +44 -0
  42. data/lib/libgems/defaults.rb +101 -0
  43. data/lib/libgems/dependency.rb +227 -0
  44. data/lib/libgems/dependency_installer.rb +286 -0
  45. data/lib/libgems/dependency_list.rb +208 -0
  46. data/lib/libgems/doc_manager.rb +242 -0
  47. data/lib/libgems/errors.rb +35 -0
  48. data/lib/libgems/exceptions.rb +91 -0
  49. data/lib/libgems/ext.rb +18 -0
  50. data/lib/libgems/ext/builder.rb +56 -0
  51. data/lib/libgems/ext/configure_builder.rb +25 -0
  52. data/lib/libgems/ext/ext_conf_builder.rb +24 -0
  53. data/lib/libgems/ext/rake_builder.rb +39 -0
  54. data/lib/libgems/format.rb +81 -0
  55. data/lib/libgems/gem_openssl.rb +92 -0
  56. data/lib/libgems/gem_path_searcher.rb +100 -0
  57. data/lib/libgems/gem_runner.rb +79 -0
  58. data/lib/libgems/gemcutter_utilities.rb +49 -0
  59. data/lib/libgems/indexer.rb +720 -0
  60. data/lib/libgems/install_update_options.rb +125 -0
  61. data/lib/libgems/installer.rb +604 -0
  62. data/lib/libgems/local_remote_options.rb +135 -0
  63. data/lib/libgems/old_format.rb +153 -0
  64. data/lib/libgems/package.rb +97 -0
  65. data/lib/libgems/package/f_sync_dir.rb +23 -0
  66. data/lib/libgems/package/tar_header.rb +266 -0
  67. data/lib/libgems/package/tar_input.rb +222 -0
  68. data/lib/libgems/package/tar_output.rb +144 -0
  69. data/lib/libgems/package/tar_reader.rb +106 -0
  70. data/lib/libgems/package/tar_reader/entry.rb +141 -0
  71. data/lib/libgems/package/tar_writer.rb +241 -0
  72. data/lib/libgems/package_task.rb +126 -0
  73. data/lib/libgems/platform.rb +183 -0
  74. data/lib/libgems/remote_fetcher.rb +414 -0
  75. data/lib/libgems/require_paths_builder.rb +18 -0
  76. data/lib/libgems/requirement.rb +153 -0
  77. data/lib/libgems/security.rb +814 -0
  78. data/lib/libgems/server.rb +872 -0
  79. data/lib/libgems/source_index.rb +597 -0
  80. data/lib/libgems/source_info_cache.rb +395 -0
  81. data/lib/libgems/source_info_cache_entry.rb +56 -0
  82. data/lib/libgems/spec_fetcher.rb +337 -0
  83. data/lib/libgems/specification.rb +1487 -0
  84. data/lib/libgems/test_utilities.rb +147 -0
  85. data/lib/libgems/text.rb +65 -0
  86. data/lib/libgems/uninstaller.rb +278 -0
  87. data/lib/libgems/user_interaction.rb +527 -0
  88. data/lib/libgems/validator.rb +240 -0
  89. data/lib/libgems/version.rb +316 -0
  90. data/lib/libgems/version_option.rb +65 -0
  91. data/lib/rbconfig/datadir.rb +20 -0
  92. data/test/bogussources.rb +8 -0
  93. data/test/data/gem-private_key.pem +27 -0
  94. data/test/data/gem-public_cert.pem +20 -0
  95. data/test/fake_certlib/openssl.rb +7 -0
  96. data/test/foo/discover.rb +0 -0
  97. data/test/gem_installer_test_case.rb +97 -0
  98. data/test/gem_package_tar_test_case.rb +132 -0
  99. data/test/gemutilities.rb +605 -0
  100. data/test/insure_session.rb +43 -0
  101. data/test/mockgemui.rb +56 -0
  102. data/test/plugin/exception/libgems_plugin.rb +2 -0
  103. data/test/plugin/load/libgems_plugin.rb +1 -0
  104. data/test/plugin/standarderror/libgems_plugin.rb +2 -0
  105. data/test/private_key.pem +27 -0
  106. data/test/public_cert.pem +20 -0
  107. data/test/rubygems_plugin.rb +21 -0
  108. data/test/simple_gem.rb +66 -0
  109. data/test/test_config.rb +12 -0
  110. data/test/test_gem.rb +780 -0
  111. data/test/test_gem_builder.rb +27 -0
  112. data/test/test_gem_command.rb +178 -0
  113. data/test/test_gem_command_manager.rb +207 -0
  114. data/test/test_gem_commands_build_command.rb +74 -0
  115. data/test/test_gem_commands_cert_command.rb +124 -0
  116. data/test/test_gem_commands_check_command.rb +18 -0
  117. data/test/test_gem_commands_contents_command.rb +156 -0
  118. data/test/test_gem_commands_dependency_command.rb +216 -0
  119. data/test/test_gem_commands_environment_command.rb +144 -0
  120. data/test/test_gem_commands_fetch_command.rb +76 -0
  121. data/test/test_gem_commands_generate_index_command.rb +135 -0
  122. data/test/test_gem_commands_install_command.rb +315 -0
  123. data/test/test_gem_commands_list_command.rb +36 -0
  124. data/test/test_gem_commands_lock_command.rb +68 -0
  125. data/test/test_gem_commands_mirror_command.rb +60 -0
  126. data/test/test_gem_commands_outdated_command.rb +40 -0
  127. data/test/test_gem_commands_owner_command.rb +105 -0
  128. data/test/test_gem_commands_pristine_command.rb +108 -0
  129. data/test/test_gem_commands_push_command.rb +81 -0
  130. data/test/test_gem_commands_query_command.rb +426 -0
  131. data/test/test_gem_commands_server_command.rb +59 -0
  132. data/test/test_gem_commands_sources_command.rb +209 -0
  133. data/test/test_gem_commands_specification_command.rb +139 -0
  134. data/test/test_gem_commands_stale_command.rb +38 -0
  135. data/test/test_gem_commands_uninstall_command.rb +83 -0
  136. data/test/test_gem_commands_unpack_command.rb +199 -0
  137. data/test/test_gem_commands_update_command.rb +207 -0
  138. data/test/test_gem_commands_which_command.rb +66 -0
  139. data/test/test_gem_config_file.rb +287 -0
  140. data/test/test_gem_dependency.rb +149 -0
  141. data/test/test_gem_dependency_installer.rb +661 -0
  142. data/test/test_gem_dependency_list.rb +230 -0
  143. data/test/test_gem_doc_manager.rb +31 -0
  144. data/test/test_gem_ext_configure_builder.rb +84 -0
  145. data/test/test_gem_ext_ext_conf_builder.rb +173 -0
  146. data/test/test_gem_ext_rake_builder.rb +81 -0
  147. data/test/test_gem_format.rb +70 -0
  148. data/test/test_gem_gem_path_searcher.rb +78 -0
  149. data/test/test_gem_gem_runner.rb +45 -0
  150. data/test/test_gem_gemcutter_utilities.rb +103 -0
  151. data/test/test_gem_indexer.rb +673 -0
  152. data/test/test_gem_install_update_options.rb +68 -0
  153. data/test/test_gem_installer.rb +857 -0
  154. data/test/test_gem_local_remote_options.rb +97 -0
  155. data/test/test_gem_package_tar_header.rb +130 -0
  156. data/test/test_gem_package_tar_input.rb +112 -0
  157. data/test/test_gem_package_tar_output.rb +97 -0
  158. data/test/test_gem_package_tar_reader.rb +46 -0
  159. data/test/test_gem_package_tar_reader_entry.rb +109 -0
  160. data/test/test_gem_package_tar_writer.rb +144 -0
  161. data/test/test_gem_package_task.rb +59 -0
  162. data/test/test_gem_platform.rb +264 -0
  163. data/test/test_gem_remote_fetcher.rb +740 -0
  164. data/test/test_gem_requirement.rb +292 -0
  165. data/test/test_gem_server.rb +356 -0
  166. data/test/test_gem_silent_ui.rb +113 -0
  167. data/test/test_gem_source_index.rb +461 -0
  168. data/test/test_gem_spec_fetcher.rb +410 -0
  169. data/test/test_gem_specification.rb +1334 -0
  170. data/test/test_gem_stream_ui.rb +218 -0
  171. data/test/test_gem_text.rb +43 -0
  172. data/test/test_gem_uninstaller.rb +146 -0
  173. data/test/test_gem_validator.rb +63 -0
  174. data/test/test_gem_version.rb +181 -0
  175. data/test/test_gem_version_option.rb +89 -0
  176. data/test/test_kernel.rb +59 -0
  177. metadata +402 -0
@@ -0,0 +1,56 @@
1
+ require 'libgems/command'
2
+ require 'libgems/local_remote_options'
3
+ require 'libgems/gemcutter_utilities'
4
+
5
+ class LibGems::Commands::PushCommand < LibGems::Command
6
+ include LibGems::LocalRemoteOptions
7
+ include LibGems::GemcutterUtilities
8
+
9
+ def description # :nodoc:
10
+ "Push a gem up to rubygems.org"
11
+ end
12
+
13
+ def arguments # :nodoc:
14
+ "GEM built gem to push up"
15
+ end
16
+
17
+ def usage # :nodoc:
18
+ "#{program_name} GEM"
19
+ end
20
+
21
+ def initialize
22
+ super 'push', description
23
+ add_proxy_option
24
+
25
+ add_option(
26
+ '--host HOST',
27
+ 'Push to another gemcutter-compatible host'
28
+ ) do |value, options|
29
+ options[:host] = value
30
+ end
31
+ end
32
+
33
+ def execute
34
+ sign_in
35
+ send_gem get_one_gem_name
36
+ end
37
+
38
+ def send_gem name
39
+ say "Pushing gem to #{options[:host] || LibGems.host}..."
40
+
41
+ args = [:post, "api/v1/gems"]
42
+
43
+ args << options[:host] if options[:host]
44
+
45
+ response = rubygems_api_request(*args) do |request|
46
+ request.body = LibGems.read_binary name
47
+ request.add_field "Content-Length", request.body.size
48
+ request.add_field "Content-Type", "application/octet-stream"
49
+ request.add_field "Authorization", LibGems.configuration.rubygems_api_key
50
+ end
51
+
52
+ with_response response
53
+ end
54
+
55
+ end
56
+
@@ -0,0 +1,280 @@
1
+ require 'libgems/command'
2
+ require 'libgems/local_remote_options'
3
+ require 'libgems/spec_fetcher'
4
+ require 'libgems/version_option'
5
+ require 'libgems/text'
6
+
7
+ class LibGems::Commands::QueryCommand < LibGems::Command
8
+
9
+ include LibGems::Text
10
+ include LibGems::LocalRemoteOptions
11
+ include LibGems::VersionOption
12
+
13
+ def initialize(name = 'query',
14
+ summary = 'Query gem information in local or remote repositories')
15
+ super name, summary,
16
+ :name => //, :domain => :local, :details => false, :versions => true,
17
+ :installed => false, :version => LibGems::Requirement.default
18
+
19
+ add_option('-i', '--[no-]installed',
20
+ 'Check for installed gem') do |value, options|
21
+ options[:installed] = value
22
+ end
23
+
24
+ add_version_option command, "for use with --installed"
25
+
26
+ add_option('-n', '--name-matches REGEXP',
27
+ 'Name of gem(s) to query on matches the',
28
+ 'provided REGEXP') do |value, options|
29
+ options[:name] = /#{value}/i
30
+ end
31
+
32
+ add_option('-d', '--[no-]details',
33
+ 'Display detailed information of gem(s)') do |value, options|
34
+ options[:details] = value
35
+ end
36
+
37
+ add_option( '--[no-]versions',
38
+ 'Display only gem names') do |value, options|
39
+ options[:versions] = value
40
+ options[:details] = false unless value
41
+ end
42
+
43
+ add_option('-a', '--all',
44
+ 'Display all gem versions') do |value, options|
45
+ options[:all] = value
46
+ end
47
+
48
+ add_option( '--[no-]prerelease',
49
+ 'Display prerelease versions') do |value, options|
50
+ options[:prerelease] = value
51
+ end
52
+
53
+ add_local_remote_options
54
+ end
55
+
56
+ def defaults_str # :nodoc:
57
+ "--local --name-matches // --no-details --versions --no-installed"
58
+ end
59
+
60
+ def execute
61
+ exit_code = 0
62
+
63
+ name = options[:name]
64
+ prerelease = options[:prerelease]
65
+
66
+ if options[:installed] then
67
+ if name.source.empty? then
68
+ alert_error "You must specify a gem name"
69
+ exit_code |= 4
70
+ elsif installed? name, options[:version] then
71
+ say "true"
72
+ else
73
+ say "false"
74
+ exit_code |= 1
75
+ end
76
+
77
+ raise LibGems::SystemExitException, exit_code
78
+ end
79
+
80
+ dep = LibGems::Dependency.new name, LibGems::Requirement.default
81
+
82
+ if local? then
83
+ if prerelease and not both? then
84
+ alert_warning "prereleases are always shown locally"
85
+ end
86
+
87
+ if ui.outs.tty? or both? then
88
+ say
89
+ say "*** LOCAL GEMS ***"
90
+ say
91
+ end
92
+
93
+ specs = LibGems.source_index.search dep
94
+
95
+ spec_tuples = specs.map do |spec|
96
+ [[spec.name, spec.version, spec.original_platform, spec], :local]
97
+ end
98
+
99
+ output_query_results spec_tuples
100
+ end
101
+
102
+ if remote? then
103
+ if ui.outs.tty? or both? then
104
+ say
105
+ say "*** REMOTE GEMS ***"
106
+ say
107
+ end
108
+
109
+ all = options[:all]
110
+
111
+ begin
112
+ fetcher = LibGems::SpecFetcher.fetcher
113
+ spec_tuples = fetcher.find_matching dep, all, false, prerelease
114
+
115
+ spec_tuples += fetcher.find_matching dep, false, false, true if
116
+ prerelease and all
117
+ rescue LibGems::RemoteFetcher::FetchError => e
118
+ if prerelease then
119
+ raise LibGems::OperationNotSupportedError,
120
+ "Prereleases not supported on legacy repositories"
121
+ end
122
+
123
+ raise unless fetcher.warn_legacy e do
124
+ require 'libgems/source_info_cache'
125
+
126
+ dep.name = '' if dep.name == //
127
+
128
+ specs = LibGems::SourceInfoCache.search_with_source dep, false, all
129
+
130
+ spec_tuples = specs.map do |spec, source_uri|
131
+ [[spec.name, spec.version, spec.original_platform, spec],
132
+ source_uri]
133
+ end
134
+ end
135
+ end
136
+
137
+ output_query_results spec_tuples
138
+ end
139
+ end
140
+
141
+ private
142
+
143
+ ##
144
+ # Check if gem +name+ version +version+ is installed.
145
+
146
+ def installed?(name, version = LibGems::Requirement.default)
147
+ dep = LibGems::Dependency.new name, version
148
+ !LibGems.source_index.search(dep).empty?
149
+ end
150
+
151
+ def output_query_results(spec_tuples)
152
+ output = []
153
+ versions = Hash.new { |h,name| h[name] = [] }
154
+
155
+ spec_tuples.each do |spec_tuple, source_uri|
156
+ versions[spec_tuple.first] << [spec_tuple, source_uri]
157
+ end
158
+
159
+ versions = versions.sort_by do |(name,_),_|
160
+ name.downcase
161
+ end
162
+
163
+ versions.each do |gem_name, matching_tuples|
164
+ matching_tuples = matching_tuples.sort_by do |(_, version,_),_|
165
+ version
166
+ end.reverse
167
+
168
+ platforms = Hash.new { |h,version| h[version] = [] }
169
+
170
+ matching_tuples.map do |(_, version, platform,_),_|
171
+ platforms[version] << platform if platform
172
+ end
173
+
174
+ seen = {}
175
+
176
+ matching_tuples.delete_if do |(_, version,_),_|
177
+ if seen[version] then
178
+ true
179
+ else
180
+ seen[version] = true
181
+ false
182
+ end
183
+ end
184
+
185
+ entry = gem_name.dup
186
+
187
+ if options[:versions] then
188
+ list = if platforms.empty? or options[:details] then
189
+ matching_tuples.map { |(_, version,_),_| version }.uniq
190
+ else
191
+ platforms.sort.reverse.map do |version, pls|
192
+ if pls == [LibGems::Platform::RUBY] then
193
+ version
194
+ else
195
+ ruby = pls.delete LibGems::Platform::RUBY
196
+ platform_list = [ruby, *pls.sort].compact
197
+ "#{version} #{platform_list.join ' '}"
198
+ end
199
+ end
200
+ end.join ', '
201
+
202
+ entry << " (#{list})"
203
+ end
204
+
205
+ if options[:details] then
206
+ detail_tuple = matching_tuples.first
207
+
208
+ spec = if detail_tuple.first.length == 4 then
209
+ detail_tuple.first.last
210
+ else
211
+ uri = URI.parse detail_tuple.last
212
+ LibGems::SpecFetcher.fetcher.fetch_spec detail_tuple.first, uri
213
+ end
214
+
215
+ entry << "\n"
216
+
217
+ non_ruby = platforms.any? do |_, pls|
218
+ pls.any? { |pl| pl != LibGems::Platform::RUBY }
219
+ end
220
+
221
+ if non_ruby then
222
+ if platforms.length == 1 then
223
+ title = platforms.values.length == 1 ? 'Platform' : 'Platforms'
224
+ entry << " #{title}: #{platforms.values.sort.join ', '}\n"
225
+ else
226
+ entry << " Platforms:\n"
227
+ platforms.sort_by do |version,|
228
+ version
229
+ end.each do |version, pls|
230
+ label = " #{version}: "
231
+ data = format_text pls.sort.join(', '), 68, label.length
232
+ data[0, label.length] = label
233
+ entry << data << "\n"
234
+ end
235
+ end
236
+ end
237
+
238
+ authors = "Author#{spec.authors.length > 1 ? 's' : ''}: "
239
+ authors << spec.authors.join(', ')
240
+ entry << format_text(authors, 68, 4)
241
+
242
+ if spec.rubyforge_project and not spec.rubyforge_project.empty? then
243
+ rubyforge = "Rubyforge: http://rubyforge.org/projects/#{spec.rubyforge_project}"
244
+ entry << "\n" << format_text(rubyforge, 68, 4)
245
+ end
246
+
247
+ if spec.homepage and not spec.homepage.empty? then
248
+ entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4)
249
+ end
250
+
251
+ if spec.license and not spec.license.empty? then
252
+ licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: "
253
+ licenses << spec.licenses.join(', ')
254
+ entry << "\n" << format_text(licenses, 68, 4)
255
+ end
256
+
257
+ if spec.loaded_from then
258
+ if matching_tuples.length == 1 then
259
+ loaded_from = File.dirname File.dirname(spec.loaded_from)
260
+ entry << "\n" << " Installed at: #{loaded_from}"
261
+ else
262
+ label = 'Installed at'
263
+ matching_tuples.each do |(_,version,_,s),|
264
+ loaded_from = File.dirname File.dirname(s.loaded_from)
265
+ entry << "\n" << " #{label} (#{version}): #{loaded_from}"
266
+ label = ' ' * label.length
267
+ end
268
+ end
269
+ end
270
+
271
+ entry << "\n\n" << format_text(spec.summary, 68, 4)
272
+ end
273
+ output << entry
274
+ end
275
+
276
+ say output.join(options[:details] ? "\n\n" : "\n")
277
+ end
278
+
279
+ end
280
+
@@ -0,0 +1,91 @@
1
+ require 'libgems/command'
2
+ require 'libgems/version_option'
3
+ require 'libgems/doc_manager'
4
+
5
+ class LibGems::Commands::RdocCommand < LibGems::Command
6
+ include LibGems::VersionOption
7
+
8
+ def initialize
9
+ super 'rdoc', 'Generates RDoc for pre-installed gems',
10
+ :version => LibGems::Requirement.default,
11
+ :include_rdoc => true, :include_ri => true, :overwrite => false
12
+
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
+ 'Generate RDoc HTML') do |value, options|
21
+ options[:include_rdoc] = value
22
+ end
23
+
24
+ add_option('--[no-]ri',
25
+ 'Generate RI data') do |value, options|
26
+ options[:include_ri] = value
27
+ end
28
+
29
+ add_option('--[no-]overwrite',
30
+ 'Overwrite installed documents') do |value, options|
31
+ options[:overwrite] = value
32
+ end
33
+
34
+ add_version_option
35
+ end
36
+
37
+ def arguments # :nodoc:
38
+ "GEMNAME gem to generate documentation for (unless --all)"
39
+ end
40
+
41
+ def defaults_str # :nodoc:
42
+ "--version '#{LibGems::Requirement.default}' --rdoc --ri --no-overwrite"
43
+ end
44
+
45
+ def description # :nodoc:
46
+ <<-DESC
47
+ The rdoc command builds RDoc and RI documentation for installed gems. Use
48
+ --overwrite to force rebuilding of documentation.
49
+ DESC
50
+ end
51
+
52
+ def usage # :nodoc:
53
+ "#{program_name} [args]"
54
+ end
55
+
56
+ def execute
57
+ if options[:all] then
58
+ specs = LibGems::SourceIndex.from_installed_gems.collect { |name, spec|
59
+ spec
60
+ }
61
+ else
62
+ gem_name = get_one_gem_name
63
+ dep = LibGems::Dependency.new gem_name, options[:version]
64
+ specs = LibGems::SourceIndex.from_installed_gems.search dep
65
+ end
66
+
67
+ if specs.empty?
68
+ raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
69
+ end
70
+
71
+ if options[:include_ri]
72
+ specs.sort.each do |spec|
73
+ doc = LibGems::DocManager.new(spec)
74
+ doc.generate_ri if options[:overwrite] || !doc.ri_installed?
75
+ end
76
+
77
+ LibGems::DocManager.update_ri_cache
78
+ end
79
+
80
+ if options[:include_rdoc]
81
+ specs.sort.each do |spec|
82
+ doc = LibGems::DocManager.new(spec)
83
+ doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed?
84
+ end
85
+ end
86
+
87
+ true
88
+ end
89
+
90
+ end
91
+
@@ -0,0 +1,31 @@
1
+ require 'libgems/command'
2
+ require 'libgems/commands/query_command'
3
+
4
+ class LibGems::Commands::SearchCommand < LibGems::Commands::QueryCommand
5
+
6
+ def initialize
7
+ super 'search', 'Display all gems whose name contains STRING'
8
+
9
+ remove_option '--name-matches'
10
+ end
11
+
12
+ def arguments # :nodoc:
13
+ "STRING fragment of gem name to search for"
14
+ end
15
+
16
+ def defaults_str # :nodoc:
17
+ "--local --no-details"
18
+ end
19
+
20
+ def usage # :nodoc:
21
+ "#{program_name} [STRING]"
22
+ end
23
+
24
+ def execute
25
+ string = get_one_optional_argument
26
+ options[:name] = /#{string}/i
27
+ super
28
+ end
29
+
30
+ end
31
+