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
@@ -24,11 +24,17 @@ class Gem::FakeFetcher
24
24
 
25
25
  attr_reader :data
26
26
  attr_reader :last_request
27
+ attr_reader :api_endpoints
27
28
  attr_accessor :paths
28
29
 
29
30
  def initialize
30
31
  @data = {}
31
32
  @paths = []
33
+ @api_endpoints = {}
34
+ end
35
+
36
+ def api_endpoint(uri)
37
+ @api_endpoints[uri] || uri
32
38
  end
33
39
 
34
40
  def find_data(path)
@@ -57,6 +63,15 @@ class Gem::FakeFetcher
57
63
  end
58
64
  end
59
65
 
66
+ def cache_update_path uri, path = nil
67
+ if data = fetch_path(uri)
68
+ open(path, 'wb') { |io| io.write data } if path
69
+ data
70
+ else
71
+ Gem.read_binary(path) if path
72
+ end
73
+ end
74
+
60
75
  # Thanks, FakeWeb!
61
76
  def open_uri_or_path(path)
62
77
  data = find_data(path)
@@ -98,7 +113,13 @@ class Gem::FakeFetcher
98
113
 
99
114
  def download spec, source_uri, install_dir = Gem.dir
100
115
  name = File.basename spec.cache_file
101
- path = File.join install_dir, "cache", name
116
+ path = if Dir.pwd == install_dir then # see fetch_command
117
+ install_dir
118
+ else
119
+ File.join install_dir, "cache"
120
+ end
121
+
122
+ path = File.join path, name
102
123
 
103
124
  Gem.ensure_gem_subdirectories install_dir
104
125
 
@@ -114,14 +135,13 @@ class Gem::FakeFetcher
114
135
  end
115
136
 
116
137
  def download_to_cache dependency
117
- found = Gem::SpecFetcher.fetcher.fetch dependency, true, true,
118
- dependency.prerelease?
138
+ found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dependency
119
139
 
120
140
  return if found.empty?
121
141
 
122
- spec, source_uri = found.first
142
+ spec, source = found.first
123
143
 
124
- download spec, source_uri
144
+ download spec, source.uri.to_s
125
145
  end
126
146
 
127
147
  end
@@ -7,7 +7,7 @@
7
7
  require 'fileutils'
8
8
  require 'rubygems'
9
9
  require 'rubygems/dependency_list'
10
- require 'rubygems/doc_manager'
10
+ require 'rubygems/rdoc'
11
11
  require 'rubygems/user_interaction'
12
12
 
13
13
  ##
@@ -42,6 +42,7 @@ class Gem::Uninstaller
42
42
  # Constructs an uninstaller that will uninstall +gem+
43
43
 
44
44
  def initialize(gem, options = {})
45
+ # TODO document the valid options
45
46
  @gem = gem
46
47
  @version = options[:version] || Gem::Requirement.default
47
48
  @gem_home = File.expand_path(options[:install_dir] || Gem.dir)
@@ -51,15 +52,19 @@ class Gem::Uninstaller
51
52
  @bin_dir = options[:bin_dir]
52
53
  @format_executable = options[:format_executable]
53
54
 
55
+ # Indicate if development dependencies should be checked when
56
+ # uninstalling. (default: false)
57
+ #
58
+ @check_dev = options[:check_dev]
59
+
60
+ if options[:force]
61
+ @force_all = true
62
+ @force_ignore = true
63
+ end
64
+
54
65
  # only add user directory if install_dir is not set
55
66
  @user_install = false
56
67
  @user_install = options[:user_install] unless options[:install_dir]
57
-
58
- if @user_install then
59
- Gem.use_paths Gem.user_dir, @gem_home
60
- else
61
- Gem.use_paths @gem_home
62
- end
63
68
  end
64
69
 
65
70
  ##
@@ -69,10 +74,36 @@ class Gem::Uninstaller
69
74
  def uninstall
70
75
  list = Gem::Specification.find_all_by_name(@gem, @version)
71
76
 
77
+ default_specs, list = list.partition do |spec|
78
+ spec.default_gem?
79
+ end
80
+
81
+ list, other_repo_specs = list.partition do |spec|
82
+ @gem_home == spec.base_dir or
83
+ (@user_install and spec.base_dir == Gem.user_dir)
84
+ end
85
+
72
86
  if list.empty? then
73
- raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
87
+ if other_repo_specs.empty?
88
+ if default_specs.empty?
89
+ raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
90
+ else
91
+ message =
92
+ "gem #{@gem.inspect} cannot be uninstalled " +
93
+ "because it is a default gem"
94
+ raise Gem::InstallError, message
95
+ end
96
+ end
97
+
98
+ other_repos = other_repo_specs.map { |spec| spec.base_dir }.uniq
74
99
 
