rubygems-update 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (225) hide show
  1. data/ChangeLog +587 -0
  2. data/README +0 -1
  3. data/Rakefile +39 -12
  4. data/TODO +0 -5
  5. data/bin/gem +7 -7
  6. data/bin/update_rubygems +1 -1
  7. data/examples/application/an-app.gemspec +1 -1
  8. data/gemspecs/cgikit-1.1.0.gemspec +1 -2
  9. data/gemspecs/jabber4r.gemspec +1 -1
  10. data/gemspecs/linguistics.gemspec +1 -1
  11. data/gemspecs/ook.gemspec +1 -1
  12. data/gemspecs/progressbar.gemspec +1 -1
  13. data/gemspecs/redcloth.gemspec +1 -1
  14. data/gemspecs/rublog.gemspec +1 -1
  15. data/gemspecs/ruby-doom.gemspec +1 -1
  16. data/gemspecs/rubyjdwp.gemspec +1 -1
  17. data/gemspecs/statistics.gemspec +1 -1
  18. data/lib/rubygems.rb +167 -105
  19. data/lib/rubygems/builder.rb +12 -10
  20. data/lib/rubygems/command.rb +177 -60
  21. data/lib/rubygems/command_manager.rb +30 -38
  22. data/lib/rubygems/commands/build_command.rb +42 -46
  23. data/lib/rubygems/commands/cert_command.rb +72 -69
  24. data/lib/rubygems/commands/check_command.rb +63 -63
  25. data/lib/rubygems/commands/cleanup_command.rb +25 -7
  26. data/lib/rubygems/commands/contents_command.rb +70 -62
  27. data/lib/rubygems/commands/dependency_command.rb +131 -86
  28. data/lib/rubygems/commands/environment_command.rb +67 -46
  29. data/lib/rubygems/commands/fetch_command.rb +62 -0
  30. data/lib/rubygems/commands/generate_index_command.rb +57 -0
  31. data/lib/rubygems/commands/help_command.rb +163 -73
  32. data/lib/rubygems/commands/install_command.rb +114 -128
  33. data/lib/rubygems/commands/list_command.rb +10 -8
  34. data/lib/rubygems/commands/lock_command.rb +101 -0
  35. data/lib/rubygems/commands/mirror_command.rb +105 -0
  36. data/lib/rubygems/commands/outdated_command.rb +24 -15
  37. data/lib/rubygems/commands/pristine_command.rb +118 -88
  38. data/lib/rubygems/commands/query_command.rb +109 -77
  39. data/lib/rubygems/commands/rdoc_command.rb +13 -10
  40. data/lib/rubygems/commands/search_command.rb +10 -8
  41. data/lib/rubygems/commands/server_command.rb +48 -0
  42. data/lib/rubygems/commands/sources_command.rb +104 -83
  43. data/lib/rubygems/commands/specification_command.rb +65 -51
  44. data/lib/rubygems/commands/uninstall_command.rb +17 -12
  45. data/lib/rubygems/commands/unpack_command.rb +68 -68
  46. data/lib/rubygems/commands/update_command.rb +72 -25
  47. data/lib/rubygems/commands/which_command.rb +86 -0
  48. data/lib/rubygems/config_file.rb +202 -78
  49. data/lib/rubygems/custom_require.rb +7 -88
  50. data/lib/rubygems/dependency.rb +65 -0
  51. data/lib/rubygems/dependency_installer.rb +232 -0
  52. data/lib/rubygems/dependency_list.rb +133 -105
  53. data/lib/rubygems/digest/md5.rb +4 -1
  54. data/lib/rubygems/digest/sha2.rb +1 -1
  55. data/lib/rubygems/doc_manager.rb +41 -19
  56. data/lib/rubygems/exceptions.rb +63 -0
  57. data/lib/rubygems/ext.rb +18 -0
  58. data/lib/rubygems/ext/builder.rb +56 -0
  59. data/lib/rubygems/ext/configure_builder.rb +24 -0
  60. data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
  61. data/lib/rubygems/ext/rake_builder.rb +27 -0
  62. data/lib/rubygems/format.rb +16 -6
  63. data/lib/rubygems/gem_openssl.rb +43 -6
  64. data/lib/rubygems/gem_path_searcher.rb +84 -0
  65. data/lib/rubygems/gem_runner.rb +20 -5
  66. data/lib/rubygems/indexer.rb +163 -0
  67. data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
  68. data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
  69. data/lib/rubygems/indexer/master_index_builder.rb +53 -0
  70. data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
  71. data/lib/rubygems/install_update_options.rb +87 -0
  72. data/lib/rubygems/installer.rb +316 -562
  73. data/lib/rubygems/local_remote_options.rb +106 -0
  74. data/lib/rubygems/old_format.rb +5 -13
  75. data/lib/rubygems/open-uri.rb +2 -0
  76. data/lib/rubygems/package.rb +28 -32
  77. data/lib/rubygems/platform.rb +187 -0
  78. data/lib/rubygems/remote_fetcher.rb +46 -29
  79. data/lib/rubygems/remote_installer.rb +11 -18
  80. data/lib/rubygems/requirement.rb +157 -0
  81. data/lib/rubygems/rubygems_version.rb +1 -1
  82. data/lib/rubygems/security.rb +715 -457
  83. data/lib/rubygems/server.rb +77 -59
  84. data/lib/rubygems/source_index.rb +154 -83
  85. data/lib/rubygems/source_info_cache.rb +73 -30
  86. data/lib/rubygems/source_info_cache_entry.rb +12 -3
  87. data/lib/rubygems/specification.rb +378 -145
  88. data/lib/rubygems/uninstaller.rb +183 -0
  89. data/lib/rubygems/user_interaction.rb +38 -9
  90. data/lib/rubygems/validator.rb +53 -24
  91. data/lib/rubygems/version.rb +126 -289
  92. data/lib/rubygems/version_option.rb +49 -0
  93. data/pkgs/sources/lib/sources.rb +1 -4
  94. data/pkgs/sources/sources.gemspec +3 -3
  95. data/scripts/gemdoc.rb +0 -1
  96. data/setup.rb +166 -1505
  97. data/test/bogussources.rb +0 -1
  98. data/test/data/gem-private_key.pem +27 -0
  99. data/test/data/gem-public_cert.pem +20 -0
  100. data/test/functional.rb +3 -105
  101. data/test/gemutilities.rb +145 -24
  102. data/test/insure_session.rb +0 -1
  103. data/test/{test_datadir.rb → test_config.rb} +7 -13
  104. data/test/test_gem.rb +360 -9
  105. data/test/test_gem_builder.rb +34 -0
  106. data/test/{test_command.rb → test_gem_command.rb} +119 -62
  107. data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
  108. data/test/test_gem_commands_build_command.rb +75 -0
  109. data/test/test_gem_commands_cert_command.rb +122 -0
  110. data/test/test_gem_commands_check_command.rb +25 -0
  111. data/test/test_gem_commands_contents_command.rb +92 -0
  112. data/test/test_gem_commands_dependency_command.rb +108 -0
  113. data/test/test_gem_commands_environment_command.rb +117 -0
  114. data/test/test_gem_commands_fetch_command.rb +34 -0
  115. data/test/test_gem_commands_generate_index_command.rb +32 -0
  116. data/test/test_gem_commands_install_command.rb +160 -0
  117. data/test/test_gem_commands_mirror_command.rb +56 -0
  118. data/test/test_gem_commands_pristine_command.rb +100 -0
  119. data/test/test_gem_commands_query_command.rb +82 -0
  120. data/test/test_gem_commands_sources_command.rb +147 -0
  121. data/test/test_gem_commands_specification_command.rb +93 -0
  122. data/test/test_gem_commands_unpack_command.rb +55 -0
  123. data/test/test_gem_config_file.rb +210 -0
  124. data/test/test_gem_dependency.rb +89 -0
  125. data/test/test_gem_dependency_installer.rb +542 -0
  126. data/test/test_gem_dependency_list.rb +212 -0
  127. data/test/test_gem_doc_manager.rb +32 -0
  128. data/test/test_gem_ext_configure_builder.rb +13 -17
  129. data/test/test_gem_ext_ext_conf_builder.rb +9 -9
  130. data/test/test_gem_ext_rake_builder.rb +23 -11
  131. data/test/test_gem_format.rb +69 -0
  132. data/test/test_gem_gem_path_searcher.rb +57 -0
  133. data/test/test_gem_gem_runner.rb +35 -0
  134. data/test/test_gem_indexer.rb +119 -0
  135. data/test/test_gem_install_update_options.rb +40 -0
  136. data/test/test_gem_installer.rb +796 -0
  137. data/test/test_gem_local_remote_options.rb +84 -0
  138. data/test/test_gem_outdated_command.rb +11 -9
  139. data/test/test_gem_platform.rb +240 -0
  140. data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
  141. data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
  142. data/test/test_gem_requirement.rb +223 -0
  143. data/test/test_gem_server.rb +71 -0
  144. data/test/test_gem_source_index.rb +429 -0
  145. data/test/test_gem_source_info_cache.rb +79 -17
  146. data/test/test_gem_source_info_cache_entry.rb +11 -9
  147. data/test/test_gem_specification.rb +738 -0
  148. data/test/test_gem_stream_ui.rb +117 -0
  149. data/test/test_gem_validator.rb +70 -0
  150. data/test/test_gem_version.rb +191 -0
  151. data/test/test_gem_version_option.rb +77 -0
  152. data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
  153. data/test/test_open_uri.rb +1 -2
  154. data/test/test_package.rb +45 -34
  155. metadata +116 -141
  156. data/Releases +0 -127
  157. data/bin/gem_mirror +0 -73
  158. data/bin/gem_server +0 -6
  159. data/bin/gemlock +0 -127
  160. data/bin/gemri +0 -24
  161. data/bin/gemwhich +0 -89
  162. data/bin/index_gem_repository.rb +0 -302
  163. data/lib/gemconfigure.rb +0 -24
  164. data/lib/rubygems/gem_commands.rb +0 -273
  165. data/pkgs/sources/sources-0.0.1.gem +0 -0
  166. data/post-install.rb +0 -121
  167. data/test/brokenbuildgem.rb +0 -35
  168. data/test/data/PostMessage-0.0.1.gem +0 -0
  169. data/test/data/a-0.0.1.gem +0 -0
  170. data/test/data/a-0.0.2.gem +0 -0
  171. data/test/data/b-0.0.2.gem +0 -0
  172. data/test/data/broken-1.0.0.gem +0 -0
  173. data/test/data/broken_build/broken-build.gemspec +0 -20
  174. data/test/data/broken_build/ext/extconf.rb +0 -3
  175. data/test/data/broken_build/ext/foo.c +0 -1
  176. data/test/data/c-1.2.gem +0 -0
  177. data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
  178. data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
  179. data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
  180. data/test/data/gemhome/cache/c-1.2.gem +0 -0
  181. data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
  182. data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
  183. data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
  184. data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
  185. data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
  186. data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
  187. data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
  188. data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
  189. data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
  190. data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
  191. data/test/data/lib/code.rb +0 -1
  192. data/test/data/one/README.one +0 -1
  193. data/test/data/one/lib/one.rb +0 -9
  194. data/test/data/one/one-0.0.1.gem +0 -0
  195. data/test/data/one/one.gemspec +0 -17
  196. data/test/data/one/one.yaml +0 -40
  197. data/test/data/post_install.gemspec +0 -19
  198. data/test/functional_extension_gems.rb +0 -48
  199. data/test/functional_generate_yaml_index.rb +0 -104
  200. data/test/gemenvironment.rb +0 -59
  201. data/test/io_capture.rb +0 -33
  202. data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
  203. data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
  204. data/test/onegem.rb +0 -35
  205. data/test/test_builder.rb +0 -34
  206. data/test/test_check_command.rb +0 -34
  207. data/test/test_configfile.rb +0 -42
  208. data/test/test_dependency_list.rb +0 -169
  209. data/test/test_file_list.rb +0 -101
  210. data/test/test_format.rb +0 -49
  211. data/test/test_gem_sources_command.rb +0 -135
  212. data/test/test_gemloadpaths.rb +0 -51
  213. data/test/test_gempaths.rb +0 -170
  214. data/test/test_installer.rb +0 -369
  215. data/test/test_loadmanager.rb +0 -48
  216. data/test/test_process_commands.rb +0 -52
  217. data/test/test_source_index.rb +0 -231
  218. data/test/test_specific_extras.rb +0 -46
  219. data/test/test_specification.rb +0 -565
  220. data/test/test_user_interaction.rb +0 -48
  221. data/test/test_validator.rb +0 -59
  222. data/test/test_version_comparison.rb +0 -321
  223. data/test/testgem.rc +0 -7
  224. data/test/user_capture.rb +0 -7
  225. data/test/yaml_data.rb +0 -63
