rubygems-update 1.8.30 → 2.0.0.preview2

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 (241) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +3 -0
  4. data/.autotest +6 -3
  5. data/History.txt +137 -63
  6. data/LICENSE.txt +1 -5
  7. data/Manifest.txt +69 -32
  8. data/README.rdoc +11 -9
  9. data/Rakefile +24 -38
  10. data/bin/gem +0 -9
  11. data/bin/update_rubygems +1 -0
  12. data/lib/rubygems.rb +193 -405
  13. data/lib/rubygems/available_set.rb +95 -0
  14. data/lib/rubygems/command.rb +88 -45
  15. data/lib/rubygems/command_manager.rb +67 -40
  16. data/lib/rubygems/commands/build_command.rb +5 -23
  17. data/lib/rubygems/commands/cert_command.rb +199 -57
  18. data/lib/rubygems/commands/check_command.rb +14 -39
  19. data/lib/rubygems/commands/cleanup_command.rb +9 -1
  20. data/lib/rubygems/commands/contents_command.rb +30 -12
  21. data/lib/rubygems/commands/dependency_command.rb +3 -8
  22. data/lib/rubygems/commands/environment_command.rb +13 -8
  23. data/lib/rubygems/commands/fetch_command.rb +3 -16
  24. data/lib/rubygems/commands/generate_index_command.rb +7 -47
  25. data/lib/rubygems/commands/help_command.rb +1 -1
  26. data/lib/rubygems/commands/install_command.rb +69 -36
  27. data/lib/rubygems/commands/list_command.rb +6 -4
  28. data/lib/rubygems/commands/lock_command.rb +1 -1
  29. data/lib/rubygems/commands/mirror_command.rb +17 -0
  30. data/lib/rubygems/commands/outdated_command.rb +6 -3
  31. data/lib/rubygems/commands/owner_command.rb +13 -5
  32. data/lib/rubygems/commands/pristine_command.rb +19 -4
  33. data/lib/rubygems/commands/push_command.rb +12 -1
  34. data/lib/rubygems/commands/query_command.rb +43 -27
  35. data/lib/rubygems/commands/rdoc_command.rb +23 -28
  36. data/lib/rubygems/commands/search_command.rb +4 -18
  37. data/lib/rubygems/commands/server_command.rb +1 -1
  38. data/lib/rubygems/commands/setup_command.rb +124 -38
  39. data/lib/rubygems/commands/sources_command.rb +16 -16
  40. data/lib/rubygems/commands/specification_command.rb +11 -13
  41. data/lib/rubygems/commands/uninstall_command.rb +24 -7
  42. data/lib/rubygems/commands/unpack_command.rb +7 -3
  43. data/lib/rubygems/commands/update_command.rb +22 -36
  44. data/lib/rubygems/commands/yank_command.rb +98 -0
  45. data/lib/rubygems/compatibility.rb +51 -0
  46. data/lib/rubygems/config_file.rb +82 -54
  47. data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
  48. data/lib/rubygems/core_ext/kernel_require.rb +119 -0
  49. data/lib/rubygems/defaults.rb +10 -21
  50. data/lib/rubygems/dependency.rb +61 -10
  51. data/lib/rubygems/dependency_installer.rb +157 -69
  52. data/lib/rubygems/dependency_list.rb +11 -19
  53. data/lib/rubygems/dependency_resolver.rb +562 -0
  54. data/lib/rubygems/deprecate.rb +40 -40
  55. data/lib/rubygems/errors.rb +77 -24
  56. data/lib/rubygems/exceptions.rb +25 -7
  57. data/lib/rubygems/ext/builder.rb +20 -23
  58. data/lib/rubygems/ext/configure_builder.rb +2 -2
  59. data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
  60. data/lib/rubygems/ext/rake_builder.rb +2 -2
  61. data/lib/rubygems/gem_runner.rb +3 -16
  62. data/lib/rubygems/gemcutter_utilities.rb +22 -7
  63. data/lib/rubygems/indexer.rb +6 -159
  64. data/lib/rubygems/install_message.rb +12 -0
  65. data/lib/rubygems/install_update_options.rb +56 -18
  66. data/lib/rubygems/installer.rb +244 -134
  67. data/lib/rubygems/installer_test_case.rb +71 -19
  68. data/lib/rubygems/mock_gem_ui.rb +17 -0
  69. data/lib/rubygems/name_tuple.rb +110 -0
  70. data/lib/rubygems/package.rb +514 -43
  71. data/lib/rubygems/package/digest_io.rb +64 -0
  72. data/lib/rubygems/package/old.rb +147 -0
  73. data/lib/rubygems/package/tar_header.rb +18 -55
  74. data/lib/rubygems/package/tar_reader.rb +20 -3
  75. data/lib/rubygems/package/tar_writer.rb +63 -7
  76. data/lib/rubygems/package_task.rb +3 -4
  77. data/lib/rubygems/path_support.rb +14 -7
  78. data/lib/rubygems/platform.rb +19 -26
  79. data/lib/rubygems/rdoc.rb +316 -0
  80. data/lib/rubygems/remote_fetcher.rb +117 -54
  81. data/lib/rubygems/request_set.rb +182 -0
  82. data/lib/rubygems/requirement.rb +63 -26
  83. data/lib/rubygems/security.rb +295 -555
  84. data/lib/rubygems/security/policies.rb +115 -0
  85. data/lib/rubygems/security/policy.rb +227 -0
  86. data/lib/rubygems/security/signer.rb +136 -0
  87. data/lib/rubygems/security/trust_dir.rb +104 -0
  88. data/lib/rubygems/server.rb +45 -55
  89. data/lib/rubygems/source.rb +144 -0
  90. data/lib/rubygems/source_list.rb +87 -0
  91. data/lib/rubygems/source_local.rb +92 -0
  92. data/lib/rubygems/source_specific_file.rb +28 -0
  93. data/lib/rubygems/spec_fetcher.rb +116 -184
  94. data/lib/rubygems/specification.rb +731 -335
  95. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
  96. data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
  97. data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
  98. data/lib/rubygems/syck_hack.rb +2 -0
  99. data/lib/rubygems/test_case.rb +199 -109
  100. data/lib/rubygems/test_utilities.rb +25 -5
  101. data/lib/rubygems/uninstaller.rb +62 -20
  102. data/lib/rubygems/user_interaction.rb +10 -0
  103. data/lib/rubygems/validator.rb +33 -40
  104. data/lib/rubygems/version.rb +19 -8
  105. data/setup.rb +8 -1
  106. data/test/rubygems/alternate_cert.pem +9 -0
  107. data/test/rubygems/alternate_cert_32.pem +9 -0
  108. data/test/rubygems/alternate_key.pem +9 -0
  109. data/test/rubygems/bad_rake.rb +1 -0
  110. data/test/rubygems/child_cert.pem +9 -0
  111. data/test/rubygems/child_cert_32.pem +9 -0
  112. data/test/rubygems/child_key.pem +9 -0
  113. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  114. data/test/rubygems/expired_cert.pem +9 -0
  115. data/test/rubygems/future_cert.pem +9 -0
  116. data/test/rubygems/future_cert_32.pem +9 -0
  117. data/test/rubygems/good_rake.rb +1 -0
  118. data/test/rubygems/grandchild_cert.pem +9 -0
  119. data/test/rubygems/grandchild_cert_32.pem +9 -0
  120. data/test/rubygems/grandchild_key.pem +9 -0
  121. data/test/rubygems/invalid_issuer_cert.pem +9 -0
  122. data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
  123. data/test/rubygems/invalid_key.pem +9 -0
  124. data/test/rubygems/invalid_signer_cert.pem +9 -0
  125. data/test/rubygems/invalid_signer_cert_32.pem +9 -0
  126. data/test/rubygems/invalidchild_cert.pem +9 -0
  127. data/test/rubygems/invalidchild_cert_32.pem +9 -0
  128. data/test/rubygems/invalidchild_key.pem +9 -0
  129. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  130. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  131. data/test/rubygems/private_key.pem +7 -25
  132. data/test/rubygems/public_cert.pem +8 -18
  133. data/test/rubygems/public_cert_32.pem +10 -0
  134. data/test/rubygems/public_key.pem +4 -0
  135. data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
  136. data/test/rubygems/test_config.rb +4 -6
  137. data/test/rubygems/test_deprecate.rb +76 -0
  138. data/test/rubygems/test_gem.rb +318 -83
  139. data/test/rubygems/test_gem_available_set.rb +106 -0
  140. data/test/rubygems/test_gem_command.rb +10 -0
  141. data/test/rubygems/test_gem_command_manager.rb +55 -9
  142. data/test/rubygems/test_gem_commands_build_command.rb +11 -19
  143. data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
  144. data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
  145. data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
  146. data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
  147. data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
  148. data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
  149. data/test/rubygems/test_gem_commands_help_command.rb +2 -1
  150. data/test/rubygems/test_gem_commands_install_command.rb +647 -48
  151. data/test/rubygems/test_gem_commands_mirror.rb +32 -0
  152. data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
  153. data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
  154. data/test/rubygems/test_gem_commands_push_command.rb +62 -8
  155. data/test/rubygems/test_gem_commands_query_command.rb +51 -0
  156. data/test/rubygems/test_gem_commands_search_command.rb +25 -0
  157. data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
  158. data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
  159. data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
  160. data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
  161. data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
  162. data/test/rubygems/test_gem_commands_update_command.rb +56 -38
  163. data/test/rubygems/test_gem_commands_which_command.rb +4 -4
  164. data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
  165. data/test/rubygems/test_gem_config_file.rb +66 -21
  166. data/test/rubygems/test_gem_dependency.rb +46 -0
  167. data/test/rubygems/test_gem_dependency_installer.rb +228 -18
  168. data/test/rubygems/test_gem_dependency_list.rb +0 -9
  169. data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
  170. data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
  171. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
  172. data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
  173. data/test/rubygems/test_gem_gem_runner.rb +27 -5
  174. data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
  175. data/test/rubygems/test_gem_indexer.rb +14 -227
  176. data/test/rubygems/test_gem_install_update_options.rb +83 -3
  177. data/test/rubygems/test_gem_installer.rb +211 -236
  178. data/test/rubygems/test_gem_local_remote_options.rb +8 -2
  179. data/test/rubygems/test_gem_name_tuple.rb +15 -0
  180. data/test/rubygems/test_gem_package.rb +547 -0
  181. data/test/rubygems/test_gem_package_old.rb +37 -0
  182. data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
  183. data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
  184. data/test/rubygems/test_gem_path_support.rb +4 -30
  185. data/test/rubygems/test_gem_platform.rb +3 -6
  186. data/test/rubygems/test_gem_rdoc.rb +245 -0
  187. data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
  188. data/test/rubygems/test_gem_request_set.rb +70 -0
  189. data/test/rubygems/test_gem_requirement.rb +53 -24
  190. data/test/rubygems/test_gem_security.rb +189 -43
  191. data/test/rubygems/test_gem_security_policy.rb +376 -0
  192. data/test/rubygems/test_gem_security_signer.rb +184 -0
  193. data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
  194. data/test/rubygems/test_gem_server.rb +31 -36
  195. data/test/rubygems/test_gem_silent_ui.rb +2 -2
  196. data/test/rubygems/test_gem_source.rb +188 -0
  197. data/test/rubygems/test_gem_source_list.rb +87 -0
  198. data/test/rubygems/test_gem_source_local.rb +83 -0
  199. data/test/rubygems/test_gem_source_specific_file.rb +33 -0
  200. data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
  201. data/test/rubygems/test_gem_specification.rb +293 -39
  202. data/test/rubygems/test_gem_uninstaller.rb +136 -13
  203. data/test/rubygems/test_gem_validator.rb +14 -41
  204. data/test/rubygems/test_gem_version.rb +15 -21
  205. data/test/rubygems/test_require.rb +193 -0
  206. data/test/rubygems/wrong_key_cert.pem +9 -0
  207. data/test/rubygems/wrong_key_cert_32.pem +9 -0
  208. metadata +171 -83
  209. metadata.gz.sig +1 -0
  210. data/CVE-2013-4287.txt +0 -36
  211. data/CVE-2013-4363.txt +0 -45
  212. data/ci_build.sh +0 -27
  213. data/cruise_config.rb +0 -32
  214. data/lib/rbconfig/datadir.rb +0 -13
  215. data/lib/rubygems/builder.rb +0 -99
  216. data/lib/rubygems/custom_require.rb +0 -69
  217. data/lib/rubygems/doc_manager.rb +0 -243
  218. data/lib/rubygems/format.rb +0 -82
  219. data/lib/rubygems/gem_openssl.rb +0 -90
  220. data/lib/rubygems/gem_path_searcher.rb +0 -172
  221. data/lib/rubygems/old_format.rb +0 -153
  222. data/lib/rubygems/package/f_sync_dir.rb +0 -23
  223. data/lib/rubygems/package/tar_input.rb +0 -234
  224. data/lib/rubygems/package/tar_output.rb +0 -146
  225. data/lib/rubygems/require_paths_builder.rb +0 -18
  226. data/lib/rubygems/source_index.rb +0 -406
  227. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  228. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  229. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  230. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  231. data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  232. data/test/rubygems/test_bundled_ca.rb +0 -59
  233. data/test/rubygems/test_gem_builder.rb +0 -44
  234. data/test/rubygems/test_gem_doc_manager.rb +0 -32
  235. data/test/rubygems/test_gem_ext_builder.rb +0 -58
  236. data/test/rubygems/test_gem_format.rb +0 -88
  237. data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
  238. data/test/rubygems/test_gem_package_tar_input.rb +0 -129
  239. data/test/rubygems/test_gem_package_tar_output.rb +0 -101
  240. data/test/rubygems/test_gem_source_index.rb +0 -250
  241. data/util/update_bundled_ca_certificates.rb +0 -103
