rubygems-update 1.8.30 → 2.0.0.preview2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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,82 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require 'rubygems/package'
8
-
9
- ##
10
- # Gem::Format knows the guts of the RubyGem .gem file format and provides the
11
- # capability to read gem files
12
-
13
- class Gem::Format
14
-
15
- attr_accessor :spec
16
- attr_accessor :file_entries
17
- attr_accessor :gem_path
18
-
19
- ##
20
- # Constructs a Format representing the gem's data which came from +gem_path+
21
-
22
- def initialize(gem_path)
23
- @gem_path = gem_path
24
- end
25
-
26
- ##
27
- # Reads the gem +file_path+ using +security_policy+ and returns a Format
28
- # representing the data in the gem
29
-
30
- def self.from_file_by_path(file_path, security_policy = nil)
31
- unless File.file?(file_path)
32
- raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
33
- end
34
-
35
- start = File.read file_path, 20
36
-
37
- if start.nil? or start.length < 20 then
38
- nil
39
- elsif start.include?("MD5SUM =") # old version gems
40
- require 'rubygems/old_format'
41
-
42
- Gem::OldFormat.from_file_by_path file_path
43
- else
44
- begin
45
- open file_path, Gem.binary_mode do |io|
46
- from_io io, file_path, security_policy
47
- end
48
- rescue Gem::Package::TarInvalidError => e
49
- message = "corrupt gem (#{e.class}: #{e.message})"
50
- raise Gem::Package::FormatError.new(message, file_path)
51
- end
52
- end
53
- end
54
-
55
- ##
56
- # Reads a gem from +io+ at +gem_path+ using +security_policy+ and returns a
57
- # Format representing the data from the gem
58
-
59
- def self.from_io(io, gem_path="(io)", security_policy = nil)
60
- format = new gem_path
61
-
62
- Gem::Package.open io, 'r', security_policy do |pkg|
63
- format.spec = pkg.metadata
64
- format.file_entries = []
65
-
66
- pkg.each do |entry|
67
- size = entry.header.size
68
- mode = entry.header.mode
69
-
70
- format.file_entries << [{
71
- "size" => size, "mode" => mode, "path" => entry.full_name,
72
- },
73
- entry.read
74
- ]
75
- end
76
- end
77
-
78
- format
79
- end
80
-
81
- end
82
-
@@ -1,90 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- #--
8
- # Some system might not have OpenSSL installed, therefore the core
9
- # library file openssl might not be available. We localize testing
10
- # for the presence of OpenSSL in this file.
11
- #++
12
-
13
- module Gem
14
- class << self
15
- ##
16
- # Is SSL (used by the signing commands) available on this
17
- # platform?
18
-
19
- def ssl_available?
20
- @ssl_available
21
- end
22
-
23
- ##
24
- # Is SSL available?
25
-
26
- attr_writer :ssl_available
27
-
28
- ##
29
- # Ensure that SSL is available. Throw an exception if it is not.
30
-
31
- def ensure_ssl_available
32
- unless ssl_available?
33
- raise Gem::Exception, "SSL is not installed on this system"
34
- end
35
- end
36
- end
37
- end
38
-
39
- # :stopdoc:
40
-
41
- begin
42
- require 'openssl'
43
-
44
- # Reference a constant defined in the .rb portion of ssl (just to
45
- # make sure that part is loaded too).
46
-
47
- Gem.ssl_available = !!OpenSSL::Digest::SHA1
48
-
49
- class OpenSSL::X509::Certificate
50
- # Check the validity of this certificate.
51
- def check_validity(issuer_cert = nil, time = Time.now)
52
- ret = if @not_before && @not_before > time
53
- [false, :expired, "not valid before '#@not_before'"]
54
- elsif @not_after && @not_after < time
55
- [false, :expired, "not valid after '#@not_after'"]
56
- elsif issuer_cert && !verify(issuer_cert.public_key)
57
- [false, :issuer, "#{issuer_cert.subject} is not issuer"]
58
- else
59
- [true, :ok, 'Valid certificate']
60
- end
61
-
62
- # return hash
63
- { :is_valid => ret[0], :error => ret[1], :desc => ret[2] }
64
- end
65
- end
66
-
67
- rescue LoadError, StandardError
68
- Gem.ssl_available = false
69
- end
70
-
71
- module Gem::SSL
72
-
73
- # We make our own versions of the constants here. This allows us
74
- # to reference the constants, even though some systems might not
75
- # have SSL installed in the Ruby core package.
76
- #
77
- # These constants are only used during load time. At runtime, any
78
- # method that makes a direct reference to SSL software must be
79
- # protected with a Gem.ensure_ssl_available call.
80
-
81
- if Gem.ssl_available? then
82
- PKEY_RSA = OpenSSL::PKey::RSA
83
- DIGEST_SHA1 = OpenSSL::Digest::SHA1
84
- else
85
- PKEY_RSA = :rsa
86
- DIGEST_SHA1 = :sha1
87
- end
88
-
89
- end
90
-
@@ -1,172 +0,0 @@
1
- require "rubygems"
2
- require "rubygems/deprecate"
3
-
4
- ##
5
- # GemPathSearcher has the capability to find loadable files inside
6
- # gems. It generates data up front to speed up searches later.
7
-
8
- class Gem::GemPathSearcher
9
-
10
- ##
11
- # Initialise the data we need to make searches later.
12
-
13
- def initialize
14
- # We want a record of all the installed gemspecs, in the order we wish to
15
- # examine them.
16
- # TODO: remove this stupid method
17
- @gemspecs = init_gemspecs
18
-
19
- # Map gem spec to glob of full require_path directories. Preparing this
20
- # information may speed up searches later.
21
- @lib_dirs = {}
22
-
23
- @gemspecs.each do |spec|
24
- @lib_dirs[spec.object_id] = lib_dirs_for spec
25
- end
26
- end
27
-
28
- ##
29
- # Look in all the installed gems until a matching +glob+ is found.
30
- # Return the _gemspec_ of the gem where it was found. If no match
31
- # is found, return nil.
32
- #
33
- # The gems are searched in alphabetical order, and in reverse
34
- # version order.
35
- #
36
- # For example:
37
- #
38
- # find('log4r') # -> (log4r-1.1 spec)
39
- # find('log4r.rb') # -> (log4r-1.1 spec)
40
- # find('rake/rdoctask') # -> (rake-0.4.12 spec)
41
- # find('foobarbaz') # -> nil
42
- #
43
- # Matching paths can have various suffixes ('.rb', '.so', and
44
- # others), which may or may not already be attached to _file_.
45
- # This method doesn't care about the full filename that matches;
46
- # only that there is a match.
47
-
48
- def find(glob)
49
- # HACK violation of encapsulation
50
- @gemspecs.find do |spec|
51
- # TODO: inverted responsibility
52
- matching_file? spec, glob
53
- end
54
- end
55
-
56
- # Looks through the available gemspecs and finds the first
57
- # one that contains +file+ as a requirable file.
58
-
59
- def find_spec_for_file(file)
60
- @gemspecs.find do |spec|
61
- return spec if spec.contains_requirable_file?(file)
62
- end
63
- end
64
-
65
- def find_active(glob)
66
- # HACK violation of encapsulation
67
- @gemspecs.find do |spec|
68
- # TODO: inverted responsibility
69
- spec.loaded? and matching_file? spec, glob
70
- end
71
- end
72
-
73
- ##
74
- # Works like #find, but finds all gemspecs matching +glob+.
75
-
76
- def find_all(glob)
77
- # HACK violation of encapsulation
78
- @gemspecs.select do |spec|
79
- # TODO: inverted responsibility
80
- matching_file? spec, glob
81
- end || []
82
- end
83
-
84
- def find_in_unresolved(glob)
85
- # HACK violation
86
- specs = Gem.unresolved_deps.values.map { |dep|
87
- Gem.source_index.search dep, true
88
- }.flatten
89
-
90
- specs.select do |spec|
91
- # TODO: inverted responsibility
92
- matching_file? spec, glob
93
- end || []
94
- end
95
-
96
- def find_in_unresolved_tree glob
97
- # HACK violation
98
- # TODO: inverted responsibility
99
- specs = Gem.unresolved_deps.values.map { |dep|
100
- Gem.source_index.search dep, true
101
- }.flatten
102
-
103
- specs.reverse_each do |spec|
104
- trails = matching_paths(spec, glob)
105
- next if trails.empty?
106
- return trails.map(&:reverse).sort.first.reverse
107
- end
108
-
109
- []
110
- end
111
-
112
- ##
113
- # Attempts to find a matching path using the require_paths of the given
114
- # +spec+.
115
-
116
- def matching_file?(spec, path)
117
- not matching_files(spec, path).empty?
118
- end
119
-
120
- def matching_paths(spec, path)
121
- trails = []
122
-
123
- spec.traverse do |from_spec, dep, to_spec, trail|
124
- next unless to_spec.conflicts.empty?
125
- trails << trail unless matching_files(to_spec, path).empty?
126
- end
127
-
128
- trails
129
- end
130
-
131
- ##
132
- # Returns files matching +path+ in +spec+.
133
- #--
134
- # Some of the intermediate results are cached in @lib_dirs for speed.
135
-
136
- def matching_files(spec, path)
137
- return [] unless @lib_dirs[spec.object_id] # case no paths
138
- glob = File.join @lib_dirs[spec.object_id], "#{path}#{Gem.suffix_pattern}"
139
- Dir[glob].select { |f| File.file? f.untaint }
140
- end
141
-
142
- ##
143
- # Return a list of all installed gemspecs, sorted by alphabetical order and
144
- # in reverse version order. (bar-2, bar-1, foo-2)
145
-
146
- def init_gemspecs
147
- Gem::Specification.sort { |a, b|
148
- names = a.name <=> b.name
149
- next names if names.nonzero?
150
- b.version <=> a.version
151
- }
152
- end
153
-
154
- ##
155
- # Returns library directories glob for a gemspec. For example,
156
- # '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'
157
-
158
- def lib_dirs_for(spec)
159
- "#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}" if
160
- spec.require_paths
161
- end
162
-
163
- extend Gem::Deprecate
164
-
165
- deprecate :initialize, :none, 2011, 10
166
- deprecate :find, :none, 2011, 10
167
- deprecate :find_active, :none, 2011, 10
168
- deprecate :find_all, :none, 2011, 10
169
- deprecate :find_in_unresolved, :none, 2011, 10
170
- deprecate :find_in_unresolved_tree, :none, 2011, 10
171
- deprecate :find_spec_for_file, :none, 2011, 10
172
- end
@@ -1,153 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require 'rubygems'
8
-
9
- ##
10
- # The format class knows the guts of the RubyGem .gem file format and provides
11
- # the capability to read gem files
12
-
13
- class Gem::OldFormat
14
-
15
- attr_accessor :spec, :file_entries, :gem_path
16
-
17
- ##
18
- # Constructs an instance of a Format object, representing the gem's data
19
- # structure.
20
- #
21
- # gem:: [String] The file name of the gem
22
-
23
- def initialize(gem_path)
24
- require 'fileutils'
25
- require 'zlib'
26
- Gem.load_yaml
27
-
28
- @gem_path = gem_path
29
- end
30
-
31
- ##
32
- # Reads the named gem file and returns a Format object, representing the
33
- # data from the gem file
34
- #
35
- # file_path:: [String] Path to the gem file
36
-
37
- def self.from_file_by_path(file_path)
38
- unless File.exist?(file_path)
39
- raise Gem::Exception, "Cannot load gem file [#{file_path}]"
40
- end
41
-
42
- File.open(file_path, 'rb') do |file|
43
- from_io(file, file_path)
44
- end
45
- end
46
-
47
- ##
48
- # Reads a gem from an io stream and returns a Format object, representing
49
- # the data from the gem file
50
- #
51
- # io:: [IO] Stream from which to read the gem
52
-
53
- def self.from_io(io, gem_path="(io)")
54
- format = self.new(gem_path)
55
- skip_ruby(io)
56
- format.spec = read_spec(io)
57
- format.file_entries = []
58
- read_files_from_gem(io) do |entry, file_data|
59
- format.file_entries << [entry, file_data]
60
- end
61
- format
62
- end
63
-
64
- private
65
-
66
- ##
67
- # Skips the Ruby self-install header. After calling this method, the
68
- # IO index will be set after the Ruby code.
69
- #
70
- # file:: [IO] The IO to process (skip the Ruby code)
71
-
72
- def self.skip_ruby(file)
73
- end_seen = false
74
- loop {
75
- line = file.gets
76
- if(line == nil || line.chomp == "__END__") then
77
- end_seen = true
78
- break
79
- end
80
- }
81
-
82
- if end_seen == false then
83
- raise Gem::Exception.new("Failed to find end of ruby script while reading gem")
84
- end
85
- end
86
-
87
- ##
88
- # Reads the specification YAML from the supplied IO and constructs
89
- # a Gem::Specification from it. After calling this method, the
90
- # IO index will be set after the specification header.
91
- #
92
- # file:: [IO] The IO to process
93
-
94
- def self.read_spec(file)
95
- yaml = ''
96
-
97
- read_until_dashes file do |line|
98
- yaml << line
99
- end
100
-
101
- Gem::Specification.from_yaml yaml
102
- rescue YAML::Error => e
103
- raise Gem::Exception, "Failed to parse gem specification out of gem file"
104
- rescue ArgumentError => e
105
- raise Gem::Exception, "Failed to parse gem specification out of gem file"
106
- end
107
-
108
- ##
109
- # Reads lines from the supplied IO until a end-of-yaml (---) is
110
- # reached
111
- #
112
- # file:: [IO] The IO to process
113
- # block:: [String] The read line
114
-
115
- def self.read_until_dashes(file)
116
- while((line = file.gets) && line.chomp.strip != "---") do
117
- yield line
118
- end
119
- end
120
-
121
- ##
122
- # Reads the embedded file data from a gem file, yielding an entry
123
- # containing metadata about the file and the file contents themselves
124
- # for each file that's archived in the gem.
125
- # NOTE: Many of these methods should be extracted into some kind of
126
- # Gem file read/writer
127
- #
128
- # gem_file:: [IO] The IO to process
129
-
130
- def self.read_files_from_gem(gem_file)
131
- errstr = "Error reading files from gem"
132
- header_yaml = ''
133
- begin
134
- self.read_until_dashes(gem_file) do |line|
135
- header_yaml << line
136
- end
137
- header = YAML.load(header_yaml)
138
- raise Gem::Exception, errstr unless header
139
-
140
- header.each do |entry|
141
- file_data = ''
142
- self.read_until_dashes(gem_file) do |line|
143
- file_data << line
144
- end
145
- yield [entry, Zlib::Inflate.inflate(file_data.strip.unpack("m")[0])]
146
- end
147
- rescue Zlib::DataError
148
- raise Gem::Exception, errstr
149
- end
150
- end
151
-
152
- end
153
-