75
- elsif list.size > 1 and @force_all then
100
+ message = ["#{@gem} is not installed in GEM_HOME, try:"]
101
+ message.concat other_repos.map { |repo|
102
+ "\tgem uninstall -i #{repo} #{@gem}"
103
+ }
104
+
105
+ raise Gem::InstallError, message.join("\n")
106
+ elsif @force_all then
76
107
  remove_all list
77
108
 
78
109
  elsif list.size > 1 then
@@ -127,12 +158,15 @@ class Gem::Uninstaller
127
158
  def remove_executables(spec)
128
159
  return if spec.nil? or spec.executables.empty?
129
160
 
161
+ executables = spec.executables.clone
162
+
163
+ # Leave any executables created by other installed versions
164
+ # of this gem installed.
165
+
130
166
  list = Gem::Specification.find_all { |s|
131
167
  s.name == spec.name && s.version != spec.version
132
168
  }
133
169
 
134
- executables = spec.executables.clone
135
-
136
170
  list.each do |s|
137
171
  s.executables.each do |exe_name|
138
172
  executables.delete exe_name
@@ -152,9 +186,7 @@ class Gem::Uninstaller
152
186
  @force_executables
153
187
  end
154
188
 
155
- unless remove then
156
- say "Executables and scripts will remain installed."
157
- else
189
+ if remove then
158
190
  bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
159
191
 
160
192
  raise Gem::FilePermissionError, bin_dir unless File.writable? bin_dir
@@ -167,6 +199,8 @@ class Gem::Uninstaller
167
199
  FileUtils.rm_f exe_file
168
200
  FileUtils.rm_f "#{exe_file}.bat"
169
201
  end
202
+ else
203
+ say "Executables and scripts will remain installed."
170
204
  end
171
205
  end
172
206
 
@@ -220,7 +254,7 @@ class Gem::Uninstaller
220
254
 
221
255
  FileUtils.rm_rf gem
222
256
 
223
- Gem::DocManager.new(spec).uninstall_doc
257
+ Gem::RDoc.new(spec).remove
224
258
 
225
259
  say "Successfully uninstalled #{spec.full_name}"
226
260
 
@@ -241,26 +275,34 @@ class Gem::Uninstaller
241
275
  return true if @force_ignore
242
276
 
243
277
  deplist = Gem::DependencyList.from_specs
244
- deplist.ok_to_remove?(spec.full_name)
278
+ deplist.ok_to_remove?(spec.full_name, @check_dev)
245
279
  end
246
280
 
247
281
  def ask_if_ok(spec)
248
282
  msg = ['']
249
283
  msg << 'You have requested to uninstall the gem:'
250
284
  msg << "\t#{spec.full_name}"
285
+ msg << ''
286
+
287
+ siblings = Gem::Specification.select do |s|
288
+ s.name == spec.name && s.full_name != spec.full_name
289
+ end
251
290
 
252
291
  spec.dependent_gems.each do |dep_spec, dep, satlist|
253
- msg <<
254
- ("#{dep_spec.name}-#{dep_spec.version} depends on " +
255
- "[#{dep.name} (#{dep.requirement})]")
292
+ unless siblings.any? { |s| s.satisfies_requirement? dep }
293
+ msg << "#{dep_spec.name}-#{dep_spec.version} depends on #{dep}"
294
+ end
256
295
  end
257
296
 
258
- msg << 'If you remove this gems, one or more dependencies will not be met.'
297
+ msg << 'If you remove this gem, these dependencies will not be met.'
259
298
  msg << 'Continue with Uninstall?'
260
299
  return ask_yes_no(msg.join("\n"), true)
261
300
  end
262
301
 
263
302
  def formatted_program_filename(filename)
303
+ # TODO perhaps the installer should leave a small manifest
304
+ # of what it did for us to find rather than trying to recreate
305
+ # it again.
264
306
  if @format_executable then
265
307
  require 'rubygems/installer'
266
308
  Gem::Installer.exec_format % File.basename(filename)
@@ -143,6 +143,16 @@ class Gem::StreamUI
143
143
  end
144
144
  end
145
145
 
146
+ ##
147
+ # Prints a formatted backtrace to the errors stream if backtraces are
148
+ # enabled.
149
+
150
+ def backtrace exception
151
+ return unless Gem.configuration.backtrace
152
+
153
+ @errs.puts "\t#{exception.backtrace.join "\n\t"}"
154
+ end
155
+
146
156
  ##
147
157
  # Choose from a list of options. +question+ is a prompt displayed above