@@ -0,0 +1,106 @@
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
+ # Mixin methods for local and remote Gem::Command options.
10
+ module Gem::LocalRemoteOptions
11
+
12
+ # Allows OptionParser to handle HTTP URIs.
13
+ def accept_uri_http
14
+ OptionParser.accept URI::HTTP do |value|
15
+ begin
16
+ value = URI.parse value
17
+ rescue URI::InvalidURIError
18
+ raise OptionParser::InvalidArgument, value
19
+ end
20
+
21
+ raise OptionParser::InvalidArgument, value unless value.scheme == 'http'
22
+
23
+ value
24
+ end
25
+ end
26
+
27
+ # Add local/remote options to the command line parser.
28
+ def add_local_remote_options
29
+ add_option(:"Local/Remote", '-l', '--local',
30
+ 'Restrict operations to the LOCAL domain') do |value, options|
31
+ options[:domain] = :local
32
+ end
33
+
34
+ add_option(:"Local/Remote", '-r', '--remote',
35
+ 'Restrict operations to the REMOTE domain') do |value, options|
36
+ options[:domain] = :remote
37
+ end
38
+
39
+ add_option(:"Local/Remote", '-b', '--both',
40
+ 'Allow LOCAL and REMOTE operations') do |value, options|
41
+ options[:domain] = :both
42
+ end
43
+
44
+ add_bulk_threshold_option
45
+ add_source_option
46
+ add_proxy_option
47
+ add_update_sources_option
48
+ end
49
+
50
+ # Add the --bulk-threshold option
51
+ def add_bulk_threshold_option
52
+ add_option(:"Local/Remote", '-B', '--bulk-threshold COUNT',
53
+ "Threshold for switching to bulk",
54
+ "synchronization (default #{Gem.configuration.bulk_threshold})") do
55
+ |value, options|
56
+ Gem.configuration.bulk_threshold = value.to_i
57
+ end
58
+ end
59
+
60
+ # Add the --http-proxy option
61
+ def add_proxy_option
62
+ accept_uri_http
63
+
64
+ add_option(:"Local/Remote", '-p', '--[no-]http-proxy [URL]', URI::HTTP,
65
+ 'Use HTTP proxy for remote operations') do |value, options|
66
+ options[:http_proxy] = (value == false) ? :no_proxy : value
67
+ Gem.configuration[:http_proxy] = options[:http_proxy]
68
+ end
69
+ end
70
+
71
+ # Add the --source option
72
+ def add_source_option
73
+ accept_uri_http
74
+
75
+ add_option(:"Local/Remote", '--source URL', URI::HTTP,
76
+ 'Use URL as the remote source for gems') do |value, options|
77
+ if options[:added_source] then
78
+ Gem.sources << value
79
+ else
80
+ options[:added_source] = true
81
+ Gem.sources.replace [value]
82
+ end
83
+ end
84
+ end
85
+
86
+ # Add the --source option
87
+ def add_update_sources_option
88
+
89
+ add_option(:"Local/Remote", '-u', '--[no-]update-sources',
90
+ 'Update local source cache') do |value, options|
91
+ Gem.configuration.update_sources = value
92
+ end
93
+ end
94
+
95
+ # Is local fetching enabled?
96
+ def local?
97
+ options[:domain] == :local || options[:domain] == :both
98
+ end
99
+
100
+ # Is remote fetching enabled?
101
+ def remote?
102
+ options[:domain] == :remote || options[:domain] == :both
103
+ end
104
+
105
+ end
106
+
@@ -4,15 +4,11 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- module Gem
7
+ require 'fileutils'
8
+ require 'yaml'
9
+ require 'zlib'
8
10
 
