slimgems 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) 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 +120 -0
  6. data/bin/gem +25 -0
  7. data/bin/update_slimgems +35 -0
  8. data/bootstrap/Rakefile +4 -0
  9. data/hide_lib_for_update/note.txt +5 -0
  10. data/lib/gauntlet_rubygems.rb +50 -0
  11. data/lib/rbconfig/datadir.rb +20 -0
  12. data/lib/rubygems.rb +1220 -0
  13. data/lib/rubygems/builder.rb +102 -0
  14. data/lib/rubygems/command.rb +534 -0
  15. data/lib/rubygems/command_manager.rb +182 -0
  16. data/lib/rubygems/commands/build_command.rb +53 -0
  17. data/lib/rubygems/commands/cert_command.rb +86 -0
  18. data/lib/rubygems/commands/check_command.rb +80 -0
  19. data/lib/rubygems/commands/cleanup_command.rb +106 -0
  20. data/lib/rubygems/commands/contents_command.rb +98 -0
  21. data/lib/rubygems/commands/dependency_command.rb +195 -0
  22. data/lib/rubygems/commands/environment_command.rb +132 -0
  23. data/lib/rubygems/commands/fetch_command.rb +67 -0
  24. data/lib/rubygems/commands/generate_index_command.rb +133 -0
  25. data/lib/rubygems/commands/help_command.rb +172 -0
  26. data/lib/rubygems/commands/install_command.rb +178 -0
  27. data/lib/rubygems/commands/list_command.rb +35 -0
  28. data/lib/rubygems/commands/lock_command.rb +110 -0
  29. data/lib/rubygems/commands/mirror_command.rb +111 -0
  30. data/lib/rubygems/commands/outdated_command.rb +33 -0
  31. data/lib/rubygems/commands/owner_command.rb +75 -0
  32. data/lib/rubygems/commands/pristine_command.rb +93 -0
  33. data/lib/rubygems/commands/push_command.rb +56 -0
  34. data/lib/rubygems/commands/query_command.rb +280 -0
  35. data/lib/rubygems/commands/rdoc_command.rb +91 -0
  36. data/lib/rubygems/commands/search_command.rb +31 -0
  37. data/lib/rubygems/commands/server_command.rb +86 -0
  38. data/lib/rubygems/commands/setup_command.rb +387 -0
  39. data/lib/rubygems/commands/sources_command.rb +157 -0
  40. data/lib/rubygems/commands/specification_command.rb +125 -0
  41. data/lib/rubygems/commands/stale_command.rb +27 -0
  42. data/lib/rubygems/commands/uninstall_command.rb +83 -0
  43. data/lib/rubygems/commands/unpack_command.rb +121 -0
  44. data/lib/rubygems/commands/update_command.rb +212 -0
  45. data/lib/rubygems/commands/which_command.rb +86 -0
  46. data/lib/rubygems/config_file.rb +345 -0
  47. data/lib/rubygems/custom_require.rb +44 -0
  48. data/lib/rubygems/defaults.rb +101 -0
  49. data/lib/rubygems/dependency.rb +227 -0
  50. data/lib/rubygems/dependency_installer.rb +286 -0
  51. data/lib/rubygems/dependency_list.rb +208 -0
  52. data/lib/rubygems/doc_manager.rb +242 -0
  53. data/lib/rubygems/errors.rb +35 -0
  54. data/lib/rubygems/exceptions.rb +91 -0
  55. data/lib/rubygems/ext.rb +18 -0
  56. data/lib/rubygems/ext/builder.rb +56 -0
  57. data/lib/rubygems/ext/configure_builder.rb +25 -0
  58. data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
  59. data/lib/rubygems/ext/rake_builder.rb +39 -0
  60. data/lib/rubygems/format.rb +81 -0
  61. data/lib/rubygems/gem_openssl.rb +92 -0
  62. data/lib/rubygems/gem_path_searcher.rb +100 -0
  63. data/lib/rubygems/gem_runner.rb +79 -0
  64. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  65. data/lib/rubygems/indexer.rb +720 -0
  66. data/lib/rubygems/install_update_options.rb +125 -0
  67. data/lib/rubygems/installer.rb +604 -0
  68. data/lib/rubygems/local_remote_options.rb +135 -0
  69. data/lib/rubygems/old_format.rb +153 -0
  70. data/lib/rubygems/package.rb +97 -0
  71. data/lib/rubygems/package/f_sync_dir.rb +23 -0
  72. data/lib/rubygems/package/tar_header.rb +266 -0
  73. data/lib/rubygems/package/tar_input.rb +222 -0
  74. data/lib/rubygems/package/tar_output.rb +144 -0
  75. data/lib/rubygems/package/tar_reader.rb +106 -0
  76. data/lib/rubygems/package/tar_reader/entry.rb +141 -0
  77. data/lib/rubygems/package/tar_writer.rb +241 -0
  78. data/lib/rubygems/package_task.rb +126 -0
  79. data/lib/rubygems/platform.rb +183 -0
  80. data/lib/rubygems/remote_fetcher.rb +414 -0
  81. data/lib/rubygems/require_paths_builder.rb +18 -0
  82. data/lib/rubygems/requirement.rb +153 -0
  83. data/lib/rubygems/security.rb +814 -0
  84. data/lib/rubygems/server.rb +872 -0
  85. data/lib/rubygems/source_index.rb +597 -0
  86. data/lib/rubygems/source_info_cache.rb +395 -0
  87. data/lib/rubygems/source_info_cache_entry.rb +56 -0
  88. data/lib/rubygems/spec_fetcher.rb +337 -0
  89. data/lib/rubygems/specification.rb +1486 -0
  90. data/lib/rubygems/test_utilities.rb +147 -0
  91. data/lib/rubygems/text.rb +65 -0
  92. data/lib/rubygems/uninstaller.rb +278 -0
  93. data/lib/rubygems/user_interaction.rb +527 -0
  94. data/lib/rubygems/validator.rb +240 -0
  95. data/lib/rubygems/version.rb +316 -0
  96. data/lib/rubygems/version_option.rb +65 -0
  97. data/lib/ubygems.rb +10 -0
  98. data/setup.rb +42 -0
  99. data/test/bogussources.rb +8 -0
  100. data/test/data/gem-private_key.pem +27 -0
  101. data/test/data/gem-public_cert.pem +20 -0
  102. data/test/fake_certlib/openssl.rb +7 -0
  103. data/test/foo/discover.rb +0 -0
  104. data/test/functional.rb +92 -0
  105. data/test/gem_installer_test_case.rb +97 -0
  106. data/test/gem_package_tar_test_case.rb +132 -0
  107. data/test/gemutilities.rb +605 -0
  108. data/test/insure_session.rb +43 -0
  109. data/test/mockgemui.rb +56 -0
  110. data/test/plugin/exception/rubygems_plugin.rb +2 -0
  111. data/test/plugin/load/rubygems_plugin.rb +1 -0
  112. data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
  113. data/test/private_key.pem +27 -0
  114. data/test/public_cert.pem +20 -0
  115. data/test/rubygems_plugin.rb +21 -0
  116. data/test/simple_gem.rb +66 -0
  117. data/test/test_config.rb +12 -0
  118. data/test/test_gem.rb +766 -0
  119. data/test/test_gem_builder.rb +27 -0
  120. data/test/test_gem_command.rb +178 -0
  121. data/test/test_gem_command_manager.rb +207 -0
  122. data/test/test_gem_commands_build_command.rb +74 -0
  123. data/test/test_gem_commands_cert_command.rb +124 -0
  124. data/test/test_gem_commands_check_command.rb +18 -0
  125. data/test/test_gem_commands_contents_command.rb +156 -0
  126. data/test/test_gem_commands_dependency_command.rb +216 -0
  127. data/test/test_gem_commands_environment_command.rb +144 -0
  128. data/test/test_gem_commands_fetch_command.rb +76 -0
  129. data/test/test_gem_commands_generate_index_command.rb +135 -0
  130. data/test/test_gem_commands_install_command.rb +315 -0
  131. data/test/test_gem_commands_list_command.rb +36 -0
  132. data/test/test_gem_commands_lock_command.rb +68 -0
  133. data/test/test_gem_commands_mirror_command.rb +60 -0
  134. data/test/test_gem_commands_outdated_command.rb +40 -0
  135. data/test/test_gem_commands_owner_command.rb +105 -0
  136. data/test/test_gem_commands_pristine_command.rb +108 -0
  137. data/test/test_gem_commands_push_command.rb +81 -0
  138. data/test/test_gem_commands_query_command.rb +426 -0
  139. data/test/test_gem_commands_server_command.rb +59 -0
  140. data/test/test_gem_commands_sources_command.rb +209 -0
  141. data/test/test_gem_commands_specification_command.rb +139 -0
  142. data/test/test_gem_commands_stale_command.rb +38 -0
  143. data/test/test_gem_commands_uninstall_command.rb +83 -0
  144. data/test/test_gem_commands_unpack_command.rb +199 -0
  145. data/test/test_gem_commands_update_command.rb +353 -0
  146. data/test/test_gem_commands_which_command.rb +66 -0
  147. data/test/test_gem_config_file.rb +287 -0
  148. data/test/test_gem_dependency.rb +149 -0
  149. data/test/test_gem_dependency_installer.rb +661 -0
  150. data/test/test_gem_dependency_list.rb +230 -0
  151. data/test/test_gem_doc_manager.rb +31 -0
  152. data/test/test_gem_ext_configure_builder.rb +84 -0
  153. data/test/test_gem_ext_ext_conf_builder.rb +173 -0
  154. data/test/test_gem_ext_rake_builder.rb +81 -0
  155. data/test/test_gem_format.rb +70 -0
  156. data/test/test_gem_gem_path_searcher.rb +78 -0
  157. data/test/test_gem_gem_runner.rb +45 -0
  158. data/test/test_gem_gemcutter_utilities.rb +103 -0
  159. data/test/test_gem_indexer.rb +673 -0
  160. data/test/test_gem_install_update_options.rb +68 -0
  161. data/test/test_gem_installer.rb +857 -0
  162. data/test/test_gem_local_remote_options.rb +97 -0
  163. data/test/test_gem_package_tar_header.rb +130 -0
  164. data/test/test_gem_package_tar_input.rb +112 -0
  165. data/test/test_gem_package_tar_output.rb +97 -0
  166. data/test/test_gem_package_tar_reader.rb +46 -0
  167. data/test/test_gem_package_tar_reader_entry.rb +109 -0
  168. data/test/test_gem_package_tar_writer.rb +144 -0
  169. data/test/test_gem_package_task.rb +59 -0
  170. data/test/test_gem_platform.rb +264 -0
  171. data/test/test_gem_remote_fetcher.rb +740 -0
  172. data/test/test_gem_requirement.rb +292 -0
  173. data/test/test_gem_server.rb +356 -0
  174. data/test/test_gem_silent_ui.rb +113 -0
  175. data/test/test_gem_source_index.rb +461 -0
  176. data/test/test_gem_spec_fetcher.rb +410 -0
  177. data/test/test_gem_specification.rb +1291 -0
  178. data/test/test_gem_stream_ui.rb +218 -0
  179. data/test/test_gem_text.rb +43 -0
  180. data/test/test_gem_uninstaller.rb +146 -0
  181. data/test/test_gem_validator.rb +63 -0
  182. data/test/test_gem_version.rb +181 -0
  183. data/test/test_gem_version_option.rb +89 -0
  184. data/test/test_kernel.rb +59 -0
  185. metadata +413 -0
