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.

Files changed (225) hide show
  1. data/ChangeLog +587 -0
  2. data/README +0 -1
  3. data/Rakefile +39 -12
  4. data/TODO +0 -5
  5. data/bin/gem +7 -7
  6. data/bin/update_rubygems +1 -1
  7. data/examples/application/an-app.gemspec +1 -1
  8. data/gemspecs/cgikit-1.1.0.gemspec +1 -2
  9. data/gemspecs/jabber4r.gemspec +1 -1
  10. data/gemspecs/linguistics.gemspec +1 -1
  11. data/gemspecs/ook.gemspec +1 -1
  12. data/gemspecs/progressbar.gemspec +1 -1
  13. data/gemspecs/redcloth.gemspec +1 -1
  14. data/gemspecs/rublog.gemspec +1 -1
  15. data/gemspecs/ruby-doom.gemspec +1 -1
  16. data/gemspecs/rubyjdwp.gemspec +1 -1
  17. data/gemspecs/statistics.gemspec +1 -1
  18. data/lib/rubygems.rb +167 -105
  19. data/lib/rubygems/builder.rb +12 -10
  20. data/lib/rubygems/command.rb +177 -60
  21. data/lib/rubygems/command_manager.rb +30 -38
  22. data/lib/rubygems/commands/build_command.rb +42 -46
  23. data/lib/rubygems/commands/cert_command.rb +72 -69
  24. data/lib/rubygems/commands/check_command.rb +63 -63
  25. data/lib/rubygems/commands/cleanup_command.rb +25 -7
  26. data/lib/rubygems/commands/contents_command.rb +70 -62
  27. data/lib/rubygems/commands/dependency_command.rb +131 -86
  28. data/lib/rubygems/commands/environment_command.rb +67 -46
  29. data/lib/rubygems/commands/fetch_command.rb +62 -0
  30. data/lib/rubygems/commands/generate_index_command.rb +57 -0
  31. data/lib/rubygems/commands/help_command.rb +163 -73
  32. data/lib/rubygems/commands/install_command.rb +114 -128
  33. data/lib/rubygems/commands/list_command.rb +10 -8
  34. data/lib/rubygems/commands/lock_command.rb +101 -0
  35. data/lib/rubygems/commands/mirror_command.rb +105 -0
  36. data/lib/rubygems/commands/outdated_command.rb +24 -15
  37. data/lib/rubygems/commands/pristine_command.rb +118 -88
  38. data/lib/rubygems/commands/query_command.rb +109 -77
  39. data/lib/rubygems/commands/rdoc_command.rb +13 -10
  40. data/lib/rubygems/commands/search_command.rb +10 -8
  41. data/lib/rubygems/commands/server_command.rb +48 -0
  42. data/lib/rubygems/commands/sources_command.rb +104 -83
  43. data/lib/rubygems/commands/specification_command.rb +65 -51
  44. data/lib/rubygems/commands/uninstall_command.rb +17 -12
  45. data/lib/rubygems/commands/unpack_command.rb +68 -68
  46. data/lib/rubygems/commands/update_command.rb +72 -25
  47. data/lib/rubygems/commands/which_command.rb +86 -0
  48. data/lib/rubygems/config_file.rb +202 -78
  49. data/lib/rubygems/custom_require.rb +7 -88
  50. data/lib/rubygems/dependency.rb +65 -0
  51. data/lib/rubygems/dependency_installer.rb +232 -0
  52. data/lib/rubygems/dependency_list.rb +133 -105
  53. data/lib/rubygems/digest/md5.rb +4 -1
  54. data/lib/rubygems/digest/sha2.rb +1 -1
  55. data/lib/rubygems/doc_manager.rb +41 -19
  56. data/lib/rubygems/exceptions.rb +63 -0
  57. data/lib/rubygems/ext.rb +18 -0
  58. data/lib/rubygems/ext/builder.rb +56 -0
  59. data/lib/rubygems/ext/configure_builder.rb +24 -0
  60. data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
  61. data/lib/rubygems/ext/rake_builder.rb +27 -0
  62. data/lib/rubygems/format.rb +16 -6
  63. data/lib/rubygems/gem_openssl.rb +43 -6
  64. data/lib/rubygems/gem_path_searcher.rb +84 -0
  65. data/lib/rubygems/gem_runner.rb +20 -5
  66. data/lib/rubygems/indexer.rb +163 -0
  67. data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
  68. data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
  69. data/lib/rubygems/indexer/master_index_builder.rb +53 -0
  70. data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
  71. data/lib/rubygems/install_update_options.rb +87 -0
  72. data/lib/rubygems/installer.rb +316 -562
  73. data/lib/rubygems/local_remote_options.rb +106 -0
  74. data/lib/rubygems/old_format.rb +5 -13
  75. data/lib/rubygems/open-uri.rb +2 -0
  76. data/lib/rubygems/package.rb +28 -32
  77. data/lib/rubygems/platform.rb +187 -0
  78. data/lib/rubygems/remote_fetcher.rb +46 -29
  79. data/lib/rubygems/remote_installer.rb +11 -18
  80. data/lib/rubygems/requirement.rb +157 -0
  81. data/lib/rubygems/rubygems_version.rb +1 -1
  82. data/lib/rubygems/security.rb +715 -457
  83. data/lib/rubygems/server.rb +77 -59
  84. data/lib/rubygems/source_index.rb +154 -83
  85. data/lib/rubygems/source_info_cache.rb +73 -30
  86. data/lib/rubygems/source_info_cache_entry.rb +12 -3
  87. data/lib/rubygems/specification.rb +378 -145
  88. data/lib/rubygems/uninstaller.rb +183 -0
  89. data/lib/rubygems/user_interaction.rb +38 -9
  90. data/lib/rubygems/validator.rb +53 -24
  91. data/lib/rubygems/version.rb +126 -289
  92. data/lib/rubygems/version_option.rb +49 -0
  93. data/pkgs/sources/lib/sources.rb +1 -4
  94. data/pkgs/sources/sources.gemspec +3 -3
  95. data/scripts/gemdoc.rb +0 -1
  96. data/setup.rb +166 -1505
  97. data/test/bogussources.rb +0 -1
  98. data/test/data/gem-private_key.pem +27 -0
  99. data/test/data/gem-public_cert.pem +20 -0
  100. data/test/functional.rb +3 -105
  101. data/test/gemutilities.rb +145 -24
  102. data/test/insure_session.rb +0 -1
  103. data/test/{test_datadir.rb → test_config.rb} +7 -13
  104. data/test/test_gem.rb +360 -9
  105. data/test/test_gem_builder.rb +34 -0
  106. data/test/{test_command.rb → test_gem_command.rb} +119 -62
  107. data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
  108. data/test/test_gem_commands_build_command.rb +75 -0
  109. data/test/test_gem_commands_cert_command.rb +122 -0
  110. data/test/test_gem_commands_check_command.rb +25 -0
  111. data/test/test_gem_commands_contents_command.rb +92 -0
  112. data/test/test_gem_commands_dependency_command.rb +108 -0
  113. data/test/test_gem_commands_environment_command.rb +117 -0
  114. data/test/test_gem_commands_fetch_command.rb +34 -0
  115. data/test/test_gem_commands_generate_index_command.rb +32 -0
  116. data/test/test_gem_commands_install_command.rb +160 -0
  117. data/test/test_gem_commands_mirror_command.rb +56 -0
  118. data/test/test_gem_commands_pristine_command.rb +100 -0
  119. data/test/test_gem_commands_query_command.rb +82 -0
  120. data/test/test_gem_commands_sources_command.rb +147 -0
  121. data/test/test_gem_commands_specification_command.rb +93 -0
  122. data/test/test_gem_commands_unpack_command.rb +55 -0
  123. data/test/test_gem_config_file.rb +210 -0
  124. data/test/test_gem_dependency.rb +89 -0
  125. data/test/test_gem_dependency_installer.rb +542 -0
  126. data/test/test_gem_dependency_list.rb +212 -0
  127. data/test/test_gem_doc_manager.rb +32 -0
  128. data/test/test_gem_ext_configure_builder.rb +13 -17
  129. data/test/test_gem_ext_ext_conf_builder.rb +9 -9
  130. data/test/test_gem_ext_rake_builder.rb +23 -11
  131. data/test/test_gem_format.rb +69 -0
  132. data/test/test_gem_gem_path_searcher.rb +57 -0
  133. data/test/test_gem_gem_runner.rb +35 -0
  134. data/test/test_gem_indexer.rb +119 -0
  135. data/test/test_gem_install_update_options.rb +40 -0
  136. data/test/test_gem_installer.rb +796 -0
  137. data/test/test_gem_local_remote_options.rb +84 -0
  138. data/test/test_gem_outdated_command.rb +11 -9
  139. data/test/test_gem_platform.rb +240 -0
  140. data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
  141. data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
  142. data/test/test_gem_requirement.rb +223 -0
  143. data/test/test_gem_server.rb +71 -0
  144. data/test/test_gem_source_index.rb +429 -0
  145. data/test/test_gem_source_info_cache.rb +79 -17
  146. data/test/test_gem_source_info_cache_entry.rb +11 -9
  147. data/test/test_gem_specification.rb +738 -0
  148. data/test/test_gem_stream_ui.rb +117 -0
  149. data/test/test_gem_validator.rb +70 -0
  150. data/test/test_gem_version.rb +191 -0
  151. data/test/test_gem_version_option.rb +77 -0
  152. data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
  153. data/test/test_open_uri.rb +1 -2
  154. data/test/test_package.rb +45 -34
  155. metadata +116 -141
  156. data/Releases +0 -127
  157. data/bin/gem_mirror +0 -73
  158. data/bin/gem_server +0 -6
  159. data/bin/gemlock +0 -127
  160. data/bin/gemri +0 -24
  161. data/bin/gemwhich +0 -89
  162. data/bin/index_gem_repository.rb +0 -302
  163. data/lib/gemconfigure.rb +0 -24
  164. data/lib/rubygems/gem_commands.rb +0 -273
  165. data/pkgs/sources/sources-0.0.1.gem +0 -0
  166. data/post-install.rb +0 -121
  167. data/test/brokenbuildgem.rb +0 -35
  168. data/test/data/PostMessage-0.0.1.gem +0 -0
  169. data/test/data/a-0.0.1.gem +0 -0
  170. data/test/data/a-0.0.2.gem +0 -0
  171. data/test/data/b-0.0.2.gem +0 -0
  172. data/test/data/broken-1.0.0.gem +0 -0
  173. data/test/data/broken_build/broken-build.gemspec +0 -20
  174. data/test/data/broken_build/ext/extconf.rb +0 -3
  175. data/test/data/broken_build/ext/foo.c +0 -1
  176. data/test/data/c-1.2.gem +0 -0
  177. data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
  178. data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
  179. data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
  180. data/test/data/gemhome/cache/c-1.2.gem +0 -0
  181. data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
  182. data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
  183. data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
  184. data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
  185. data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
  186. data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
  187. data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
  188. data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
  189. data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
  190. data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
  191. data/test/data/lib/code.rb +0 -1
  192. data/test/data/one/README.one +0 -1
  193. data/test/data/one/lib/one.rb +0 -9
  194. data/test/data/one/one-0.0.1.gem +0 -0
  195. data/test/data/one/one.gemspec +0 -17
  196. data/test/data/one/one.yaml +0 -40
  197. data/test/data/post_install.gemspec +0 -19
  198. data/test/functional_extension_gems.rb +0 -48
  199. data/test/functional_generate_yaml_index.rb +0 -104
  200. data/test/gemenvironment.rb +0 -59
  201. data/test/io_capture.rb +0 -33
  202. data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
  203. data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
  204. data/test/onegem.rb +0 -35
  205. data/test/test_builder.rb +0 -34
  206. data/test/test_check_command.rb +0 -34
  207. data/test/test_configfile.rb +0 -42
  208. data/test/test_dependency_list.rb +0 -169
  209. data/test/test_file_list.rb +0 -101
  210. data/test/test_format.rb +0 -49
  211. data/test/test_gem_sources_command.rb +0 -135
  212. data/test/test_gemloadpaths.rb +0 -51
  213. data/test/test_gempaths.rb +0 -170
  214. data/test/test_installer.rb +0 -369
  215. data/test/test_loadmanager.rb +0 -48
  216. data/test/test_process_commands.rb +0 -52
  217. data/test/test_source_index.rb +0 -231
  218. data/test/test_specific_extras.rb +0 -46
  219. data/test/test_specification.rb +0 -565
  220. data/test/test_user_interaction.rb +0 -48
  221. data/test/test_validator.rb +0 -59
  222. data/test/test_version_comparison.rb +0 -321
  223. data/test/testgem.rc +0 -7
  224. data/test/user_capture.rb +0 -7
  225. data/test/yaml_data.rb +0 -63