148
158
  # the list. +list+ is a list of option strings. Returns the pair
@@ -4,7 +4,7 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- require 'rubygems/format'
7
+ require 'rubygems/package'
8
8
  require 'rubygems/installer'
9
9
 
10
10
  ##
@@ -16,7 +16,6 @@ class Gem::Validator
16
16
 
17
17
  def initialize
18
18
  require 'find'
19
- require 'digest'
20
19
  end
21
20
 
22
21
  ##
@@ -24,20 +23,8 @@ class Gem::Validator
24
23
  # gem_data:: [String] Contents of the gem file
25
24
 
26
25
  def verify_gem(gem_data)
27
- raise Gem::VerificationError, 'empty gem file' if gem_data.size == 0
28
-
29
- unless gem_data =~ /MD5SUM/ then
30
- return # Don't worry about it...this sucks. Need to fix MD5 stuff for
31
- # new format
32
- # FIXME
33
- end
34
-
35
- sum_data = gem_data.gsub(/MD5SUM = "([a-z0-9]+)"/,
36
- "MD5SUM = \"#{"F" * 32}\"")
37
-
38
- unless Digest::MD5.hexdigest(sum_data) == $1.to_s then
39
- raise Gem::VerificationError, 'invalid checksum for gem file'
40
- end
26
+ # TODO remove me? The code here only validate an MD5SUM that was
27
+ # in some old formatted gems, but hasn't been for a long time.
41
28
  end
42
29
 
43
30
  ##
@@ -58,17 +45,27 @@ class Gem::Validator
58
45
 
59
46
  def find_files_for_gem(gem_directory)
60
47
  installed_files = []
48
+
61
49
  Find.find gem_directory do |file_name|