9
- ##
10
- # Used to raise parsing and loading errors
11
- #
12
- class FormatException < Gem::Exception
13
- attr_accessor :file_path
14
- #I go back and forth on whether or not to create custom exception classes
15
- end
11
+ module Gem
16
12
 
17
13
  ##
18
14
  # The format class knows the guts of the RubyGem .gem file format
@@ -41,8 +37,7 @@ module Gem
41
37
  unless File.exist?(file_path)
42
38
  raise Gem::Exception, "Cannot load gem file [#{file_path}]"
43
39
  end
44
- require 'fileutils'
45
- File.open(file_path, 'r') do |file|
40
+ File.open(file_path, 'rb') do |file|
46
41
  from_io(file, file_path)
47
42
  end
48
43
  end
@@ -93,7 +88,6 @@ module Gem
93
88
  # file:: [IO] The IO to process
94
89
  #
95
90
  def self.read_spec(file)
96
- require 'yaml'
97
91
  yaml = ''
98
92
  begin
99
93
  read_until_dashes(file) do |line|
@@ -131,8 +125,6 @@ module Gem
131
125
  # gem_file:: [IO] The IO to process
132
126
  #
133
127
  def self.read_files_from_gem(gem_file)
134
- require 'zlib'
135
- require 'yaml'
136
128
  errstr = "Error reading files from gem"