@@ -0,0 +1,98 @@
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, :prefix => true
11
+
12
+ add_version_option
13
+
14
+ add_option( '--all',
15
+ "Contents for all gems") do |all, options|
16
+ options[:all] = all
17
+ end
18
+
19
+ add_option('-s', '--spec-dir a,b,c', Array,
20
+ "Search for gems under specific paths") do |spec_dirs, options|
21
+ options[:specdirs] = spec_dirs
22
+ end
23
+
24
+ add_option('-l', '--[no-]lib-only',
25
+ "Only return files in the Gem's lib_dirs") do |lib_only, options|
26
+ options[:lib_only] = lib_only
27
+ end
28
+
29
+ add_option( '--[no-]prefix',
30
+ "Don't include installed path prefix") do |prefix, options|
31
+ options[:prefix] = prefix
32
+ end
33
+ end
34
+
35
+ def arguments # :nodoc:
36
+ "GEMNAME name of gem to list contents for"
37
+ end
38
+
39
+ def defaults_str # :nodoc:
40
+ "--no-lib-only --prefix"
41
+ end
42
+
43
+ def usage # :nodoc:
44
+ "#{program_name} GEMNAME [GEMNAME ...]"
45
+ end
46
+
47
+ def execute
48
+ version = options[:version] || Gem::Requirement.default
49
+
50
+ spec_dirs = options[:specdirs].map do |i|
51
+ [i, File.join(i, "specifications")]
52
+ end.flatten
53
+
54
+ path_kind = if spec_dirs.empty? then
55
+ spec_dirs = Gem::SourceIndex.installed_spec_directories
56
+ "default gem paths"
57
+ else
58
+ "specified path"
59
+ end
60
+
61
+ si = Gem::SourceIndex.from_gems_in(*spec_dirs)
62
+
63
+ gem_names = if options[:all] then
64
+ si.map { |_, spec| spec.name }
65
+ else
66
+ get_all_gem_names
67
+ end
68
+
69
+ gem_names.each do |name|
70
+ gem_spec = si.find_name(name, version).last
71
+
72
+ unless gem_spec then
73
+ say "Unable to find gem '#{name}' in #{path_kind}"
74
+
75
+ if Gem.configuration.verbose then
76
+ say "\nDirectories searched:"
77
+ spec_dirs.each { |dir| say dir }
78
+ end
79
+
80
+ terminate_interaction 1 if gem_names.length == 1
81
+ end
82
+
83
+ files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
84
+
85
+ files.each do |f|
86
+ path = if options[:prefix] then
87
+ File.join gem_spec.full_gem_path, f
88
+ else
89
+ f
90
+ end
91
+
92
+ say path
93
+ end
94
+ end
95
+ end
96
+
97
+ end
98
+
@@ -0,0 +1,195 @@
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',
13
+ 'Show the dependencies of an installed gem',
14
+ :version => Gem::Requirement.default, :domain => :local
15
+
16
+ add_version_option
17
+ add_platform_option
18
+ add_prerelease_option
19
+
20
+ add_option('-R', '--[no-]reverse-dependencies',
21
+ 'Include reverse dependencies in the output') do
22
+ |value, options|
23
+ options[:reverse_dependencies] = value
24
+ end
25
+
26
+ add_option('-p', '--pipe',
27
+ "Pipe Format (name --version ver)") do |value, options|
28
+ options[:pipe_format] = value
29
+ end
30
+
31
+ add_local_remote_options
32
+ end
33
+
34
+ def arguments # :nodoc:
35
+ "GEMNAME name of gem to show dependencies for"
36
+ end
37
+
38
+ def defaults_str # :nodoc:
39
+ "--local --version '#{Gem::Requirement.default}' --no-reverse-dependencies"
40
+ end
41
+
42
+ def usage # :nodoc:
43
+ "#{program_name} GEMNAME"
44
+ end
45
+
46
+ def execute
47
+ options[:args] << '' if options[:args].empty?
48
+ specs = {}
49
+
50
+ source_indexes = Hash.new do |h, source_uri|
51
+ h[source_uri] = Gem::SourceIndex.new
52
+ end
53
+
54
+ pattern = if options[:args].length == 1 and
55
+ options[:args].first =~ /\A\/(.*)\/(i)?\z/m then
56
+ flags = $2 ? Regexp::IGNORECASE : nil
57
+ Regexp.new $1, flags
58
+ else
59
+ /\A#{Regexp.union(*options[:args])}/
60
+ end
61
+
62
+ dependency = Gem::Dependency.new pattern, options[:version]
63
+ dependency.prerelease = options[:prerelease]
64
+
65
+ if options[:reverse_dependencies] and remote? and not local? then
66
+ alert_error 'Only reverse dependencies for local gems are supported.'
67
+ terminate_interaction 1
68
+ end
69
+
70
+ if local? then
71
+ Gem.source_index.search(dependency).each do |spec|
72
+ source_indexes[:local].add_spec spec
73
+ end
74
+ end
75
+
76
+ if remote? and not options[:reverse_dependencies] then
77
+ fetcher = Gem::SpecFetcher.fetcher
78
+
79
+ begin
80
+ specs_and_sources = fetcher.find_matching(dependency, false, true,
81
+ dependency.prerelease?)
82
+
83
+ specs_and_sources.each do |spec_tuple, source_uri|
84
+ spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
85
+
86
+ source_indexes[source_uri].add_spec spec
87
+ end
88
+ rescue Gem::RemoteFetcher::FetchError => e
89
+ raise unless fetcher.warn_legacy e do
90
+ require 'rubygems/source_info_cache'
91
+
92
+ specs = Gem::SourceInfoCache.search_with_source dependency, false
93
+
94
+ specs.each do |spec, source_uri|
95
+ source_indexes[source_uri].add_spec spec
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ if source_indexes.empty? then
102
+ patterns = options[:args].join ','
103
+ say "No gems found matching #{patterns} (#{options[:version]})" if
104
+ Gem.configuration.verbose
105
+
106
+ terminate_interaction 1
107
+ end
108
+
109
+ specs = {}
110
+
111
+ source_indexes.values.each do |source_index|
112
+ source_index.gems.each do |name, spec|
113
+ specs[spec.full_name] = [source_index, spec]
114
+ end
115
+ end
116
+
117
+ reverse = Hash.new { |h, k| h[k] = [] }
118
+
119
+ if options[:reverse_dependencies] then
120
+ specs.values.each do |_, spec|
121
+ reverse[spec.full_name] = find_reverse_dependencies spec
122
+ end
123
+ end
124
+
125
+ if options[:pipe_format] then
126
+ specs.values.sort_by { |_, spec| spec }.each do |_, spec|
127
+ unless spec.dependencies.empty?
128
+ spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
129
+ say "#{dep.name} --version '#{dep.requirement}'"
130
+ end
131
+ end
132
+ end
133
+ else
134
+ response = ''
135
+
136
+ specs.values.sort_by { |_, spec| spec }.each do |_, spec|
137
+ response << print_dependencies(spec)
138
+ unless reverse[spec.full_name].empty? then
139
+ response << " Used by\n"
140
+ reverse[spec.full_name].each do |sp, dep|
141
+ response << " #{sp} (#{dep})\n"
142
+ end
143
+ end
144
+ response << "\n"
145
+ end
146
+
147
+ say response
148
+ end
149
+ end
150
+
151
+ def print_dependencies(spec, level = 0)
152
+ response = ''
153
+ response << ' ' * level + "Gem #{spec.full_name}\n"
154
+ unless spec.dependencies.empty? then
155
+ spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
156
+ response << ' ' * level + " #{dep}\n"
157
+ end
158
+ end
159
+ response
160
+ end
161
+
162
+ ##
163
+ # Returns an Array of [specification, dep] that are satisfied by +spec+.
164
+
165
+ def find_reverse_dependencies(spec)
166
+ result = []
167
+
168
+ Gem.source_index.each do |name, sp|
169
+ sp.dependencies.each do |dep|
170
+ dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
171
+
172
+ if spec.name == dep.name and
173
+ dep.requirement.satisfied_by?(spec.version) then
174
+ result << [sp.full_name, dep]
175
+ end
176
+ end
177
+ end
178
+
179
+ result
180
+ end
181
+
182
+ def find_gems(name, source_index)
183
+ specs = {}
184
+
185
+ spec_list = source_index.search name, options[:version]
186
+
187
+ spec_list.each do |spec|
188
+ specs[spec.full_name] = [source_index, spec]
189
+ end
190
+
191
+ specs
192
+ end
193
+
194
+ end
195
+
@@ -0,0 +1,132 @@
1
+ require 'rubygems/command'
2
+
3
+ class Gem::Commands::EnvironmentCommand < Gem::Command
4
+
5
+ def initialize
6
+ super 'environment', "Display information about the #{Gem::NAME} environment"
7
+ end
8
+
9
+ def arguments # :nodoc:
10
+ args = <<-EOF
11
+ packageversion display the package version
12
+ gemdir display the path where gems are installed
13
+ gempath display path used to search for gems
14
+ version display the gem format version
15
+ remotesources display the remote gem servers
16
+ platform display the supported gem platforms
17
+ <omitted> display everything
18
+ EOF
19
+ return args.gsub(/^\s+/, '')
20
+ end
21
+
22
+ def description # :nodoc:
23
+ <<-EOF
24
+ The #{Gem::NAME} environment can be controlled through command line arguments,
25
+ gemrc files, environment variables and built-in defaults.
26
+
27
+ Command line argument defaults and some #{Gem::NAME} defaults can be set in
28
+ ~/.gemrc file for individual users and a /etc/gemrc for all users. A gemrc
29
+ is a YAML file with the following YAML keys:
30
+
31
+ :sources: A YAML array of remote gem repositories to install gems from
32
+ :verbose: Verbosity of the gem command. false, true, and :really are the
33
+ levels
34
+ :update_sources: Enable/disable automatic updating of repository metadata
35
+ :backtrace: Print backtrace when #{Gem::NAME} encounters an error
36
+ :bulk_threshold: Switch to a bulk update when this many sources are out of
37
+ date (legacy setting)
38
+ :gempath: The paths in which to look for gems
39
+ gem_command: A string containing arguments for the specified gem command
40
+
41
+ Example:
42
+
43
+ :verbose: false
44
+ install: --no-wrappers
45
+ update: --no-wrappers
46
+
47
+ #{Gem::NAME}' default local repository can be overriden with the GEM_PATH and
48
+ GEM_HOME environment variables. GEM_HOME sets the default repository to
49
+ install into. GEM_PATH allows multiple local repositories to be searched for
50
+ gems.
51
+
52
+ If you are behind a proxy server, #{Gem::NAME} uses the HTTP_PROXY,
53
+ HTTP_PROXY_USER and HTTP_PROXY_PASS environment variables to discover the
54
+ proxy server.
55
+
56
+ If you are packaging #{Gem::NAME} all of #{Gem::NAME}' defaults are in
57
+ lib/rubygems/defaults.rb. You may override these in
58
+ lib/rubygems/defaults/operating_system.rb
59
+ EOF
60
+ end
61
+
62
+ def usage # :nodoc:
63
+ "#{program_name} [arg]"
64
+ end
65
+
66
+ def execute
67
+ out = ''
68
+ arg = options[:args][0]
69
+ case arg
70
+ when /^packageversion/ then
71
+ out << Gem::RubyGemsPackageVersion
72
+ when /^version/ then
73
+ out << Gem::VERSION
74
+ when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
75
+ out << Gem.dir
76
+ when /^gempath/, /^path/, /^GEM_PATH/ then
77
+ out << Gem.path.join(File::PATH_SEPARATOR)
78
+ when /^remotesources/ then
79
+ out << Gem.sources.join("\n")
80
+ when /^platform/ then
81
+ out << Gem.platforms.join(File::PATH_SEPARATOR)
82
+ when nil then
83
+ out = "#{Gem::NAME} Environment:\n"
84
+
85
+ out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n"
86
+
87
+ out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
88
+ out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
89
+ out << ") [#{RUBY_PLATFORM}]\n"
90
+
91
+ out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n"
92
+
93
+ out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
94
+
95
+ out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
96
+
97
+ out << " - EXECUTABLE DIRECTORY: #{Gem.bindir}\n"
98
+
99
+ out << " - RUBYGEMS PLATFORMS:\n"
100
+ Gem.platforms.each do |platform|
101
+ out << " - #{platform}\n"
102
+ end
103
+
104
+ out << " - GEM PATHS:\n"
105
+ out << " - #{Gem.dir}\n"
106
+
107
+ path = Gem.path.dup
108
+ path.delete Gem.dir
109
+ path.each do |p|
110
+ out << " - #{p}\n"
111
+ end
112
+
113
+ out << " - GEM CONFIGURATION:\n"
114
+ Gem.configuration.each do |name, value|
115
+ value = value.gsub(/./, '*') if name == 'gemcutter_key'
116
+ out << " - #{name.inspect} => #{value.inspect}\n"
117
+ end
118
+
119
+ out << " - REMOTE SOURCES:\n"
120
+ Gem.sources.each do |s|
121
+ out << " - #{s}\n"
122
+ end
123
+
124
+ else
125
+ raise Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
126
+ end
127
+ say out
128
+ true
129
+ end
130
+
131
+ end
132
+
@@ -0,0 +1,67 @@
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::FetchCommand < Gem::Command
7
+
8
+ include Gem::LocalRemoteOptions
9
+ include Gem::VersionOption
10
+
11
+ def initialize
12
+ super 'fetch', 'Download a gem and place it in the current directory'
13
+
14
+ add_bulk_threshold_option
15
+ add_proxy_option
16
+ add_source_option
17
+
18
+ add_version_option
19
+ add_platform_option
20
+ add_prerelease_option
21
+ end
22
+
23
+ def arguments # :nodoc:
24
+ 'GEMNAME name of gem to download'
25
+ end
26
+
27
+ def defaults_str # :nodoc:
28
+ "--version '#{Gem::Requirement.default}'"
29
+ end
30
+
31
+ def usage # :nodoc:
32
+ "#{program_name} GEMNAME [GEMNAME ...]"
33
+ end
34
+
35
+ def execute
36
+ version = options[:version] || Gem::Requirement.default
37
+ all = Gem::Requirement.default != version
38
+
39
+ gem_names = get_all_gem_names
40
+
41
+ gem_names.each do |gem_name|
42
+ dep = Gem::Dependency.new gem_name, version
43
+ dep.prerelease = options[:prerelease]
44
+
45
+ specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, all, true,
46
+ dep.prerelease?)
47
+
48
+ specs_and_sources, errors =
49
+ Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
50
+ dep.prerelease?)
51
+
52
+ spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
53
+
54
+ if spec.nil? then
55
+ show_lookup_failure gem_name, version, errors, options[:domain]
56
+ next
57
+ end
58
+
59
+ path = Gem::RemoteFetcher.fetcher.download spec, source_uri
60
+ FileUtils.mv path, spec.file_name
61
+
62
+ say "Downloaded #{spec.full_name}"
63
+ end
64
+ end
65
+
66
+ end
67
+