@@ -1,10 +1,11 @@
1
1
  = RubyGems
2
2
 
3
- * http://rubygems.org
4
- * http://docs.rubygems.org
5
- * http://help.rubygems.org
6
- * http://github.com/rubygems
7
- * http://rubyforge.org/projects/rubygems
3
+ Homepage: :: http://rubygems.org
4
+ Announcements: :: http://blog.rubygems.org
5
+ Documentation: :: http://guides.rubygems.org
6
+ Support: :: http://help.rubygems.org
7
+ Source: :: http://github.com/rubygems/rubygems
8
+ Bugtracker: :: http://github.com/rubygems/rubygems/issues
8
9
 
9
10
  == DESCRIPTION
10
11
 
@@ -23,7 +24,7 @@ See UPGRADING.rdoc for more details and alternative instructions.
23
24
 
24
25
  -----
25
26
 
26
- If you don't have RubyGems installed, your can still do it manually:
27
+ If you don't have RubyGems installed, you can still do it manually:
27
28
 
28
29
  * Download from: https://rubygems.org/pages/download
29
30
  * Unpack into a directory and cd there
@@ -43,9 +44,10 @@ support request at {help.rubygems.org}[http://help.rubygems.org].
43
44
 
44
45
  === Filing Tickets
45
46
 
46
- You're sure you've found a bug! But where do you let us know? The best place
47
- for letting the RubyGems team know about bugs you've found is {on the rubygems
48
- tracker at rubyforge}[http://rubyforge.org/tracker/?group_id=126].
47
+ Got a bug and you're not sure? You're sure you have a bug, but don't know
48
+ what to do next? In any case, let us know about it! The best place
49
+ for letting the RubyGems team know about bugs or problems you're having is
50
+ {on the rubygems issues page at github}[http://github.com/rubygems/rubygems/issues].
49
51
 
50
52
  === Bundler Compatibility
51
53
 
data/Rakefile CHANGED
@@ -6,6 +6,10 @@ require 'rubygems/package_task'
6
6
  # HACK bootstrap load_yaml, remove after 1.5 release
7
7
  def Gem.load_yaml; end unless Gem.respond_to? :load_yaml
8
8
 
9
+ if ENV['YAML'] == "syck"
10
+ ENV['TEST_SYCK'] = "1"
11
+ end
12
+
9
13
  begin
10
14
  require 'psych'
11
15
  rescue ::LoadError
@@ -18,16 +22,15 @@ Hoe::RUBY_FLAGS << " --disable-gems" if RUBY_VERSION > "1.9"
18
22
 
19
23
  Hoe.plugin :minitest
20
24
  Hoe.plugin :git
25
+ Hoe.plugin :travis
21
26
  # Hoe.plugin :isolate
22
27
 
23
28
  hoe = Hoe.spec 'rubygems-update' do
29
+ self.rubyforge_name = 'rubygems'
24
30
  self.author = ['Jim Weirich', 'Chad Fowler', 'Eric Hodel']
25
31
  self.email = %w[rubygems-developers@rubyforge.org]
26
32
  self.readme_file = 'README.rdoc'
27
33
 
28
- license 'Ruby'
29
- license 'MIT'
30
-
31
34
  spec_extras[:required_rubygems_version] = Gem::Requirement.default
32
35
  spec_extras[:required_ruby_version] = Gem::Requirement.new '>= 1.8.7'
33
36
  spec_extras[:executables] = ['update_rubygems']
@@ -49,13 +52,10 @@ hoe = Hoe.spec 'rubygems-update' do
49
52
  extra_dev_deps << ['hoe-seattlerb', '~> 1.2']
50
53
  extra_dev_deps << ['session', '~> 2.4']
51
54
  extra_dev_deps << ['rdoc', '~> 3.0']
52
- extra_dev_deps << ['rcov', '~> 0.9.0']
53
55
  extra_dev_deps << ['ZenTest', '~> 4.5']
56
+ extra_dev_deps << ['rake', '~> 0.9.3']
54
57
 
55
- self.extra_rdoc_files = Dir["*.rdoc"] + %w[
56
- CVE-2013-4287.txt
57
- CVE-2013-4363.txt
58
- ]
58
+ self.extra_rdoc_files = Dir["*.rdoc"]
59
59
 
60
60
  spec_extras['rdoc_options'] = proc do |rdoc_options|
61
61
  rdoc_options << "--title=RubyGems #{self.version} Documentation"
@@ -70,8 +70,6 @@ hoe = Hoe.spec 'rubygems-update' do
70
70
  ENV['RAKE_SUCKS']
71
71
  end
72
72
 
73
- hoe.test_prelude = 'gem "minitest", "~> 4.0"'
74
-
75
73
  task :docs => :rake_sucks
76
74
  task :rake_sucks do
77
75
  # This exists ENTIRELY because the rake design convention of
@@ -86,12 +84,19 @@ task :rake_sucks do
86
84
  end
87
85
  end
88
86
 
87
+ task :clean_env do
88
+ ENV.delete "GEM_HOME"
89
+ ENV.delete "GEM_PATH"
90
+ end
91
+
92
+ task :test => :clean_env
93
+
89
94
  # --------------------------------------------------------------------
90
95
  # Creating a release
91
96
 
92
97
  task :prerelease => [:clobber, :check_manifest, :test]
93
98
 
94
- task :postrelease => [:upload]
99
+ task :postrelease => [:publish_docs, :upload]
95
100
 
96
101
  pkg_dir_path = "pkg/rubygems-update-#{hoe.version}"
97
102
  task :package do
@@ -145,7 +150,7 @@ def diff_with dir
145
150
  sh "diff #{diff_options} lib/rubygems.rb #{dir}/lib/rubygems.rb; true"
146
151
  sh "diff #{diff_options} lib/rubygems #{dir}/lib/rubygems; true"
147
152
  sh "diff #{diff_options} lib/rbconfig #{dir}/lib/rbconfig; true"
148
- sh "diff #{diff_options} test/rubygems #{dir}/test/rubygems; true"
153
+ sh "diff #{diff_options} test #{dir}/test/rubygems; true"
149
154
  end
150
155
 
151
156
  rubinius_dir = ENV['RUBINIUS_PATH'] || '../git.rubini.us/code'
@@ -171,29 +176,6 @@ task :diff_rubinius do
171
176
  diff_with rubinius_dir
172
177
  end
173
178
 
174
- desc "Get coverage for a specific test, no system RubyGems."
175
- task "rcov:for", [:test] do |task, args|
176
- mgem = Gem.source_index.find_name("minitest").first rescue nil
177
- rgem = Gem.source_index.find_name(/rcov/).first
178
- libs = rgem.require_paths.map { |p| File.join rgem.full_gem_path, p }
179
- rcov = File.join rgem.full_gem_path, rgem.bindir, rgem.default_executable
180
-
181
- if mgem
182
- libs << mgem.require_paths.map { |p| File.join mgem.full_gem_path, p }
183
- end
184
-
185
- libs << "lib:test"
186
-
187
- flags = []
188
- flags << "-I" << libs.flatten.join(":")
189
-
190
- rflags = []
191
- rflags << "-i" << "lib/rubygems"
192
- rflags << "--no-color" << "--save coverage.info" << "-T" << "--no-html"
193
-
194
- ruby "#{flags.join ' '} #{rcov} #{rflags.join ' '} #{args[:test]}"
195
- end
196
-
197
179
  def changelog_section code
198
180
  name = {
199
181
  :major => "major enhancement",
@@ -233,11 +215,10 @@ task "git:newchangelog" do
233
215
  now = Time.new.strftime "%Y-%m-%d"
234
216
 
235
217
  changes = `#{cmd}`.split(/\|\|\|/).each_slice(3).map do |msg, author, email|
236
- c = msg.split(/\n/).reject { |s| s.empty? }
237
- c.empty? ? nil : c.first
218
+ msg.split(/\n/).reject { |s| s.empty? }
238
219
  end
239
220
 
240
- changes = changes.flatten.compact
221
+ changes = changes.flatten
241
222
 
242
223
  next if changes.empty?
243
224
 
@@ -271,3 +252,8 @@ task "git:newchangelog" do
271
252
  changelog_section :unknown
272
253
  puts
273
254
  end
255
+
256
+ desc "Cleanup trailing whitespace"
257
+ task :whitespace do
258
+ system 'find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | xargs -0 sed -i "" -E "s/[[:space:]]*$//"'
259
+ end
data/bin/gem CHANGED
@@ -5,15 +5,6 @@
5
5
  # See LICENSE.txt for permissions.
6
6
  #++
7
7
 
8
- # The prelude in 1.9.1 injects rubygems.rb into $LOADED_FEATURES
9
- # which prevents the `require 'rubygems'` from actually loading
10
- # the site's version of rubygems. So we have to use it's API
11
- # to get it's prelude out of the way.
12
- #
13
- if RUBY_VERSION =~ /^1\.9\.1/ && defined?(Gem::QuickLoader)
14
- Gem::QuickLoader.load_full_rubygems_library
15
- end
16
-
17
8
  require 'rubygems'
18
9
  require 'rubygems/gem_runner'
19
10
  require 'rubygems/exceptions'
@@ -31,6 +31,7 @@ if update_dir.nil?
31
31
  else
32
32
  update_dir = File.dirname(update_dir)
33
33
  Dir.chdir update_dir
34
+ ENV["GEM_PREV_VER"] = Gem::VERSION
34
35
  system(Gem.ruby, 'setup.rb', *ARGV)
35
36
  end
36
37
 
@@ -5,32 +5,6 @@
5
5
  # See LICENSE.txt for permissions.
6
6
  #++
7
7
 
8
- module Gem
9
- QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/
10
-
11
- # Only MRI 1.9.2 has the custom prelude.
12
- GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ && RUBY_ENGINE == "ruby"
13
- end
14
-
15
- if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
16
- Gem::QuickLoader.remove
17
-
18
- $LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
19
-
20
- if $LOADED_FEATURES.any? do |path| path.end_with? '/rubygems.rb' end then
21
- # TODO path does not exist here
22
- raise LoadError, "another rubygems is already loaded from #{path}"
23
- end
24
-
25
- class << Gem
26
- remove_method :try_activate if Gem.respond_to?(:try_activate, true)
27
- end
28
- end
29
-
30
- require 'rubygems/defaults'
31
- require 'rbconfig'
32
- require "rubygems/deprecate"
33
-
34
8
  ##
35
9
  # RubyGems is the Ruby standard for publishing and managing third party
36
10
  # libraries.
@@ -72,8 +46,8 @@ require "rubygems/deprecate"
72
46
  # For RubyGems packagers, provide lib/rubygems/operating_system.rb and
73
47
  # override any defaults from lib/rubygems/defaults.rb.
74
48
  #
75
- # For Ruby implementers, provide lib/rubygems/#{RUBY_ENGINE}.rb and override
76
- # any defaults from lib/rubygems/defaults.rb.
49
+ # For Ruby implementers, provide lib/rubygems/defaults/#{RUBY_ENGINE}.rb and
50
+ # override any defaults from lib/rubygems/defaults.rb.
77
51
  #
78
52
  # If you need RubyGems to perform extra work on install or uninstall, your
79
53
  # defaults override file can set pre and post install and uninstall hooks.
@@ -83,8 +57,8 @@ require "rubygems/deprecate"
83
57
  # == Bugs
84
58
  #
85
59
  # You can submit bugs to the
86
- # {RubyGems bug tracker}[http://rubyforge.org/tracker/?atid=575&group_id=126]
87
- # on RubyForge
60
+ # {RubyGems bug tracker}[https://github.com/rubygems/rubygems/issues]
61
+ # on GitHub
88
62
  #
89
63
  # == Credits
90
64
  #
@@ -112,7 +86,8 @@ require "rubygems/deprecate"
112
86
  # * Daniel Berger -- djberg96(at)gmail.com
113
87
  # * Phil Hagelberg -- technomancy(at)gmail.com
114
88
  # * Ryan Davis -- ryand-ruby(at)zenspider.com
115
- # * Evan Phoenix -- evan@phx.io
89
+ # * Evan Phoenix -- evan(at)fallingsnow.net
90
+ # * Steve Klabnik -- steve(at)steveklabnik.com
116
91
  #
117
92
  # (If your name is missing, PLEASE let us know!)
118
93
  #
@@ -120,49 +95,22 @@ require "rubygems/deprecate"
120
95
  #
121
96
  # -The RubyGems Team
122
97
 
123
- module Gem
124
- VERSION = '1.8.30'
125
-
126
- ##
127
- # Raised when RubyGems is unable to load or activate a gem. Contains the
128
- # name and version requirements of the gem that either conflicts with
129
- # already activated gems or that RubyGems is otherwise unable to activate.
130
-
131
- class LoadError < ::LoadError
132
- # Name of gem
133
- attr_accessor :name
134
-
135
- # Version requirement of gem
136
- attr_accessor :requirement
137
- end
138
-
139
- # :stopdoc:
140
-
141
- RubyGemsVersion = VERSION
98
+ require 'rbconfig'
142
99
 
143
- RbConfigPriorities = %w[
144
- EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
145
- ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
146
- ]
100
+ module Gem
101
+ VERSION = '2.0.0.preview2'
102
+ end
147
103
 
148
- unless defined?(ConfigMap)
149
- ##
150
- # Configuration settings from ::RbConfig
151
- ConfigMap = Hash.new do |cm, key|
152
- cm[key] = RbConfig::CONFIG[key.to_s]
153
- end
154
- else
155
- RbConfigPriorities.each do |key|
156
- ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
157
- end
158
- end
104
+ # Must be first since it unloads the prelude from 1.9.2
105
+ require 'rubygems/compatibility'
159
106
 
160
- RubyGemsPackageVersion = VERSION
107
+ require 'rubygems/defaults'
108
+ require 'rubygems/deprecate'
109
+ require 'rubygems/errors'
161
110
 
111
+ module Gem
162
112
  RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)
163
113
 
164
- # :startdoc:
165
-
166
114
  ##
167
115
  # An Array of Regexps that match windows ruby platforms.
168
116
 
@@ -175,11 +123,13 @@ module Gem
175
123
  /wince/i,
176
124
  ]
177
125
 
178
- @@source_index = nil
126
+ GEM_DEP_FILES = %w!gem.deps.rb Gemfile Isolate!
127
+
179
128
  @@win_platform = nil
180
129
 
181
130
  @configuration = nil
182
131
  @loaded_specs = {}
132
+ @path_to_default_spec_map = {}
183
133
  @platforms = []
184
134
  @ruby = nil
185
135
  @sources = nil
@@ -198,12 +148,13 @@ module Gem
198
148
  # activated. Returns false if it can't find the path in a gem.
199
149
 
200
150
  def self.try_activate path
201
- # TODO: deprecate when 1.9.3 comes out.
202
151
  # finds the _latest_ version... regardless of loaded specs and their deps
152
+ # if another gem had a requirement that would mean we shouldn't
153
+ # activate the latest version, then either it would alreaby be activated
154
+ # or if it was ambigious (and thus unresolved) the code in our custom
155
+ # require will try to activate the more specific version.
203
156
 
204
- # TODO: use find_all and bork if ambiguous
205
-
206
- spec = Gem::Specification.find_by_path path
157
+ spec = Gem::Specification.find_inactive_by_path path
207
158
  return false unless spec
208
159
 
209
160
  begin
@@ -215,77 +166,62 @@ module Gem
215
166
  return true
216
167
  end
217
168
 
218
- ##
219
- # Activates an installed gem matching +dep+. The gem must satisfy
220
- # +requirements+.
221
- #
222
- # Returns true if the gem is activated, false if it is already
223
- # loaded, or an exception otherwise.
224
- #
225
- # Gem#activate adds the library paths in +dep+ to $LOAD_PATH. Before a Gem
226
- # is activated its required Gems are activated. If the version information
227
- # is omitted, the highest version Gem of the supplied name is loaded. If a
228
- # Gem is not found that meets the version requirements or a required Gem is
229
- # not found, a Gem::LoadError is raised.
230
- #
231
- # More information on version requirements can be found in the
232
- # Gem::Requirement and Gem::Version documentation.
233
-
234
- def self.activate(dep, *requirements)
235
- raise ArgumentError, "Deprecated use of Gem.activate(dep)" if
236
- Gem::Dependency === dep
169
+ def self.needs
170
+ rs = Gem::RequestSet.new
237
171
 
238
- Gem::Specification.find_by_name(dep, *requirements).activate
239
- end
172
+ yield rs
240
173
 
241
- def self.activate_dep dep, *requirements # :nodoc:
242
- dep.to_spec.activate
174
+ finish_resolve rs
243
175
  end
244
176
 
245
- def self.activate_spec spec # :nodoc:
246
- spec.activate
247
- end
177
+ def self.finish_resolve(request_set=Gem::RequestSet.new)
178
+ request_set.import Gem::Specification.unresolved_deps.values
248
179
 
249
- def self.unresolved_deps
250
- @unresolved_deps ||= Hash.new { |h, n| h[n] = Gem::Dependency.new n }
180
+ request_set.resolve_current.each do |s|
181
+ s.full_spec.activate
182
+ end
251
183
  end
252
184
 
253
- ##
254
- # An Array of all possible load paths for all versions of all gems in the
255
- # Gem installation.
185
+ def self.detect_gemdeps
186
+ if path = ENV['RUBYGEMS_GEMDEPS']
187
+ path = path.dup.untaint
256
188
 
257
- def self.all_load_paths
258
- result = []
189
+ if path == "-"
190
+ here = Dir.pwd.untaint
191
+ start = here
259
192
 
260
- Gem.path.each do |gemdir|
261
- each_load_path all_partials(gemdir) do |load_path|
262
- result << load_path
263
- end
264
- end
193
+ begin
194
+ while true
195
+ path = GEM_DEP_FILES.find { |f| File.exists?(f) }
265
196
 
266
- result
267
- end
197
+ if path
198
+ path = File.join here, path
199
+ break
200
+ end
268
201
 
269
- ##
270
- # Return all the partial paths in +gemdir+.
202
+ Dir.chdir ".."
271
203
 
272
- def self.all_partials(gemdir)
273
- Dir[File.join(gemdir, "gems/*")]
274
- end
204
+ # If we're at a toplevel, stop.
205
+ return if Dir.pwd == here
275
206
 
276
- private_class_method :all_partials
207
+ here = Dir.pwd
208
+ end
209
+ ensure
210
+ Dir.chdir start
211
+ end
212
+ end
277
213
 
278
- ##
279
- # See if a given gem is available.
214
+ return unless File.exists? path
280
215
 
281
- def self.available?(dep, *requirements)
282
- requirements = Gem::Requirement.default if requirements.empty?
216
+ rs = Gem::RequestSet.new
217
+ rs.load_gemdeps path
283
218
 
284
- unless dep.respond_to?(:name) and dep.respond_to?(:requirement) then
285
- dep = Gem::Dependency.new dep, requirements
219
+ rs.resolve_current.map do |s|
220
+ sp = s.full_spec
221
+ sp.activate
222
+ sp
223
+ end
286
224
  end
287
-
288
- not dep.matching_specs(true).empty?
289
225
  end
290
226
 
291
227
  ##
@@ -343,11 +279,10 @@ module Gem
343
279
  # mainly used by the unit tests to provide test isolation.
344
280
 
345
281
  def self.clear_paths
346
- @@source_index = nil
347
282
  @paths = nil
348
283
  @user_home = nil
349
- @searcher = nil
350
284
  Gem::Specification.reset
285
+ Gem::Security.reset if const_defined? :Security
351
286
  end
352
287
 
353
288
  ##
@@ -377,7 +312,8 @@ module Gem
377
312
  # package is not available as a gem, return nil.
378
313
 
379
314
  def self.datadir(gem_name)
380
- # TODO: deprecate
315
+ # TODO: deprecate and move to Gem::Specification
316
+ # and drop the extra ", gem_name" which is uselessly redundant
381
317
  spec = @loaded_specs[gem_name]
382
318
  return nil if spec.nil?
383
319
  File.join spec.full_gem_path, "data", gem_name
@@ -391,10 +327,12 @@ module Gem
391
327
  Zlib::Deflate.deflate data
392
328
  end
393
329
 
330
+ # DOC: needs doc'd or :nodoc'd
394
331
  def self.paths
395
332
  @paths ||= Gem::PathSupport.new
396
333
  end
397
334
 
335
+ # DOC: needs doc'd or :nodoc'd
398
336
  def self.paths=(env)
399
337
  clear_paths
400
338
  @paths = Gem::PathSupport.new env
@@ -450,7 +388,7 @@ module Gem
450
388
 
451
389
  require 'fileutils'
452
390
 
453
- %w[cache doc gems specifications].each do |name|
391
+ %w[cache build_info doc gems specifications].each do |name|
454
392
  subdir = File.join dir, name
455
393
  next if File.exist? subdir
456
394
  FileUtils.mkdir_p subdir rescue nil # in case of perms issues -- lame
@@ -566,13 +504,28 @@ module Gem
566
504
  Zlib::Inflate.inflate data
567
505
  end
568
506
 
507
+ ##
508
+ # Top level install helper method. Allows you to install gems interactively:
509
+ #
510
+ # % irb
511
+ # >> Gem.install "minitest"
512
+ # Fetching: minitest-3.0.1.gem (100%)
513
+ # => [#<Gem::Specification:0x1013b4528 @name="minitest", ...>]
514
+
515
+ def self.install name, version = Gem::Requirement.default
516
+ require "rubygems/dependency_installer"
517
+ inst = Gem::DependencyInstaller.new
518
+ inst.install name, version
519
+ inst.installed_gems
520
+ end
521
+
569
522
  ##
570
523
  # Get the default RubyGems API host. This is normally
571
524
  # <tt>https://rubygems.org</tt>.
572
525
 
573
526
  def self.host
574
527
  # TODO: move to utils
575
- @host ||= "https://rubygems.org"
528
+ @host ||= Gem::DEFAULT_HOST
576
529
  end
577
530
 
578
531
  ## Set the default RubyGems API host.
@@ -582,43 +535,6 @@ module Gem
582
535
  @host = host
583
536
  end
584
537
 
585
- ##
586
- # Return a list of all possible load paths for the latest version for all
587
- # gems in the Gem installation.
588
-
589
- def self.latest_load_paths
590
- result = []
591
-
592
- Gem.path.each do |gemdir|
593
- each_load_path(latest_partials(gemdir)) do |load_path|
594
- result << load_path
595
- end
596
- end
597
-
598
- result
599
- end
600
-
601
- ##
602
- # Return only the latest partial paths in the given +gemdir+.
603
-
604
- def self.latest_partials(gemdir)
605
- latest = {}
606
- all_partials(gemdir).each do |gp|
607
- base = File.basename gp
608
-
609
- if base.to_s =~ /(.*)-((\d+\.)*\d+)/ then
610
- name, version = $1, $2
611
- ver = Gem::Version.new(version)
612
- if latest[name].nil? || ver > latest[name][0]
613
- latest[name] = [ver, gp]
614
- end
615
- end
616
- end
617
- latest.collect { |k,v| v[1] }
618
- end
619
-
620
- private_class_method :latest_partials
621
-
622
538
  ##
623
539
  # The index to insert activated gem paths into the $LOAD_PATH.
624
540
  #
@@ -629,16 +545,6 @@ module Gem
629
545
  def self.load_path_insert_index
630
546
  index = $LOAD_PATH.index ConfigMap[:sitelibdir]
631
547
 
632
- if QUICKLOADER_SUCKAGE then
633
- $LOAD_PATH.each_with_index do |path, i|
634
- if path.instance_variables.include?(:@gem_prelude_index) or
635
- path.instance_variables.include?('@gem_prelude_index') then
636
- index = i
637
- break
638
- end
639
- end
640
- end
641
-
642
548
  index
643
549
  end
644
550
 
@@ -649,6 +555,7 @@ module Gem
649
555
 
650
556
  def self.load_yaml
651
557
  return if @yaml_loaded
558
+ return unless defined?(gem)
652
559
 
653
560
  test_syck = ENV['TEST_SYCK']
654
561
 
@@ -711,27 +618,6 @@ module Gem
711
618
  "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
712
619
  end
713
620
 
714
- ##
715
- # Get the appropriate cache path.
716
- #
717
- # Pass a string to use a different base path, or nil/false (default) for
718
- # Gem.dir.
719
- #
720
-
721
- def self.cache_dir(custom_dir=false)
722
- File.join(custom_dir || Gem.dir, "cache")
723
- end
724
-
725
- ##
726
- # Given a gem path, find the gem in cache.
727
- #
728
- # Pass a string as the second argument to use a different base path, or
729
- # nil/false (default) for Gem.dir.
730
-
731
- def self.cache_gem(filename, user_dir=false)
732
- cache_dir(user_dir).add(filename)
733
- end
734
-
735
621
  ##
736
622
  # Set array of platforms this RubyGems supports (primarily for testing).
737
623
 
@@ -769,6 +655,15 @@ module Gem
769
655
  @post_install_hooks << hook
770
656
  end
771
657
 
658
+ ##
659
+ # Adds a post-installs hook that will be passed a Gem::DependencyInstaller
660
+ # and a list of installed specifications when
661
+ # Gem::DependencyInstaller#install is complete
662
+
663
+ def self.done_installing(&hook)
664
+ @done_installing_hooks << hook
665
+ end
666
+
772
667
  ##
773
668
  # Adds a hook that will get run after Gem::Specification.reset is
774
669
  # run.
@@ -828,39 +723,10 @@ module Gem
828
723
  end
829
724
 
830
725
  ##
831
- # Promotes the load paths of the +gem_name+ over the load paths of
832
- # +over_name+. Useful for allowing one gem to override features in another
833
- # using #find_files.
834
-
835
- def self.promote_load_path(gem_name, over_name)
836
- gem = Gem.loaded_specs[gem_name]
837
- over = Gem.loaded_specs[over_name]
838
-
839
- raise ArgumentError, "gem #{gem_name} is not activated" if gem.nil?
840
- raise ArgumentError, "gem #{over_name} is not activated" if over.nil?
841
-
842
- last_gem_path = Gem::Path.path(gem.full_gem_path).add(gem.require_paths.last)
843
-
844
- over_paths = over.require_paths.map do |path|
845
- Gem::Path.path(over.full_gem_path).add(path).to_s
846
- end
847
-
848
- over_paths.each do |path|
849
- $LOAD_PATH.delete path
850
- end
851
-
852
- gem = $LOAD_PATH.index(last_gem_path) + 1
853
-
854
- $LOAD_PATH.insert(gem, *over_paths)
855
- end
856
-
857
- ##
858
- # Refresh source_index from disk and clear searcher.
726
+ # Refresh available gems from disk.
859
727
 
860
728
  def self.refresh
861
729
  Gem::Specification.reset
862
- @source_index = nil
863
- @searcher = nil
864
730
  end
865
731
 
866
732
  ##
@@ -870,50 +736,6 @@ module Gem
870
736
  File.open path, binary_mode do |f| f.read end
871
737
  end
872
738
 
873
- ##
874
- # Report a load error during activation. The message of load error
875
- # depends on whether it was a version mismatch or if there are not gems of
876
- # any version by the requested name.
877
-
878
- def self.report_activate_error(gem)
879
- matches = Gem::Specification.find_by_name(gem.name)
880
-
881
- if matches.empty? then
882
- error = Gem::LoadError.new(
883
- "Could not find RubyGem #{gem.name} (#{gem.requirement})\n")
884
- else
885
- error = Gem::LoadError.new(
886
- "RubyGem version error: " +
887
- "#{gem.name}(#{matches.first.version} not #{gem.requirement})\n")
888
- end
889
-
890
- error.name = gem.name
891
- error.requirement = gem.requirement
892
- raise error
893
- end
894
-
895
- private_class_method :report_activate_error
896
-
897
- ##
898
- # Full path to +libfile+ in +gemname+. Searches for the latest gem unless
899
- # +requirements+ is given.
900
-
901
- def self.required_location(gemname, libfile, *requirements)
902
- requirements = Gem::Requirement.default if requirements.empty?
903
-
904
- matches = Gem::Specification.find_all_by_name gemname, *requirements
905
-
906
- return nil if matches.empty?
907
-
908
- spec = matches.last
909
- spec.require_paths.each do |path|
910
- result = Gem::Path.path(spec.full_gem_path).add(path, libfile)
911
- return result if result.exist?
912
- end
913
-
914
- nil
915
- end
916
-
917
739
  ##
918
740
  # The path to the running Ruby interpreter.
919
741
 
@@ -928,6 +750,7 @@ module Gem
928
750
  @ruby
929
751
  end
930
752
 
753
+ # DOC: needs doc'd or :nodoc'd
931
754
  def self.latest_spec_for name
932
755
  dependency = Gem::Dependency.new name
933
756
  fetcher = Gem::SpecFetcher.fetcher
@@ -942,13 +765,16 @@ module Gem
942
765
  match and fetcher.fetch_spec(*match)
943
766
  end
944
767
 
768
+ # DOC: needs doc'd or :nodoc'd
945
769
  def self.latest_version_for name
946
770
  spec = latest_spec_for name
947
771
  spec and spec.version
948
772
  end
949
773
 
774
+ # DOC: needs doc'd or :nodoc'd
950
775
  def self.latest_rubygems_version
951
- latest_version_for "rubygems-update"
776
+ latest_version_for("rubygems-update") or
777
+ raise "Can't find 'rubygems-update' in any repo. Check `gem source list`."
952
778
  end
953
779
 
954
780
  ##
@@ -968,36 +794,34 @@ module Gem
968
794
  end
969
795
 
970
796
  ##
971
- # The GemPathSearcher object used to search for matching installed gems.
972
-
973
- def self.searcher
974
- @searcher ||= Gem::GemPathSearcher.new
975
- end
976
-
977
- ##
978
- # Returns the Gem::SourceIndex of specifications that are in the Gem.path
797
+ # A Gem::Version for the currently running RubyGems
979
798
 
980
- def self.source_index
981
- @@source_index ||= Gem::Deprecate.skip_during do
982
- SourceIndex.new Gem::Specification.dirs
983
- end
799
+ def self.rubygems_version
800
+ return @rubygems_version if defined? @rubygems_version
801
+ @rubygems_version = Gem::Version.new Gem::VERSION
984
802
  end
985
803
 
986
804
  ##
987
- # Returns an Array of sources to fetch remote gems from. If the sources
988
- # list is empty, attempts to load the "sources" gem, then uses
989
- # default_sources if it is not installed.
805
+ # Returns an Array of sources to fetch remote gems from. Uses
806
+ # default_sources if the sources list is empty.
990
807
 
991
808
  def self.sources
992
- @sources ||= default_sources
809
+ @sources ||= Gem::SourceList.from(default_sources)
993
810
  end
994
811
 
995
812
  ##
996
813
  # Need to be able to set the sources without calling
997
814
  # Gem.sources.replace since that would cause an infinite loop.
815
+ #
816
+ # DOC: This comment is not documentation about the method itself, it's
817
+ # more of a code comment about the implementation.
998
818
 
999
819
  def self.sources= new_sources
1000
- @sources = new_sources
820
+ if !new_sources
821
+ @sources = nil
822
+ else
823
+ @sources = Gem::SourceList.from(new_sources)
824
+ end
1001
825
  end
1002
826
 
1003
827
  ##
@@ -1007,12 +831,6 @@ module Gem
1007
831
  @suffix_pattern ||= "{#{suffixes.join(',')}}"
1008
832
  end
1009
833
 
1010
- def self.loaded_path? path
1011
- # TODO: ruby needs a feature to let us query what's loaded in 1.8 and 1.9
1012
- re = /(^|\/)#{Regexp.escape path}#{Regexp.union(*Gem.suffixes)}$/
1013
- $LOADED_FEATURES.any? { |s| s =~ re }
1014
- end
1015
-
1016
834
  ##
1017
835
  # Suffixes for require-able paths.
1018
836
 
@@ -1067,7 +885,7 @@ module Gem
1067
885
  # The home directory for the user.
1068
886
 
1069
887
  def self.user_home
1070
- @user_home ||= find_home
888
+ @user_home ||= find_home.untaint
1071
889
  end
1072
890
 
1073
891
  ##
@@ -1126,6 +944,9 @@ module Gem
1126
944
  load_plugin_files files
1127
945
  end
1128
946
 
947
+ # FIX: Almost everywhere else we use the `def self.` way of defining class
948
+ # methods, and then we switch over to `class << self` here. Pick one or the
949
+ # other.
1129
950
  class << self
1130
951
 
1131
952
  ##
@@ -1134,29 +955,73 @@ module Gem
1134
955
  attr_reader :loaded_specs
1135
956
 
1136
957
  ##
1137
- # The list of hooks to be run before Gem::Install#install finishes
1138
- # installation
958
+ # Register a Gem::Specification for default gem
959
+
960
+ def register_default_spec(spec)
961
+ spec.files.each do |file|
962
+ @path_to_default_spec_map[file] = spec
963
+ end
964
+ end
965
+
966
+ ##
967
+ # Find a Gem::Specification of default gem from +path+
968
+
969
+ def find_unresolved_default_spec(path)
970
+ Gem.suffixes.each do |suffix|
971
+ spec = @path_to_default_spec_map["#{path}#{suffix}"]
972
+ return spec if spec
973
+ end
974
+ nil
975
+ end
976
+
977
+ ##
978
+ # Remove needless Gem::Specification of default gem from
979
+ # unresolved default gem list
980
+
981
+ def remove_unresolved_default_spec(spec)
982
+ spec.files.each do |file|
983
+ @path_to_default_spec_map.delete(file)
984
+ end
985
+ end
986
+
987
+ ##
988
+ # Clear default gem related varibles. It is for test
989
+
990
+ def clear_default_specs
991
+ @path_to_default_spec_map.clear
992
+ end
993
+
994
+ ##
995
+ # The list of hooks to be run after Gem::Installer#install extracts files
996
+ # and builds extensions
1139
997
 
1140
998
  attr_reader :post_build_hooks
1141
999
 
1142
1000
  ##
1143
- # The list of hooks to be run before Gem::Install#install does any work
1001
+ # The list of hooks to be run after Gem::Installer#install completes
1002
+ # installation
1144
1003
 
1145
1004
  attr_reader :post_install_hooks
1146
1005
 
1006
+ ##
1007
+ # The list of hooks to be run after Gem::DependencyInstaller installs a
1008
+ # set of gems
1009
+
1010
+ attr_reader :done_installing_hooks
1011
+
1147
1012
  ##
1148
1013
  # The list of hooks to be run after Gem::Specification.reset is run.
1149
1014
 
1150
1015
  attr_reader :post_reset_hooks
1151
1016
 
1152
1017
  ##
1153
- # The list of hooks to be run before Gem::Uninstall#uninstall does any
1154
- # work
1018
+ # The list of hooks to be run after Gem::Uninstaller#uninstall completes
1019
+ # installation
1155
1020
 
1156
1021
  attr_reader :post_uninstall_hooks
1157
1022
 
1158
1023
  ##
1159
- # The list of hooks to be run after Gem::Install#install is finished
1024
+ # The list of hooks to be run before Gem::Installer#install does any work
1160
1025
 
1161
1026
  attr_reader :pre_install_hooks
1162
1027
 
@@ -1166,95 +1031,37 @@ module Gem
1166
1031
  attr_reader :pre_reset_hooks
1167
1032
 
1168
1033
  ##
1169
- # The list of hooks to be run after Gem::Uninstall#uninstall is finished
1034
+ # The list of hooks to be run before Gem::Uninstaller#uninstall does any
1035
+ # work
1170
1036
 
1171
1037
  attr_reader :pre_uninstall_hooks
1172
1038
  end
1173
1039
 
1174
- def self.cache # :nodoc:
1175
- source_index
1176
- end
1177
-
1178
1040
  ##
1179
1041
  # Location of Marshal quick gemspecs on remote repositories
1180
1042
 
1181
1043
  MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
1182
1044
 
1183
- autoload :Version, 'rubygems/version'
1184
- autoload :Requirement, 'rubygems/requirement'
1185
- autoload :Dependency, 'rubygems/dependency'
1186
- autoload :DependencyList, 'rubygems/dependency_list'
1187
- autoload :GemPathSearcher, 'rubygems/gem_path_searcher'
1188
- autoload :SpecFetcher, 'rubygems/spec_fetcher'
1189
- autoload :Specification, 'rubygems/specification'
1190
- autoload :Cache, 'rubygems/source_index'
1191
- autoload :SourceIndex, 'rubygems/source_index'
1192
- autoload :PathSupport, 'rubygems/path_support'
1193
- autoload :Platform, 'rubygems/platform'
1194
- autoload :Builder, 'rubygems/builder'
1195
- autoload :ConfigFile, 'rubygems/config_file'
1196
- end
1197
-
1198
- module Kernel
1199
-
1200
- remove_method :gem if 'method' == defined? gem # from gem_prelude.rb on 1.9
1201
-
1202
- ##
1203
- # Use Kernel#gem to activate a specific version of +gem_name+.
1204
- #
1205
- # +requirements+ is a list of version requirements that the
1206
- # specified gem must match, most commonly "= example.version.number". See
1207
- # Gem::Requirement for how to specify a version requirement.
1208
- #
1209
- # If you will be activating the latest version of a gem, there is no need to
1210
- # call Kernel#gem, Kernel#require will do the right thing for you.
1211
- #
1212
- # Kernel#gem returns true if the gem was activated, otherwise false. If the
1213
- # gem could not be found, didn't match the version requirements, or a
1214
- # different version was already activated, an exception will be raised.
1215
- #
1216
- # Kernel#gem should be called *before* any require statements (otherwise
1217
- # RubyGems may load a conflicting library version).
1218
- #
1219
- # In older RubyGems versions, the environment variable GEM_SKIP could be
1220
- # used to skip activation of specified gems, for example to test out changes
1221
- # that haven't been installed yet. Now RubyGems defers to -I and the
1222
- # RUBYLIB environment variable to skip activation of a gem.
1223
- #
1224
- # Example:
1225
- #
1226
- # GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
1227
-
1228
- def gem(gem_name, *requirements) # :doc:
1229
- skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
1230
- raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
1231
- spec = Gem::Dependency.new(gem_name, *requirements).to_spec
1232
- spec.activate if spec
1233
- end
1234
-
1235
- private :gem
1236
-
1237
- end
1238
-
1239
- ##
1240
- # Return the path to the data directory associated with the named package. If
1241
- # the package is loaded as a gem, return the gem specific data directory.
1242
- # Otherwise return a path to the share area as define by
1243
- # "#{ConfigMap[:datadir]}/#{package_name}".
1244
-
1245
- def RbConfig.datadir(package_name) # :nodoc:
1246
- warn "#{Gem.location_of_caller.join ':'}:Warning: " \
1247
- "RbConfig.datadir is deprecated and will be removed on or after " \
1248
- "August 2011. " \
1249
- "Use Gem::datadir."
1250
-
1251
- require 'rbconfig/datadir'
1252
-
1253
- Gem.datadir(package_name) || File.join(Gem::ConfigMap[:datadir], package_name)
1045
+ autoload :ConfigFile, 'rubygems/config_file'
1046
+ autoload :Dependency, 'rubygems/dependency'
1047
+ autoload :DependencyList, 'rubygems/dependency_list'
1048
+ autoload :DependencyResolver, 'rubygems/dependency_resolver'
1049
+ autoload :PathSupport, 'rubygems/path_support'
1050
+ autoload :Platform, 'rubygems/platform'
1051
+ autoload :RequestSet, 'rubygems/request_set'
1052
+ autoload :Requirement, 'rubygems/requirement'
1053
+ autoload :SourceList, 'rubygems/source_list'
1054
+ autoload :SpecFetcher, 'rubygems/spec_fetcher'
1055
+ autoload :Specification, 'rubygems/specification'
1056
+ autoload :Version, 'rubygems/version'
1057
+ autoload :Source, 'rubygems/source'
1058
+
1059
+ require "rubygems/specification"
1254
1060
  end
1255
1061
 
1256
1062
  require 'rubygems/exceptions'
1257
1063
 
1064
+ # REFACTOR: This should be pulled out into some kind of hacks file.
1258
1065
  gem_preluded = Gem::GEM_PRELUDE_SUCKAGE and defined? Gem
1259
1066
  unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
1260
1067
  begin
@@ -1277,29 +1084,10 @@ unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
1277
1084
  end
1278
1085
 
1279
1086
  ##
1280
- # Enables the require hook for RubyGems.
1087
+ # Loads the default specs.
1088
+ Gem::Specification.load_defaults
1281
1089
 
1282
- require 'rubygems/custom_require'
1090
+ require 'rubygems/core_ext/kernel_gem'
1091
+ require 'rubygems/core_ext/kernel_require'
1283
1092
 
1284
- module Gem
1285
- class << self
1286
- extend Gem::Deprecate
1287
- deprecate :activate_dep, "Specification#activate", 2011, 6
1288
- deprecate :activate_spec, "Specification#activate", 2011, 6
1289
- deprecate :cache, "Gem::source_index", 2011, 8
1290
- deprecate :activate, "Specification#activate", 2011, 10
1291
- deprecate :all_load_paths, :none, 2011, 10
1292
- deprecate :all_partials, :none, 2011, 10
1293
- deprecate :latest_load_paths, :none, 2011, 10
1294
- deprecate :promote_load_path, :none, 2011, 10
1295
- deprecate :available?, "Specification::find_by_name", 2011, 11
1296
- deprecate :cache_dir, "Specification#cache_dir", 2011, 11
1297
- deprecate :cache_gem, "Specification#cache_file", 2011, 11
1298
- deprecate :default_system_source_cache_dir, :none, 2011, 11
1299
- deprecate :default_user_source_cache_dir, :none, 2011, 11
1300
- deprecate :report_activate_error, :none, 2011, 11
1301
- deprecate :required_location, :none, 2011, 11
1302
- deprecate :searcher, "Specification", 2011, 11
1303
- deprecate :source_index, "Specification", 2011, 11
1304
- end
1305
- end
1093
+ Gem.detect_gemdeps