137
129
  header_yaml = ''
138
130
  begin
@@ -2,6 +2,7 @@ require 'uri'
2
2
  require 'stringio'
3
3
  require 'time'
4
4
 
5
+ # :stopdoc:
5
6
  module Kernel
6
7
  private
7
8
  alias rubygems_open_uri_original_open open # :nodoc:
@@ -769,3 +770,4 @@ module URI
769
770
  include OpenURI::OpenRead
770
771
  end
771
772
  end
773
+ # :startdoc:
@@ -1,26 +1,22 @@
1
- #
1
+ #++
2
2
  # Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
3
3
  # See LICENSE.txt for additional licensing information.
4
- #
4
+ #--
5
5
 
6
- require 'yaml'
7
- require 'yaml/syck'
8
- require 'fileutils'
9
- require 'zlib'
10
- require 'digest/md5'
11
6
  require 'fileutils'
12
7
  require 'find'
13
8
  require 'stringio'
9
+ require 'yaml'
10
+ require 'zlib'
14
11
 
15
- require 'rubygems/specification'
12
+ require 'rubygems/digest/md5'
16
13
  require 'rubygems/security'
14
+ require 'rubygems/specification'
17
15
 
18
16
  # Wrapper for FileUtils meant to provide logging and additional operations if
19
17
  # needed.