@@ -1,302 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
-
9
- # Generate the yaml/yaml.Z index files for a gem server directory.
10
- #
11
- # Usage: generate_yaml_index.rb --dir DIR [--verbose]
12
-
13
- $:.unshift '~/rubygems' if File.exist? "~/rubygems"
14
-
15
- require 'optparse'
16
- require 'rubygems'
17
- require 'zlib'
18
- require 'digest/sha2'
19
- begin
20
- require 'builder/xchar'
21
- rescue LoadError
22
- fail "index_gem_repository requires that the XML Builder library be installed"
23
- end
24
-
25
- Gem.manage_gems
26
-
27
- ######################################################################
28
- # Mixin that provides a +compress+ method for compressing files on
29
- # disk.
30
- #
31
- module Compressor
32
- # Compress the given file.
33
- def compress(filename, ext="rz")
34
- File.open(filename + ".#{ext}", "w") do |file|
35
- file.write(zip(File.read(filename)))
36
- end
37
- end
38
-
39
- # Return a compressed version of the given string.
40
- def zip(string)
41
- Zlib::Deflate.deflate(string)
42
- end
43
-
44
- # Return an uncompressed version of a compressed string.
45
- def unzip(string)
46
- Zlib::Inflate.inflate(string)
47
- end
48
- end
49
-
50
- ######################################################################
51
- # Announcer provides a way of announcing activities to the user.
52
- #
53
- module Announcer
54
- # Announce +msg+ to the user.
55
- def announce(msg)
56
- puts msg if @options[:verbose]
57
- end
58
- end
59
-
60
- ######################################################################
61
- # Abstract base class for building gem indicies. Uses the template
62
- # pattern with subclass specialization in the +begin_index+,
63
- # +end_index+ and +cleanup+ methods.
64
- #
65
- class AbstractIndexBuilder
66
- include Compressor
67
- include Announcer
68
-
69
- # Build a Gem index. Yields to block to handle the details of the
70
- # actual building. Calls +begin_index+, # +end_index+ and +cleanup+
71
- # at appropriate times to customize basic operations.
72
- def build
73
- if ! @enabled
74
- yield
75
- else
76
- unless File.exist?(@directory)
77
- FileUtils.mkdir_p(@directory)
78
- end
79
- fail "not a directory: #{@directory}" unless File.directory?(@directory)
80
- File.open(File.join(@directory, @filename), "w") do |file|
81
- @file = file
82
- start_index
83
- yield
84
- end_index
85
- end
86
- cleanup
87
- end
88
- ensure
89
- @file = nil
90
- end
91
-
92
- # Called immediately before the yield in build. The index file is
93
- # open and availabe as @file.
94
- def start_index
95
- end
96
-
97
- # Called immediately after the yield in build. The index file is
98
- # still open and available as @file.
99
- def end_index
100
- end
101
-
102
- # Called from within builder after the index file has been closed.
103
- def cleanup
104
- end
105
- end
106
-
107
- ######################################################################
108
- # Construct the master Gem index file.
109
- #
110
- class MasterIndexBuilder < AbstractIndexBuilder
111
- def initialize(filename, options)
112
- @filename = filename
113
- @options = options
114
- @directory = options[:directory]
115
- @enabled = true
116
- end
117
-
118
- def start_index
119
- super
120
- @file.puts "--- !ruby/object:Gem::Cache"
121
- @file.puts "gems:"
122
- end
123
-
124
- def cleanup
125
- super
126
- index_file_name = File.join(@directory, @filename)
127
- compress(index_file_name, "Z")
128
- paranoid(index_file_name, "#{index_file_name}.Z")
129
- end
130
-
131
- def add(spec)
132
- @file.puts " #{spec.full_name}: #{nest(spec.to_yaml)}"
133
- end
134
-
135
- def nest(yaml_string)
136
- yaml_string[4..-1].gsub(/\n/, "\n ")
137
- end
138
-
139
- private
140
-
141
- def paranoid(fn, compressed_fn)
142
- data = File.read(fn)
143
- compressed_data = File.read(compressed_fn)
144
- if data != unzip(compressed_data)
145
- fail "Compressed file #{compressed_fn} does not match uncompressed file #{fn}"
146
- end
147
- end
148
- end
149
-
150
- ######################################################################
151
- # Construct a quick index file and all of the individual specs to
152
- # support incremental loading.
153
- #
154
- class QuickIndexBuilder < AbstractIndexBuilder
155
- def initialize(filename, options)
156
- @filename = filename
157
- @options = options
158
- @directory = options[:quick_directory]
159
- @enabled = options[:quick]
160
- end
161
-
162
- def cleanup
163
- compress(File.join(@directory, @filename))
164
- end
165
-
166
- def add(spec)
167
- return unless @enabled
168
- @file.puts spec.full_name
169
- fn = File.join(@directory, "#{spec.full_name}.gemspec.rz")
170
- File.open(fn, "w") do |gsfile|
171
- gsfile.write(zip(spec.to_yaml))
172
- end
173
- end
174
- end
175
-
176
- ######################################################################
177
- # Top level class for building the repository index. Initialize with
178
- # an options hash and call +build_index+.
179
- #
180
- class Indexer
181
- include Compressor
182
- include Announcer
183
-
184
- # Create an indexer with the options specified by the options hash.
185
- def initialize(options)
186
- @options = options.dup
187
- @directory = @options[:directory]
188
- @options[:quick_directory] = File.join(@directory, "quick")
189
- @master_index = MasterIndexBuilder.new("yaml", @options)
190
- @quick_index = QuickIndexBuilder.new("index", @options)
191
- end
192
-
193
- # Build the index.
194
- def build_index
195
- announce "Building Server Index"
196
- FileUtils.rm_r(@options[:quick_directory]) rescue nil
197
- @master_index.build do
198
- @quick_index.build do
199
- gem_file_list.each do |gemfile|
200
- spec = Gem::Format.from_file_by_path(gemfile).spec
201
- abbreviate(spec)
202
- sanitize(spec)
203
- announce " ... adding #{spec.full_name}"
204
- @master_index.add(spec)
205
- @quick_index.add(spec)
206
- end
207
- end
208
- end
209
- end
210
-
211
- # List of gem file names to index.
212
- def gem_file_list
213
- Dir.glob(File.join(@directory, "gems", "*.gem"))
214
- end
215
-
216
- # Abbreviate the spec for downloading. Abbreviated specs are only
217
- # used for searching, downloading and related activities and do not
218
- # need deployment specific information (e.g. list of files). So we
219
- # abbreviate the spec, making it much smaller for quicker downloads.
220
- def abbreviate(spec)
221
- spec.files = []
222
- spec.test_files = []
223
- spec.rdoc_options = []
224
- spec.extra_rdoc_files = []
225
- spec.cert_chain = []
226
- spec
227
- end
228
-
229
- # Sanitize the descriptive fields in the spec. Sometimes non-ASCII
230
- # characters will garble the site index. Non-ASCII characters will
231
- # be replaced by their XML entity equivalent.
232
- def sanitize(spec)
233
- spec.summary = sanitize_string(spec.summary)
234
- spec.description = sanitize_string(spec.description)
235
- spec.post_install_message = sanitize_string(spec.post_install_message)
236
- spec.authors = spec.authors.collect { |a| sanitize_string(a) }
237
- spec
238
- end
239
-
240
- # Sanitize a single string.
241
- def sanitize_string(string)
242
- string ? string.to_xs : string
243
- end
244
- end
245
-
246
- ######################################################################
247
- # Top Level Functions
248
- ######################################################################
249
-
250
- def handle_options(args)
251
- # default options
252
- options = {
253
- :directory => '.',
254
- :verbose => false,
255
- :quick => true,
256
- }
257
-
258
- args.options do |opts|
259
- opts.on_tail("--help", "show this message") do
260
- puts opts
261
- exit
262
- end
263
- opts.on(
264
- '-d', '--dir=DIRNAME', '--directory=DIRNAME',
265
- "repository base dir containing gems subdir",
266
- String) do |value|
267
- options[:directory] = value
268
- end
269
- opts.on('--[no-]quick', "include quick index") do |value|
270
- options[:quick] = value
271
- end
272
- opts.on('-v', '--verbose', "show verbose output") do |value|
273
- options[:verbose] = value
274
- end
275
- opts.on('-V', '--version',
276
- "show version") do |value|
277
- puts Gem::RubyGemsVersion
278
- exit
279
- end
280
- opts.parse!
281
- end
282
-
283
- if options[:directory].nil?
284
- puts "Error, must specify directory name. Use --help"
285
- exit
286
- elsif ! File.exist?(options[:directory]) ||
287
- ! File.directory?(options[:directory])
288
- puts "Error, unknown directory name #{directory}."
289
- exit
290
- end
291
- options
292
- end
293
-
294
- # Main program.
295
- def main_index(args)
296
- options = handle_options(args)
297
- Indexer.new(options).build_index
298
- end
299
-
300
- if __FILE__ == $0 then
301
- main_index(ARGV)
302
- end
@@ -1,24 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- module Gem
8
-
9
- # Activate the gems specfied by the gem_pairs list.
10
- #
11
- # gem_pairs ::
12
- # List of gem/version pairs.
13
- # Eg. [['rake', '= 0.8.15'], ['RedCloth', '~> 3.0']]
14
- # options ::
15
- # options[:verbose] => print gems as they are required.
16
- #
17
- def self.configure(gem_pairs, options={})
18
- gem_pairs.each do |name, version|
19
- require 'rubygems'
20
- puts "Activating gem #{name} (version #{version})" if options[:verbose]
21
- gem name, version
22
- end
23
- end
24
- end
@@ -1,273 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
- # All rights reserved.
5
- # See LICENSE.txt for permissions.
6
- #++
7
-
8
- require 'rubygems'
9
- require 'rubygems/command'
10
-
11
- module Gem
12
-
13
- class CommandLineError < Gem::Exception; end
14
- module Commands; end # This is where Commands will be placed in the namespace
15
-
16
- ####################################################################
17
- # The following mixin methods aid in the retrieving of information
18
- # from the command line.
19
- #
20
- module CommandAids
21
-
22
- # Get the single gem name from the command line. Fail if there is
23
- # no gem name or if there is more than one gem name given.
24
- def get_one_gem_name
25
- args = options[:args]
26
- if args.nil? or args.empty?
27
- fail Gem::CommandLineError,
28
- "Please specify a gem name on the command line (e.g. gem build GEMNAME)"
29
- end
30
- if args.size > 1
31
- fail Gem::CommandLineError,
32
- "Too many gem names (#{args.join(', ')}); please specify only one"
33
- end
34
- args.first
35
- end
36
-
37
- # Get all gem names from the command line.
38
- def get_all_gem_names
39
- args = options[:args]
40
- if args.nil? or args.empty?
41
- raise Gem::CommandLineError,
42
- "Please specify at least one gem name (e.g. gem build GEMNAME)"
43
- end
44
- gem_names = args.select { |arg| arg !~ /^-/ }
45
- end
46
-
47
- # Get a single optional argument from the command line. If more
48
- # than one argument is given, return only the first. Return nil if
49
- # none are given.
50
- def get_one_optional_argument
51
- args = options[:args] || []
52
- args.first
53
- end
54
-
55
- # True if +long+ begins with the characters from +short+.
56
- def begins?(long, short)
57
- return false if short.nil?
58
- long[0, short.length] == short
59
- end
60
- end
61
-
62
- ####################################################################
63
- # Mixin methods for handling the local/remote command line options.
64
- #
65
- module LocalRemoteOptions
66
-
67
- # Add the local/remote options to the command line parser.
68
- def add_local_remote_options
69
- add_option('-l', '--local',
70
- 'Restrict operations to the LOCAL domain'
71
- ) do |value, options|
72
- options[:domain] = :local
73
- end
74
-
75
- add_option('-r', '--remote',
76
- 'Restrict operations to the REMOTE domain') do
77
- |value, options|
78
- options[:domain] = :remote
79
- end
80
-
81
- add_option('-b', '--both',
82
- 'Allow LOCAL and REMOTE operations') do
83
- |value, options|
84
- options[:domain] = :both
85
- end
86
- end
87
-
88
- # Is local fetching enabled?
89
- def local?
90
- options[:domain] == :local || options[:domain] == :both
91
- end
92
-
93
- # Is remote fetching enabled?
94
- def remote?
95
- options[:domain] == :remote || options[:domain] == :both
96
- end
97
- end
98
-
99
- ####################################################################
100
- # Mixin methods and OptionParser options specific to the gem install
101
- # command.
102
- #
103
- module InstallUpdateOptions
104
-
105
- # Add the install/update options to the option parser.
106
- def add_install_update_options
107
- add_option('-i', '--install-dir DIR',
108
- 'Gem repository directory to get installed',
109
- 'gems.') do |value, options|
110
- options[:install_dir] = File.expand_path(value)
111
- end
112
-
113
- add_option('-d', '--[no-]rdoc',
114
- 'Generate RDoc documentation for the gem on',
115
- 'install') do |value, options|
116
- options[:generate_rdoc] = value
117
- end
118
-
119
- add_option('--[no-]ri',
120
- 'Generate RI documentation for the gem on',
121
- 'install') do |value, options|
122
- options[:generate_ri] = value
123
- end
124
-
125
- add_option('-E', '--env-shebang',
126
- "Rewrite the shebang line on installed",
127
- "scripts to use /usr/bin/env") do |value, options|
128
- options[:env_shebang] = value
129
- end
130
-
131
- add_option('-f', '--[no-]force',
132
- 'Force gem to install, bypassing dependency',
133
- 'checks') do |value, options|
134
- options[:force] = value
135
- end
136
-
137
- add_option('-t', '--[no-]test',
138
- 'Run unit tests prior to installation') do
139
- |value, options|
140
- options[:test] = value
141
- end
142
-
143
- add_option('-w', '--[no-]wrappers',
144
- 'Use bin wrappers for executables',
145
- 'Not available on dosish platforms') do
146
- |value, options|
147
- options[:wrappers] = value
148
- end
149
-
150
- add_option('-P', '--trust-policy POLICY',
151
- 'Specify gem trust policy.') do
152
- |value, options|
153
- options[:security_policy] = value
154
- end
155
-
156
- add_option('--ignore-dependencies',
157
- 'Do not install any required dependent gems') do
158
- |value, options|
159
- options[:ignore_dependencies] = value
160
- end
161
-
162
- add_option('-y', '--include-dependencies',
163
- 'Unconditionally install the required',
164
- 'dependent gems') do |value, options|
165
- options[:include_dependencies] = value
166
- end
167
- end
168
-
169
- # Default options for the gem install command.
170
- def install_update_defaults_str
171
- '--rdoc --no-force --no-test --wrappers'
172
- end
173
- end
174
-
175
- ####################################################################
176
- # Mixin methods for the version command.
177
- #
178
- module VersionOption
179
-
180
- # Add the options to the option parser.
181
- def add_version_option(taskname, *wrap)
182
- add_option('-v', '--version VERSION',
183
- "Specify version of gem to #{taskname}", *wrap) do
184
- |value, options|
185
- options[:version] = value
186
- end
187
- end
188
-
189
- end
190
- def self.load_commands(*command_names)
191
- command_names.each{|name|
192
- require "rubygems/commands/#{name}_command"
193
- }
194
- end
195
- end
196
-
197
- ######################################################################
198
- # Documentation Constants
199
- #
200
- module Gem
201
-
202
- HELP = %{
203
- RubyGems is a sophisticated package manager for Ruby. This is a
204
- basic help message containing pointers to more information.
205
-
206
- Usage:
207
- gem -h/--help
208
- gem -v/--version
209
- gem command [arguments...] [options...]
210
-
211
- Examples:
212
- gem install rake
213
- gem list --local
214
- gem build package.gemspec
215
- gem help install
216
-
217
- Further help:
218
- gem help commands list all 'gem' commands
219
- gem help examples show some examples of usage
220
- gem help <COMMAND> show help on COMMAND
221
- (e.g. 'gem help install')
222
- Further information:
223
- http://rubygems.rubyforge.org
224
- }.gsub(/^ /, "")
225
-
226
- EXAMPLES = %{
227
- Some examples of 'gem' usage.
228
-
229
- * Install 'rake', either from local directory or remote server:
230
-
231
- gem install rake
232
-
233
- * Install 'rake', only from remote server:
234
-
235
- gem install rake --remote
236
-
237
- * Install 'rake' from remote server, and run unit tests,
238
- and generate RDocs:
239
-
240
- gem install --remote rake --test --rdoc --ri
241
-
242
- * Install 'rake', but only version 0.3.1, even if dependencies
243
- are not met, and into a specific directory:
244
-
245
- gem install rake --version 0.3.1 --force --install-dir $HOME/.gems
246
-
247
- * List local gems whose name begins with 'D':
248
-
249
- gem list D
250
-
251
- * List local and remote gems whose name contains 'log':
252
-
253
- gem search log --both
254
-
255
- * List only remote gems whose name contains 'log':
256
-
257
- gem search log --remote
258
-
259
- * Uninstall 'rake':
260
-
261
- gem uninstall rake
262
-
263
- * Create a gem:
264
-
265
- See http://rubygems.rubyforge.org/wiki/wiki.pl?CreateAGemInTenMinutes
266
-
267
- * See information about RubyGems:
268
-
269
- gem environment
270
-
271
- }.gsub(/^ /, "")
272
-
273
- end