62
50
  fn = file_name[gem_directory.size..file_name.size-1].sub(/^\//, "")
63
51
  installed_files << fn unless
64
52
  fn =~ /CVS/ || fn.empty? || File.directory?(file_name)
65
53
  end
54
+
66
55
  installed_files
67
56
  end
68
57
 
69
58
  public
70
59
 
71
- ErrorData = Struct.new :path, :problem
60
+ ErrorData = Struct.new :path, :problem do
61
+
62
+ def <=> other
63
+ return nil unless self.class === other
64
+
65
+ [path, problem] <=> [other.path, other.problem]
66
+ end
67
+
68
+ end
72
69
 
73
70
  ##
74
71
  # Checks the gem directory for the following potential
@@ -80,20 +77,22 @@ class Gem::Validator
80
77
  # * 1 cache - 1 spec - 1 directory.
81
78
  #
82
79
  # returns a hash of ErrorData objects, keyed on the problem gem's name.
80
+ #--
81
+ # TODO needs further cleanup
83
82
 
84
83
  def alien(gems=[])
85
84
  errors = Hash.new { |h,k| h[k] = {} }
86
85
 
87
- Gem::SourceIndex.from_installed_gems.each do |gem_name, gem_spec|
88
- next unless gems.include? gem_spec.name unless gems.empty?
86
+ Gem::Specification.each do |spec|
87
+ next unless gems.include? spec.name unless gems.empty?
89
88
 
90
- install_dir = gem_spec.installation_path
91
- gem_path = Gem.cache_gem(gem_spec.file_name, install_dir)
92
- spec_path = File.join install_dir, "specifications", gem_spec.spec_name
93
- gem_directory = gem_spec.full_gem_path
89
+ gem_name = spec.file_name
90
+ gem_path = spec.cache_file
91
+ spec_path = spec.spec_file
92
+ gem_directory = spec.full_gem_path
94
93
 
95
94
  unless File.directory? gem_directory then
96
- errors[gem_name][gem_spec.full_name] =
95
+ errors[gem_name][spec.full_name] =
97
96
  "Gem registered but doesn't exist at #{gem_directory}"
98
97
  next
99
98
  end
@@ -108,19 +107,18 @@ class Gem::Validator
108
107
  good, gone, unreadable = nil, nil, nil, nil
109
108
 
110
109
  open gem_path, Gem.binary_mode do |file|
111
- format = Gem::Format.from_file_by_path(gem_path)
110
+ package = Gem::Package.new gem_path
112
111
 
113
- good, gone = format.file_entries.partition { |entry, _|
114
- File.exist? File.join(gem_directory, entry['path'])
112
+ good, gone = package.contents.partition { |file_name|
113
+ File.exist? File.join(gem_directory, file_name)
115
114
  }
116
115
 
117
- gone.map! { |entry, _| entry['path'] }
118
116
  gone.sort.each do |path|
119
117
  errors[gem_name][path] = "Missing file"
120
118
  end
121
119
 
122
- good, unreadable = good.partition { |entry, _|
123
- File.readable? File.join(gem_directory, entry['path'])
120
+ good, unreadable = good.partition { |file_name|
121
+ File.readable? File.join(gem_directory, file_name)
124
122
  }
125
123
 
126
124
  unreadable.map! { |entry, _| entry['path'] }
@@ -132,9 +130,10 @@ class Gem::Validator
132
130
  begin
133
131
  next unless data # HACK `gem check -a mkrf`
134
132
 
135
- open File.join(gem_directory, entry['path']), Gem.binary_mode do |f|
136
- unless Digest::MD5.hexdigest(f.read).to_s ==
137
- Digest::MD5.hexdigest(data).to_s then
133
+ source = File.join gem_directory, entry['path']
134
+
135
+ open source, Gem.binary_mode do |f|
136
+ unless f.read == data then
138
137
  errors[gem_name][entry['path']] = "Modified from original"
139
138
  end
140
139
  end
@@ -143,7 +142,6 @@ class Gem::Validator
143
142
  end
144
143
 
145
144
  installed_files = find_files_for_gem(gem_directory)
146
- good.map! { |entry, _| entry['path'] }
147
145
  extras = installed_files - good - unreadable
148
146
 
149
147
  extras.each do |extra|
@@ -155,15 +153,10 @@ class Gem::Validator
155
153
  end
156
154
 
157
155
  errors.each do |name, subhash|
158
- errors[name] = subhash.map { |path, msg| ErrorData.new(path, msg) }
156
+ errors[name] = subhash.map { |path, msg| ErrorData.new(path, msg) }.sort
159
157
  end
160
158
 
161
159
  errors
162
160
  end
163
-
164
- def remove_leading_dot_dir(path)
165
- path.sub(/^\.\//, "")
166
- end
167
-
168
161
  end
169
162
 
@@ -129,8 +129,8 @@
129
129
  # specify your dependency as ">= 2.0.0" then, you're good, right? What
130
130
  # happens if fnord 3.0 comes out and it isn't backwards compatible
131
131
  # with 2.y.z? Your stuff will break as a result of using ">=". The
132
- # better route is to specify your dependency with a "spermy" version
133
- # specifier. They're a tad confusing, so here is how the dependency
132
+ # better route is to specify your dependency with an "approximate" version
133
+ # specifier ("~>"). They're a tad confusing, so here is how the dependency
134
134
  # specifiers work:
135
135
  #
136
136
  # Specification From ... To (exclusive)
@@ -145,8 +145,10 @@ class Gem::Version
145
145
 
146
146
  include Comparable
147
147
 
148
- VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*' # :nodoc:
149
- ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/ # :nodoc:
148
+ # FIX: These are only used once, in .correct?. Do they deserve to be
149
+ # constants?
150
+ VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
151
+ ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/ # :nodoc:
150
152
 
151
153
  ##
152
154
  # A string representation of this Version.
@@ -169,6 +171,8 @@ class Gem::Version
169
171
  # ver2 = Version.create(ver1) # -> (ver1)
170
172
  # ver3 = Version.create(nil) # -> nil
171
173
 
174
+ # REFACTOR: There's no real reason this should be separate from #initialize.
175
+
172
176
  def self.create input
173
177
  if input.respond_to? :version then
174
178
  input
@@ -187,8 +191,7 @@ class Gem::Version
187
191
  raise ArgumentError, "Malformed version number string #{version}" unless
188
192
  self.class.correct?(version)
189
193
 
190
- @version = version.to_s.dup
191
- @version.strip!
194
+ @version = version.to_s.dup.strip
192
195
  end
193
196
 
194
197
  ##
@@ -248,11 +251,19 @@ class Gem::Version
248
251
  @hash = nil
249
252
  end
250
253
 
254
+ def to_yaml_properties
255
+ ["@version"]
256
+ end
257
+
258
+ def encode_with coder
259
+ coder.add 'version', @version
260
+ end
261
+
251
262
  ##
252
263
  # A version is considered a prerelease if it contains a letter.
253
264
 
254
265
  def prerelease?
255
- @prerelease ||= @version =~ /[a-zA-Z]/
266
+ @prerelease ||= !!(@version =~ /[a-zA-Z]/)
256
267
  end
257
268
 
258
269
  def pretty_print q # :nodoc:
@@ -284,7 +295,7 @@ class Gem::Version
284
295
  ##
285
296
  # A recommended version for use with a ~> Requirement.
286
297
 
287
- def spermy_recommendation
298
+ def approximate_recommendation
288
299
  segments = self.segments.dup
289
300
 
290
301
  segments.pop while segments.any? { |s| String === s }