20
18
  class Gem::FileOperations
21
19
 
22
- extend FileUtils
23
-
24
20
  def initialize(logger = nil)
25
21
  @logger = logger
26
22
  end
@@ -488,14 +484,13 @@ module Gem::Package
488
484
  @tarreader.each do |entry|
489
485
  case entry.full_name
490
486
  when "metadata"
491
- # (GS) Changed to line below: @metadata = YAML.load(entry.read) rescue nil
492
487
  @metadata = load_gemspec(entry.read)
493
488
  has_meta = true
494
489
  break
495
490
  when "metadata.gz"
496
491
  begin
497
- # if we have a security_policy, then pre-read the
498
- # metadata file and calculate it's digest
492
+ # if we have a security_policy, then pre-read the metadata file
493
+ # and calculate it's digest
499
494
  sio = nil
500
495
  if security_policy
501
496
  Gem.ensure_ssl_available
@@ -506,7 +501,6 @@ module Gem::Package
506
501
 
507
502
  gzis = Zlib::GzipReader.new(sio || entry)
508
503
  # YAML wants an instance of IO
509
- # (GS) Changed to line below: @metadata = YAML.load(gzis) rescue nil
510
504
  @metadata = load_gemspec(gzis)
511
505
  has_meta = true
512
506
  ensure
@@ -524,23 +518,24 @@ module Gem::Package
524
518
  end
525
519
  end
526
520
 
527
- if security_policy
521
+ if security_policy then
528
522
  Gem.ensure_ssl_available
529
- # map trust policy from string to actual class (or a
530
- # serialized YAML file, if that exists)
531
- if (security_policy.is_a?(String))
532
- if Gem::Security.constants.index(security_policy)
523
+
524
+ # map trust policy from string to actual class (or a serialized YAML
525
+ # file, if that exists)
526
+ if String === security_policy then
527
+ if Gem::Security::Policy.key? security_policy then
533
528
  # load one of the pre-defined security policies
534
- security_policy = Gem::Security.const_get(security_policy)
535
- elsif File.exist?(security_policy)
529
+ security_policy = Gem::Security::Policy[security_policy]
530
+ elsif File.exist? security_policy then
536
531
  # FIXME: this doesn't work yet
