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,66 +1,74 @@
1
- module Gem
2
- module Commands
3
- class ContentsCommand < Command
4
- include CommandAids
5
- include VersionOption
6
- def initialize
7
- super(
8
- 'contents',
9
- 'Display the contents of the installed gems',
10
- { :list => true, :specdirs => [] })
11
-
12
- add_version_option('contents')
13
-
14
- add_option("-l","--list",'List the files inside a Gem') do |v,o|
15
- o[:list] = true
16
- end
17
-
18
- add_option('-s','--spec-dir a,b,c', Array, "Search for gems under specific paths") do |v,o|
19
- o[:specdirs] = v
20
- end
21
-
22
- add_option('-V','--verbose','Be verbose when showing status') do |v,o|
23
- o[:verbose] = v
24
- end
25
- end
1
+ require 'rubygems/command'
2
+ require 'rubygems/version_option'
3
+
4
+ class Gem::Commands::ContentsCommand < Gem::Command
5
+
6
+ include Gem::VersionOption
7
+
8
+ def initialize
9
+ super 'contents', 'Display the contents of the installed gems',
10
+ :specdirs => [], :lib_only => false
11
+
12
+ add_version_option
13
+
14
+ add_option('-s', '--spec-dir a,b,c', Array,
15
+ "Search for gems under specific paths") do |spec_dirs, options|
16
+ options[:specdirs] = spec_dirs
17
+ end
18
+
19
+ add_option('-l', '--[no-]lib-only',
20
+ "Only return files in the Gem's lib_dirs") do |lib_only, options|
21
+ options[:lib_only] = lib_only
22
+ end
23
+ end
24
+
25
+ def arguments # :nodoc:
26
+ "GEMNAME name of gem to list contents for"
27
+ end
28
+
29
+ def defaults_str # :nodoc:
30
+ "--no-lib-only"
31
+ end
26
32
 