537
- security_policy = YAML::load(File.read(security_policy))
532
+ security_policy = YAML.load File.read(security_policy)
538
533
  else
539
534
  raise Gem::Exception, "Unknown trust policy '#{security_policy}'"
540
535
  end
541
536
  end
542
537
 
543
- if data_sig && data_dgst && meta_sig && meta_dgst
538
+ if data_sig && data_dgst && meta_sig && meta_dgst then
544
539
  # the user has a trust policy, and we have a signed gem
545
540
  # file, so use the trust policy to verify the gem signature
546
541
 
@@ -618,9 +613,14 @@ module Gem::Package
618
613
  # this method would use the String IO approach on all platforms at all
619
614
  # times. And that's the way it is.
620
615
  def zipped_stream(entry)
621
- zis = Zlib::GzipReader.new entry
622
- dis = zis.read
623
- is = StringIO.new(dis)
616
+ # This is Jamis Buck's ZLib workaround. The original code is
617
+ # commented out while we evaluate this patch.
618
+ entry.read(10) # skip the gzip header
619
+ zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
620
+ is = StringIO.new(zis.inflate(entry.read))
621
+ # zis = Zlib::GzipReader.new entry
622
+ # dis = zis.read
623
+ # is = StringIO.new(dis)
624
624
  ensure
625
625
  zis.finish if zis
626
626
  end
@@ -706,11 +706,7 @@ module Gem::Package
706
706
 
707
707
  TarWriter.new(os) do |inner_tar_stream|
708
708
  klass = class << inner_tar_stream; self end
709
- if RUBY_VERSION >= "1.9" then
710
- klass.funcall(:define_method, :metadata=, &set_meta)
711
- else
712
- klass.send(:define_method, :metadata=, &set_meta)
713
- end
709
+ klass.send(:define_method, :metadata=, &set_meta)
714
710
  block.call inner_tar_stream
715
711
  end
716
712
  ensure
@@ -846,7 +842,7 @@ module Gem::Package
846
842
  Dir
847
843
  end
848
844
 
849
- def find_class
845
+ def find_class # HACK kill me
850
846
  Find
851
847
  end
852
848
  end