27
- def execute(io=STDOUT)
28
- if options[:list]
29
- version = options[:version] || "> 0.0.0"
30
- gem = get_one_gem_name
31
-
32
- s = options[:specdirs].map do |i|
33
- [i, File.join(i,"specifications")]
34
- end.flatten
35
-
36
- if s.empty?
37
- s = Gem::SourceIndex.installed_spec_directories
38
- path_kind = "default gem paths"
39
- system = true
40
- else
41
- path_kind = "specified path"
42
- system = false
43
- end
44
-
45
- si = Gem::SourceIndex.from_gems_in(*s)
46
-
47
- gem_spec = si.search(gem, version).last
48
- unless gem_spec
49
- io.puts "Unable to find gem '#{gem}' in #{path_kind}"
50
- if options[:verbose]
51
- io.puts "\nDirectories searched:"
52
- s.each do |p|
53
- io.puts p
54
- end
55
- end
56
- return
57
- end
58
- # show the list of files.
59
- gem_spec.files.each do |f|
60
- io.puts File.join(gem_spec.full_gem_path, f)
61
- end
62
- end
33
+ def usage # :nodoc:
34
+ "#{program_name} GEMNAME"
35
+ end
36
+
37
+ def execute
38
+ version = options[:version] || Gem::Requirement.default
39
+ gem = get_one_gem_name
40
+
41
+ s = options[:specdirs].map do |i|
42
+ [i, File.join(i, "specifications")]
43
+ end.flatten
44
+
45
+ path_kind = if s.empty? then
46
+ s = Gem::SourceIndex.installed_spec_directories
47
+ "default gem paths"
48
+ else
49
+ "specified path"
50
+ end
51
+
52
+ si = Gem::SourceIndex.from_gems_in(*s)
53
+
54
+ gem_spec = si.search(/\A#{gem}\z/, version).last
55
+
56
+ unless gem_spec then
57
+ say "Unable to find gem '#{gem}' in #{path_kind}"
58
+
59
+ if Gem.configuration.verbose then
60
+ say "\nDirectories searched:"
61
+ s.each { |dir| say dir }
63
62
  end
63
+
64
+ terminate_interaction
65
+ end
66
+
67
+ files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
68
+ files.each do |f|
69
+ say File.join(gem_spec.full_gem_path, f)
64
70
  end
65
71
  end
66
- end
72
+
73
+ end
74
+
@@ -1,105 +1,150 @@
1
- module Gem
2
- module Commands
3
- class DependencyCommand < Command
4
- include VersionOption
5
- include CommandAids
6
-
7
- def initialize
8
- super('dependency',
1
+ require 'rubygems/command'
2
+ require 'rubygems/local_remote_options'
3
+ require 'rubygems/version_option'
4
+ require 'rubygems/source_info_cache'
5
+
6
+ class Gem::Commands::DependencyCommand < Gem::Command
7
+
8
+ include Gem::LocalRemoteOptions
9
+ include Gem::VersionOption
10
+
11
+ def initialize
12
+ super 'dependency',
9
13
  'Show the dependencies of an installed gem',
10
- {:version=>"> 0"})
11
- add_version_option('dependency')
12
- add_option('-r', '--[no-]reverse-dependencies',
13
- 'Include reverse dependencies in the output'
14
- ) do |value, options|
15
- options[:reverse_dependencies] = value
16
- end
17
- add_option('-p', '--pipe', "Pipe Format (name --version ver)") do |value, options|
18
- options[:pipe_format] = value
19
- end
20
- end
14
+ :version => Gem::Requirement.default, :domain => :local
21
15
 
22
- def defaults_str
23
- "--version '> 0' --no-reverse"
24
- end
25
-
26
- def usage
27
- "#{program_name} GEMNAME"
16
+ add_version_option
17
+ add_platform_option
18
+
19
+ add_option('-R', '--[no-]reverse-dependencies',
20
+ 'Include reverse dependencies in the output') do
21
+ |value, options|
22
+ options[:reverse_dependencies] = value
23
+ end
24
+
25
+ add_option('-p', '--pipe',
26
+ "Pipe Format (name --version ver)") do |value, options|
27
+ options[:pipe_format] = value
28
+ end
29
+
30
+ add_local_remote_options
31
+ end
32
+
33
+ def arguments # :nodoc:
34
+ "GEMNAME name of gem to show dependencies for"
35
+ end
36
+
37
+ def defaults_str # :nodoc:
38
+ "--local --version '#{Gem::Requirement.default}' --no-reverse-dependencies"
39
+ end
40
+
41
+ def usage # :nodoc:
42
+ "#{program_name} GEMNAME"
43
+ end
44
+
45
+ def execute
46
+ options[:args] << '.' if options[:args].empty?
47
+ specs = {}
48
+
49
+ source_indexes = []
50
+
51
+ if local? then
52
+ source_indexes << Gem::SourceIndex.from_installed_gems
53
+ end
54
+
55
+ if remote? then
56
+ Gem::SourceInfoCache.cache_data.map do |_, sice|
57
+ source_indexes << sice.source_index
28
58
  end
59
+ end
29
60
 
30
- def arguments
31
- "GEMNAME name of gems to show"
61
+ options[:args].each do |name|
62
+ new_specs = nil
63
+ source_indexes.each do |source_index|
64
+ new_specs = find_gems(name, source_index)
32
65
  end
33
66
 
34
- def execute
35
- specs = {}
36
- srcindex = SourceIndex.from_installed_gems
37
- options[:args] << '.' if options[:args].empty?
38
- options[:args].each do |name|
39
- speclist = srcindex.search(name, options[:version])
40
- if speclist.empty?
41
- say "No match found for #{name} (#{options[:version]})"
42
- else
43
- speclist.each do |spec|
44
- specs[spec.full_name] = spec
45
- end
46
- end
47
- end
48
- reverse = Hash.new { |h, k| h[k] = [] }
49
- if options[:reverse_dependencies]
50
- specs.values.each do |spec|
51
- reverse[spec.full_name] = find_reverse_dependencies(spec, srcindex)
52
- end
53
- end
54
- if options[:pipe_format]
55
- specs.values.sort.each do |spec|
56
- unless spec.dependencies.empty?
57
- spec.dependencies.each do |dep|
58
- puts "#{dep.name} --version '#{dep.version_requirements}'"
59
- end
60
- end
61
- end
62
- else
63
- response = ''
64
- specs.values.sort.each do |spec|
65
- response << print_dependencies(spec)
66
- unless reverse[spec.full_name].empty?
67
- response << " Used by\n"
68
- reverse[spec.full_name].each do |sp, dep|
69
- response << " #{sp} (#{dep})\n"
70
- end
71
- end
72
- response << "\n"
73
- end
74
- say response
75
- end
67
+ say "No match found for #{name} (#{options[:version]})" if
68
+ new_specs.empty?
69
+
70
+ specs = specs.merge new_specs
71
+ end
72
+
73
+ terminate_interaction 1 if specs.empty?
74
+
75
+ reverse = Hash.new { |h, k| h[k] = [] }
76
+
77
+ if options[:reverse_dependencies] then
78
+ specs.values.each do |source_index, spec|
79
+ reverse[spec.full_name] = find_reverse_dependencies spec, source_index
76
80
  end
81
+ end
77
82
 
78
- def print_dependencies(spec, level = 0)
79
- response = ''
80
- response << ' ' * level + "Gem #{spec.full_name}\n"
83
+ if options[:pipe_format] then
84
+ specs.values.sort_by { |_, spec| spec }.each do |_, spec|
81
85
  unless spec.dependencies.empty?
82
- # response << ' ' * level + " Requires\n"
83
86
  spec.dependencies.each do |dep|
84
- response << ' ' * level + " #{dep}\n"
87
+ say "#{dep.name} --version '#{dep.version_requirements}'"
85
88
  end
86
89
  end
87
- response
88
90
  end
91
+ else
92
+ response = ''
89
93
 
90
- # Retuns list of [specification, dep] that are satisfied by spec.
91
- def find_reverse_dependencies(spec, srcindex)
92
- result = []
93
- srcindex.each do |name, sp|
94
- sp.dependencies.each do |dep|
95
- if spec.name == dep.name &&
96
- dep.version_requirements.satisfied_by?(spec.version)
97
- result << [sp.full_name, dep]
98
- end
94
+ specs.values.sort_by { |_, spec| spec }.each do |_, spec|
95
+ response << print_dependencies(spec)
96
+ unless reverse[spec.full_name].empty? then
97
+ response << " Used by\n"
98
+ reverse[spec.full_name].each do |sp, dep|
99
+ response << " #{sp} (#{dep})\n"
99
100
  end
100
101
  end
101
- result
102
+ response << "\n"
103
+ end
104
+
105
+ say response
106
+ end
107
+ end
108
+
109
+ def print_dependencies(spec, level = 0)
110
+ response = ''
111
+ response << ' ' * level + "Gem #{spec.full_name}\n"
112
+ unless spec.dependencies.empty? then
113
+ spec.dependencies.each do |dep|
114
+ response << ' ' * level + " #{dep}\n"
115
+ end
116
+ end
117
+ response
118
+ end
119
+
120
+ # Retuns list of [specification, dep] that are satisfied by spec.
121
+ def find_reverse_dependencies(spec, source_index)
122
+ result = []
123
+
124
+ source_index.each do |name, sp|
125
+ sp.dependencies.each do |dep|
126
+ dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
127
+
128
+ if spec.name == dep.name and
129
+ dep.version_requirements.satisfied_by?(spec.version) then
130
+ result << [sp.full_name, dep]
131
+ end
102
132
  end
103
- end
133
+ end
134
+
135
+ result
136
+ end
137
+
138
+ def find_gems(name, source_index)
139
+ specs = {}
140
+
141
+ spec_list = source_index.search name, options[:version]
142
+
143
+ spec_list.each do |spec|
144
+ specs[spec.full_name] = [source_index, spec]
145
+ end
146
+
147
+ specs
104
148
  end
105
149
  end
150
+
@@ -1,59 +1,80 @@
1
- module Gem
2
- module Commands
3
- class EnvironmentCommand < Command
4
- include CommandAids
1
+ require 'rubygems/command'
5
2
 
6
- def initialize
7
- super('environment', 'Display information about the RubyGems environment')
8
- end
3
+ class Gem::Commands::EnvironmentCommand < Gem::Command
9
4
 
10
- def usage
11
- "#{program_name} [args]"
12
- end
5
+ def initialize
6
+ super 'environment', 'Display information about the RubyGems environment'
7
+ end
13
8
 
14
- def arguments
15
- args = <<-EOF
9
+ def arguments # :nodoc:
10
+ args = <<-EOF
16
11
  packageversion display the package version
17
12
  gemdir display the path where gems are installed
18
13
  gempath display path used to search for gems
19
14
  version display the gem format version
20
15
  remotesources display the remote gem servers
21
16
  <omitted> display everything
22
- EOF
23
- return args.gsub(/^\s+/, '')
17
+ EOF
18
+ return args.gsub(/^\s+/, '')
19
+ end
20
+
21
+ def usage # :nodoc:
22
+ "#{program_name} [arg]"
23
+ end
24
+
25
+ def execute
26
+ out = ''
27
+ arg = options[:args][0]
28
+ if begins?("packageversion", arg) then
29
+ out << Gem::RubyGemsPackageVersion
30
+ elsif begins?("version", arg) then
31
+ out << Gem::RubyGemsVersion
32
+ elsif begins?("gemdir", arg) then
33
+ out << Gem.dir
34
+ elsif begins?("gempath", arg) then
35
+ out << Gem.path.join("\n")
36
+ elsif begins?("remotesources", arg) then
37
+ out << Gem.sources.join("\n")
38
+ elsif arg then
39
+ fail Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
40
+ else
41
+ out = "RubyGems Environment:\n"
42
+
43
+ out << " - RUBYGEMS VERSION: #{Gem::RubyGemsVersion} (#{Gem::RubyGemsPackageVersion})\n"
44
+
45
+ out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
46
+ out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
47
+ out << ") [#{RUBY_PLATFORM}]\n"
48
+
49
+ out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n"
50
+
51
+ out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
52
+
53
+ out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
54
+
55
+ out << " - RUBYGEMS PLATFORMS:\n"
56
+ Gem.platforms.each do |platform|
57
+ out << " - #{platform}\n"
58
+ end
59
+
60
+ out << " - GEM PATHS:\n"
61
+ Gem.path.each do |p|
62
+ out << " - #{p}\n"
24
63
  end
25
64
 
26
- def execute
27
- out = ''
28
- arg = options[:args][0]
29
- if begins?("packageversion", arg)
30
- out = Gem::RubyGemsPackageVersion.to_s
31
- elsif begins?("version", arg)
32
- out = Gem::RubyGemsVersion.to_s
33
- elsif begins?("gemdir", arg)
34
- out = Gem.dir
35
- elsif begins?("gempath", arg)
36
- Gem.path.collect { |p| out << "#{p}\n" }
37
- elsif begins?("remotesources", arg)
38
- require 'sources'
39
- out << Gem.sources.join("\n") << "\n"
40
- elsif arg
41
- fail Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
42
- else
43
- out = "RubyGems Environment:\n"
44
- out << " - VERSION: #{Gem::RubyGemsVersion} (#{Gem::RubyGemsPackageVersion})\n"
45
- out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n"
46
- out << " - GEM PATH:\n"
47
- Gem.path.collect { |p| out << " - #{p}\n" }
48
- out << " - REMOTE SOURCES:\n"
49
- require 'sources'
50
- Gem.sources.collect do |s|
51
- out << " - #{s}\n"
52
- end
53
- end
54
- say out
55
- true
65
+ out << " - GEM CONFIGURATION:\n"
66
+ Gem.configuration.each do |name, value|
67
+ out << " - #{name.inspect} => #{value.inspect}\n"
56
68
  end
57
- end
69
+
70
+ out << " - REMOTE SOURCES:\n"
71
+ Gem.sources.each do |s|
72
+ out << " - #{s}\n"
73
+ end
74
+ end
75
+ say out
76
+ true
58
77
  end
59
- end
78
+
79
+ end
80
+