@@ -0,0 +1,187 @@
1
+ require 'rubygems'
2
+
3
+ # Available list of platforms for targeting Gem installations.
4
+ #
5
+ class Gem::Platform
6
+
7
+ @local = nil
8
+
9
+ attr_accessor :cpu
10
+
11
+ attr_accessor :os
12
+
13
+ attr_accessor :version
14
+
15
+ def self.local
16
+ arch = Config::CONFIG['arch']
17
+ arch = "#{arch}_60" if arch =~ /mswin32$/
18
+ @local ||= new(arch)
19
+ end
20
+
21
+ def self.match(platform)
22
+ Gem.platforms.any? do |local_platform|
23
+ platform.nil? or local_platform == platform or
24
+ (local_platform != Gem::Platform::RUBY and local_platform =~ platform)
25
+ end
26
+ end
27
+
28
+ def self.new(arch) # :nodoc:
29
+ case arch
30
+ when Gem::Platform::RUBY, nil, '' then
31
+ Gem::Platform::RUBY
32
+ else
33
+ super
34
+ end
35
+ end
36
+
37
+ def initialize(arch)
38
+ case arch
39
+ when Array then
40
+ @cpu, @os, @version = arch
41
+ when String then
42
+ arch = arch.split '-'
43
+
44
+ if arch.length > 2 and arch.last !~ /\d/ then # reassemble x86-linux-gnu
45
+ extra = arch.pop
46
+ arch.last << "-#{extra}"
47
+ end
48
+
49
+ cpu = arch.shift
50
+
51
+ @cpu = case cpu
52
+ when /i\d86/ then 'x86'
53
+ else cpu
54
+ end
55
+
56
+ if arch.length == 2 and arch.last =~ /^\d+$/ then # for command-line
57
+ @os, @version = arch
58
+ return
59
+ end
60
+
61
+ os, = arch
62
+ @cpu, os = nil, cpu if os.nil? # legacy jruby
63
+
64
+ @os, @version = case os
65
+ when /aix(\d+)/ then [ 'aix', $1 ]
66
+ when /cygwin/ then [ 'cygwin', nil ]
67
+ when /darwin(\d+)?/ then [ 'darwin', $1 ]
68
+ when /freebsd(\d+)/ then [ 'freebsd', $1 ]
69
+ when /hpux(\d+)/ then [ 'hpux', $1 ]
70
+ when /^java$/, /^jruby$/ then [ 'java', nil ]
71
+ when /^java([\d.]*)/ then [ 'java', $1 ]
72
+ when /linux/ then [ 'linux', $1 ]
73
+ when /mingw32/ then [ 'mingw32', nil ]
74
+ when /(mswin\d+)(\_(\d+))?/ then [ $1, $3 ]
75
+ when /netbsdelf/ then [ 'netbsdelf', nil ]
76
+ when /openbsd(\d+\.\d+)/ then [ 'openbsd', $1 ]
77
+ when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
78
+ # test
79
+ when /^(\w+_platform)(\d+)/ then [ $1, $2 ]
80
+ else [ 'unknown', nil ]
81
+ end
82
+ when Gem::Platform then
83
+ @cpu = arch.cpu
84
+ @os = arch.os
85
+ @version = arch.version
86
+ else
87
+ raise ArgumentError, "invalid argument #{arch.inspect}"
88
+ end
89
+ end
90
+
91
+ def inspect
92
+ "#<%s:0x%x @cpu=%p, @os=%p, @version=%p>" % [self.class, object_id, *to_a]
93
+ end
94
+
95
+ def to_a
96
+ [@cpu, @os, @version]
97
+ end
98
+
99
+ def to_s
100
+ to_a.compact.join '-'
101
+ end
102
+
103
+ def ==(other)
104
+ self.class === other and
105
+ @cpu == other.cpu and @os == other.os and @version == other.version
106
+ end
107
+
108
+ def ===(other)
109
+ return nil unless Gem::Platform === other
110
+
111
+ # cpu
112
+ (@cpu == 'universal' or other.cpu == 'universal' or @cpu == other.cpu) and
113
+
114
+ # os
115
+ @os == other.os and
116
+
117
+ # version
118
+ (@version.nil? or other.version.nil? or @version == other.version)
119
+ end
120
+
121
+ def =~(other)
122
+ case other
123
+ when Gem::Platform then # nop
124
+ when String then
125
+ # This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
126
+ other = case other
127
+ when /^i686-darwin(\d)/ then ['x86', 'darwin', $1]
128
+ when /^i\d86-linux/ then ['x86', 'linux', nil]
129
+ when 'java', 'jruby' then [nil, 'java', nil]
130
+ when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2]
131
+ when 'powerpc-darwin' then ['powerpc', 'darwin', nil]
132
+ when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1]
133
+ when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8']
134
+ when /universal-darwin(\d)/ then ['universal', 'darwin', $1]
135
+ else other
136
+ end
137
+
138
+ other = Gem::Platform.new other
139
+ else
140
+ return nil
141
+ end
142
+
143
+ self === other
144
+ end
145
+
146
+ ##
147
+ # A pure-ruby gem that may use Gem::Specification#extensions to build
148
+ # binary files.
149
+
150
+ RUBY = 'ruby'
151
+
152
+ ##
153
+ # A platform-specific gem that is built for the packaging ruby's platform.
154
+ # This will be replaced with Gem::Platform::local.
155
+
156
+ CURRENT = 'current'
157
+
158
+ ##
159
+ # A One Click Installer-compatible gem, built with VC6 for 32 bit Windows.
160
+ #
161
+ # CURRENT is preferred over this constant, avoid its use at all costs.
162
+
163
+ MSWIN32 = new ['x86', 'mswin32', '60']
164
+
165
+ ##
166
+ # An x86 Linux-compatible gem
167
+ #
168
+ # CURRENT is preferred over this constant, avoid its use at all costs.
169
+
170
+ X86_LINUX = new ['x86', 'linux', nil]
171
+
172
+ ##
173
+ # A PowerPC Darwin-compatible gem
174
+ #
175
+ # CURRENT is preferred over this constant, avoid its use at all costs.
176
+
177
+ PPC_DARWIN = new ['ppc', 'darwin', nil]
178
+
179
+ # :stopdoc:
180
+ # Here lie legacy constants. These are deprecated.
181
+ WIN32 = 'mswin32'
182
+ LINUX_586 = 'i586-linux'
183
+ DARWIN = 'powerpc-darwin'
184
+ # :startdoc:
185
+
186
+ end
187
+