rubygems-update 1.3.6 → 1.3.7

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 (80) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +86 -0
  3. data/History.txt +34 -1
  4. data/Manifest.txt +6 -1
  5. data/Rakefile +79 -34
  6. data/lib/rubygems.rb +52 -30
  7. data/lib/rubygems/builder.rb +2 -0
  8. data/lib/rubygems/command.rb +12 -0
  9. data/lib/rubygems/command_manager.rb +17 -12
  10. data/lib/rubygems/commands/contents_command.rb +1 -1
  11. data/lib/rubygems/commands/dependency_command.rb +3 -1
  12. data/lib/rubygems/commands/environment_command.rb +3 -2
  13. data/lib/rubygems/commands/fetch_command.rb +7 -3
  14. data/lib/rubygems/commands/install_command.rb +2 -1
  15. data/lib/rubygems/commands/query_command.rb +16 -3
  16. data/lib/rubygems/commands/server_command.rb +5 -3
  17. data/lib/rubygems/commands/setup_command.rb +1 -1
  18. data/lib/rubygems/commands/unpack_command.rb +35 -23
  19. data/lib/rubygems/commands/update_command.rb +1 -1
  20. data/lib/rubygems/defaults.rb +4 -6
  21. data/lib/rubygems/dependency.rb +32 -6
  22. data/lib/rubygems/dependency_installer.rb +10 -3
  23. data/lib/rubygems/doc_manager.rb +5 -2
  24. data/lib/rubygems/errors.rb +35 -0
  25. data/lib/rubygems/exceptions.rb +10 -1
  26. data/lib/rubygems/indexer.rb +1 -1
  27. data/lib/rubygems/installer.rb +6 -5
  28. data/lib/rubygems/package.rb +6 -3
  29. data/lib/rubygems/package/f_sync_dir.rb +4 -3
  30. data/lib/rubygems/package/tar_header.rb +4 -3
  31. data/lib/rubygems/package/tar_output.rb +4 -3
  32. data/lib/rubygems/package/tar_reader.rb +4 -3
  33. data/lib/rubygems/package/tar_writer.rb +4 -3
  34. data/lib/rubygems/package_task.rb +4 -3
  35. data/lib/rubygems/platform.rb +4 -1
  36. data/lib/rubygems/remote_fetcher.rb +9 -3
  37. data/lib/rubygems/requirement.rb +5 -0
  38. data/lib/rubygems/security.rb +3 -3
  39. data/lib/rubygems/server.rb +33 -18
  40. data/lib/rubygems/source_index.rb +4 -4
  41. data/lib/rubygems/source_info_cache.rb +4 -2
  42. data/lib/rubygems/spec_fetcher.rb +33 -11
  43. data/lib/rubygems/specification.rb +40 -32
  44. data/lib/rubygems/test_utilities.rb +2 -2
  45. data/lib/rubygems/validator.rb +3 -4
  46. data/lib/rubygems/version.rb +1 -1
  47. data/test/gem_package_tar_test_case.rb +2 -2
  48. data/test/gemutilities.rb +15 -9
  49. data/test/insure_session.rb +1 -1
  50. data/test/plugin/exception/rubygems_plugin.rb +2 -0
  51. data/test/plugin/load/rubygems_plugin.rb +1 -0
  52. data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
  53. data/test/rubygems/commands/crash_command.rb +5 -0
  54. data/test/rubygems_plugin.rb +5 -0
  55. data/test/simple_gem.rb +15 -15
  56. data/test/test_gem.rb +45 -2
  57. data/test/test_gem_command_manager.rb +14 -0
  58. data/test/test_gem_commands_contents_command.rb +7 -5
  59. data/test/test_gem_commands_environment_command.rb +3 -1
  60. data/test/test_gem_commands_fetch_command.rb +21 -1
  61. data/test/test_gem_commands_install_command.rb +2 -4
  62. data/test/test_gem_commands_query_command.rb +33 -6
  63. data/test/test_gem_commands_server_command.rb +9 -2
  64. data/test/test_gem_commands_uninstall_command.rb +4 -2
  65. data/test/test_gem_commands_unpack_command.rb +46 -2
  66. data/test/test_gem_config_file.rb +2 -0
  67. data/test/test_gem_dependency.rb +11 -0
  68. data/test/test_gem_doc_manager.rb +1 -1
  69. data/test/test_gem_indexer.rb +2 -2
  70. data/test/test_gem_installer.rb +1 -1
  71. data/test/test_gem_package_tar_input.rb +1 -1
  72. data/test/test_gem_package_tar_writer.rb +3 -3
  73. data/test/test_gem_platform.rb +19 -0
  74. data/test/test_gem_server.rb +11 -0
  75. data/test/test_gem_source_index.rb +2 -2
  76. data/test/test_gem_spec_fetcher.rb +42 -0
  77. data/test/test_gem_specification.rb +46 -7
  78. data/util/{gem_prelude.rb.template → gem_prelude.rb} +53 -23
  79. metadata +16 -6
  80. metadata.gz.sig +0 -0
@@ -85,10 +85,10 @@ class Gem::SourceIndex
85
85
  def load_specification(file_name)
86
86
  return nil unless file_name and File.exist? file_name
87
87
 
88
- spec_code = if RUBY_VERSION < '1.9' then
89
- File.read file_name
90
- else
88
+ spec_code = if defined? Encoding then
91
89
  File.read file_name, :encoding => 'UTF-8'
90
+ else
91
+ File.read file_name
92
92
  end.untaint
93
93
 
94
94
  begin
@@ -414,7 +414,7 @@ class Gem::SourceIndex
414
414
  end
415
415
 
416
416
  def ==(other) # :nodoc:
417
- self.class === other and @gems == other.gems
417
+ self.class === other and @gems == other.gems
418
418
  end
419
419
 
420
420
  def dump
@@ -285,17 +285,19 @@ class Gem::SourceInfoCache
285
285
  cache_data.map do |source_uri, sic_entry|
286
286
  next unless Gem.sources.include? source_uri
287
287
  # TODO - Remove this gunk after 2008/11
288
- unless pattern.kind_of?(Gem::Dependency)
289
- pattern = Gem::Dependency.new(pattern, Gem::Requirement.default)
288
+ unless pattern.kind_of? Gem::Dependency then
289
+ pattern = Gem::Dependency.new pattern, Gem::Requirement.default
290
290
  end
291
291
  sic_entry.source_index.search pattern, platform_only
292
292
  end.flatten.compact
293
293
  end
294
294
 
295
+ ##
295
296
  # Searches all source indexes for +pattern+. If +only_platform+ is true,
296
297
  # only gems matching Gem.platforms will be selected. Returns an Array of
297
298
  # pairs containing the Gem::Specification found and the source_uri it was
298
299
  # found at.
300
+
299
301
  def search_with_source(pattern, only_platform = false, all = false)
300
302
  read_all_cache_data if all
301
303
 
@@ -3,6 +3,7 @@ require 'fileutils'
3
3
 
4
4
  require 'rubygems/remote_fetcher'
5
5
  require 'rubygems/user_interaction'
6
+ require 'rubygems/errors'
6
7
 
7
8
  ##
8
9
  # SpecFetcher handles metadata updates from remote gem repositories.
@@ -53,7 +54,7 @@ class Gem::SpecFetcher
53
54
  end
54
55
 
55
56
  ##
56
- # Retuns the local directory to write +uri+ to.
57
+ # Returns the local directory to write +uri+ to.
57
58
 
58
59
  def cache_dir(uri)
59
60
  File.join @dir, "#{uri.host}%#{uri.port}", File.dirname(uri.path)
@@ -65,22 +66,28 @@ class Gem::SpecFetcher
65
66
  # false, all platforms are returned. If +prerelease+ is true,
66
67
  # prerelease versions are included.
67
68
 
68
- def fetch(dependency, all = false, matching_platform = true, prerelease = false)
69
- specs_and_sources = find_matching dependency, all, matching_platform, prerelease
69
+ def fetch_with_errors(dependency, all = false, matching_platform = true, prerelease = false)
70
+ specs_and_sources, errors = find_matching_with_errors dependency, all, matching_platform, prerelease
70
71
 
71
- specs_and_sources.map do |spec_tuple, source_uri|
72
+ ss = specs_and_sources.map do |spec_tuple, source_uri|
72
73
  [fetch_spec(spec_tuple, URI.parse(source_uri)), source_uri]
73
74
  end
74
75
 
76
+ return [ss, errors]
77
+
75
78
  rescue Gem::RemoteFetcher::FetchError => e
76
79
  raise unless warn_legacy e do
77
80
  require 'rubygems/source_info_cache'
78
81
 
79
- return Gem::SourceInfoCache.search_with_source(dependency,
80
- matching_platform, all)
82
+ return [Gem::SourceInfoCache.search_with_source(dependency,
83
+ matching_platform, all), nil]
81
84
  end
82
85
  end
83
86
 
87
+ def fetch(*args)
88
+ fetch_with_errors(*args).first
89
+ end
90
+
84
91
  def fetch_spec(spec, source_uri)
85
92
  spec = spec - [nil, 'ruby', '']
86
93
  spec_file_name = "#{spec.join '-'}.gemspec"
@@ -117,16 +124,27 @@ class Gem::SpecFetcher
117
124
  # matching released versions are returned. If +matching_platform+
118
125
  # is false, gems for all platforms are returned.
119
126
 
120
- def find_matching(dependency, all = false, matching_platform = true, prerelease = false)
127
+ def find_matching_with_errors(dependency, all = false, matching_platform = true, prerelease = false)
121
128
  found = {}
122
129
 
130
+ rejected_specs = {}
131
+
123
132
  list(all, prerelease).each do |source_uri, specs|
124
133
  found[source_uri] = specs.select do |spec_name, version, spec_platform|
125
- dependency =~ Gem::Dependency.new(spec_name, version) and
126
- (not matching_platform or Gem::Platform.match(spec_platform))
134
+ if dependency.match?(spec_name, version)
135
+ if matching_platform and !Gem::Platform.match(spec_platform)
136
+ pm = (rejected_specs[dependency] ||= Gem::PlatformMismatch.new(spec_name, version))
137
+ pm.add_platform spec_platform
138
+ false
139
+ else
140
+ true
141
+ end
142
+ end
127
143
  end
128
144
  end
129
145
 
146
+ errors = rejected_specs.values
147
+
130
148
  specs_and_sources = []
131
149
 
132
150
  found.each do |source_uri, specs|
@@ -134,7 +152,11 @@ class Gem::SpecFetcher
134
152
  specs_and_sources.push(*specs.map { |spec| [spec, uri_str] })
135
153
  end
136
154
 
137
- specs_and_sources
155
+ [specs_and_sources, errors]
156
+ end
157
+
158
+ def find_matching(*args)
159
+ find_matching_with_errors(*args).first
138
160
  end
139
161
 
140
162
  ##
@@ -184,7 +206,7 @@ class Gem::SpecFetcher
184
206
  cache = { :latest => @latest_specs,
185
207
  :prerelease => @prerelease_specs,
186
208
  :all => @specs }[type]
187
-
209
+
188
210
  Gem.sources.each do |source_uri|
189
211
  source_uri = URI.parse source_uri
190
212
 
@@ -504,8 +504,8 @@ class Gem::Specification
504
504
  gemspec = nil
505
505
  raise "NESTED Specification.load calls not allowed!" if @@gather
506
506
  @@gather = proc { |gs| gemspec = gs }
507
- data = File.read(filename)
508
- eval(data)
507
+ data = File.read filename
508
+ eval data, nil, filename
509
509
  gemspec
510
510
  ensure
511
511
  @@gather = nil
@@ -524,7 +524,7 @@ class Gem::Specification
524
524
  # Sets the rubygems_version to the current RubyGems version
525
525
 
526
526
  def mark_version
527
- @rubygems_version = Gem::RubyGemsVersion
527
+ @rubygems_version = Gem::VERSION
528
528
  end
529
529
 
530
530
  ##
@@ -677,33 +677,43 @@ class Gem::Specification
677
677
  }
678
678
  end
679
679
 
680
- def to_yaml(opts = {}) # :nodoc:
680
+ def encode_with coder # :nodoc:
681
681
  mark_version
682
682
 
683
683
  attributes = @@attributes.map { |name,| name.to_s }.sort
684
684
  attributes = attributes - %w[name version platform]
685
685
 
686
+ coder.add 'name', @name
687
+ coder.add 'version', @version
688
+ platform = case @original_platform
689
+ when nil, '' then
690
+ 'ruby'
691
+ when String then
692
+ @original_platform
693
+ else
694
+ @original_platform.to_s
695
+ end
696
+ coder.add 'platform', platform
697
+
698
+ attributes.each do |name|
699
+ coder.add name, instance_variable_get("@#{name}")
700
+ end
701
+ end
702
+
703
+ def to_yaml(opts = {}) # :nodoc:
704
+ return super if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?
705
+
686
706
  yaml = YAML.quick_emit object_id, opts do |out|
687
707
  out.map taguri, to_yaml_style do |map|
688
- map.add 'name', @name
689
- map.add 'version', @version
690
- platform = case @original_platform
691
- when nil, '' then
692
- 'ruby'
693
- when String then
694
- @original_platform
695
- else
696
- @original_platform.to_s
697
- end
698
- map.add 'platform', platform
699
-
700
- attributes.each do |name|
701
- map.add name, instance_variable_get("@#{name}")
702
- end
708
+ encode_with map
703
709
  end
704
710
  end
705
711
  end
706
712
 
713
+ def init_with coder # :nodoc:
714
+ yaml_initialize coder.tag, coder.map
715
+ end
716
+
707
717
  def yaml_initialize(tag, vals) # :nodoc:
708
718
  vals.each do |ivar, val|
709
719
  instance_variable_set "@#{ivar}", val
@@ -759,7 +769,7 @@ class Gem::Specification
759
769
  result << " s.specification_version = #{specification_version}"
760
770
  result << nil
761
771
 
762
- result << " if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then"
772
+ result << " if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then"
763
773
 
764
774
  unless dependencies.empty? then
765
775
  dependencies.each do |dep|
@@ -804,9 +814,9 @@ class Gem::Specification
804
814
  extend Gem::UserInteraction
805
815
  normalize
806
816
 
807
- if rubygems_version != Gem::RubyGemsVersion then
817
+ if rubygems_version != Gem::VERSION then
808
818
  raise Gem::InvalidSpecificationException,
809
- "expected RubyGems version #{Gem::RubyGemsVersion}, was #{rubygems_version}"
819
+ "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
810
820
  end
811
821
 
812
822
  @@required_attributes.each do |symbol|
@@ -1052,7 +1062,7 @@ class Gem::Specification
1052
1062
  #
1053
1063
  # Do not set this, it is set automatically when the gem is packaged.
1054
1064
 
1055
- required_attribute :rubygems_version, Gem::RubyGemsVersion
1065
+ required_attribute :rubygems_version, Gem::VERSION
1056
1066
 
1057
1067
  ##
1058
1068
  # :attr_accessor: specification_version
@@ -1481,14 +1491,12 @@ class Gem::Specification
1481
1491
  end
1482
1492
 
1483
1493
  overwrite_accessor :files do
1484
- result = []
1485
- result.push(*@files) if defined?(@files)
1486
- result.push(*@test_files) if defined?(@test_files)
1487
- result.push(*(add_bindir(@executables)))
1488
- result.push(*@extra_rdoc_files) if defined?(@extra_rdoc_files)
1489
- result.push(*@extensions) if defined?(@extensions)
1490
- result.uniq.compact
1494
+ # DO NOT CHANGE TO ||= ! This is not a normal accessor. (yes, it sucks)
1495
+ @files = [@files,
1496
+ @test_files,
1497
+ add_bindir(@executables),
1498
+ @extra_rdoc_files,
1499
+ @extensions,
1500
+ ].flatten.uniq.compact
1491
1501
  end
1492
-
1493
1502
  end
1494
-
@@ -11,9 +11,9 @@ require 'rubygems/remote_fetcher'
11
11
  # @fetcher = Gem::FakeFetcher.new
12
12
  # @fetcher.data['http://gems.example.com/yaml'] = source_index.to_yaml
13
13
  # Gem::RemoteFetcher.fetcher = @fetcher
14
- #
14
+ #
15
15
  # # invoke RubyGems code
16
- #
16
+ #
17
17
  # paths = @fetcher.paths
18
18
  # assert_equal 'http://gems.example.com/yaml', paths.shift
19
19
  # assert paths.empty?, paths.join(', ')
@@ -10,12 +10,11 @@ require 'digest'
10
10
  require 'rubygems/format'
11
11
  require 'rubygems/installer'
12
12
 
13
- # Load test-unit 2.x if it's a gem
14
13
  begin
15
- Gem.activate('test-unit')
14
+ gem 'test-unit'
16
15
  rescue Gem::LoadError
17
- # Ignore - use the test-unit library that's part of the standard library
18
- end
16
+ # Ignore - use the test-unit library that's part of the standard library
17
+ end
19
18
 
20
19
  ##
21
20
  # Validator performs various gem file and gem database validation
@@ -212,7 +212,7 @@ class Gem::Version
212
212
  end
213
213
 
214
214
  def hash # :nodoc:
215
- segments.hash
215
+ @hash ||= segments.hash
216
216
  end
217
217
 
218
218
  def inspect # :nodoc:
@@ -35,7 +35,7 @@ class TarTestCase < RubyGemTestCase
35
35
  linkname 100
36
36
  magic 6
37
37
  version 2
38
- uname 32
38
+ uname 32
39
39
  gname 32
40
40
  devmajor 8
41
41
  devminor 8
@@ -54,7 +54,7 @@ class TarTestCase < RubyGemTestCase
54
54
  next
55
55
  end
56
56
 
57
- assert_equal expected[offset, length], actual[offset, length],
57
+ assert_equal expected[offset, length], actual[offset, length],
58
58
  "Field #{name} of the tar header differs."
59
59
 
60
60
  offset += length
data/test/gemutilities.rb CHANGED
@@ -8,18 +8,17 @@ else
8
8
  require 'rubygems'
9
9
  end
10
10
  require 'fileutils'
11
- begin
12
- gem 'minitest', '>= 1.3.1'
13
- require 'minitest/unit'
14
- rescue Gem::LoadError
15
- warn "Install minitest gem >= 1.3.1"
16
- raise
17
- end
11
+ require 'minitest/autorun'
18
12
  require 'tmpdir'
19
13
  require 'uri'
20
14
  require 'rubygems/package'
21
15
  require 'rubygems/test_utilities'
22
16
  require 'pp'
17
+ require 'yaml'
18
+ begin
19
+ YAML::ENGINE.yamler = 'psych'
20
+ rescue LoadError
21
+ end if YAML.const_defined? :ENGINE
23
22
 
24
23
  begin
25
24
  gem 'rdoc'
@@ -71,6 +70,13 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
71
70
 
72
71
  Gem.ensure_gem_subdirectories @gemhome
73
72
 
73
+ @orig_ruby = if ruby = ENV['RUBY'] then
74
+ Gem.class_eval { ruby, @ruby = @ruby, ruby }
75
+ ruby
76
+ end
77
+
78
+ Gem.ensure_gem_subdirectories @gemhome
79
+
74
80
  @orig_ENV_HOME = ENV['HOME']
75
81
  ENV['HOME'] = @userhome
76
82
  Gem.instance_variable_set :@user_home, nil
@@ -147,6 +153,8 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
147
153
 
148
154
  Gem.clear_paths
149
155
 
156
+ Gem.class_eval { @ruby = ruby } if ruby = @orig_ruby
157
+
150
158
  if @orig_ENV_HOME then
151
159
  ENV['HOME'] = @orig_ENV_HOME
152
160
  else
@@ -578,5 +586,3 @@ Also, a list:
578
586
 
579
587
  end
580
588
 
581
- MiniTest::Unit.autorun
582
-
@@ -15,7 +15,7 @@ def install_session
15
15
  puts
16
16
  puts "with the appropriate admin privileges."
17
17
  puts "*****************************************************************"
18
- puts
18
+ puts
19
19
  exit
20
20
  end
21
21
  gem 'session'
@@ -0,0 +1,2 @@
1
+ TestGem::TEST_PLUGIN_EXCEPTION = :loaded
2
+ raise Exception.new('boom')
@@ -0,0 +1 @@
1
+ TestGem::TEST_PLUGIN_LOAD = :loaded
@@ -0,0 +1,2 @@
1
+ TestGem::TEST_PLUGIN_STANDARDERROR = :loaded
2
+ raise StandardError.new('boom')
@@ -0,0 +1,5 @@
1
+ class Gem::Commands::CrashCommand < Gem::Command
2
+
3
+ raise "crash"
4
+
5
+ end
@@ -1,5 +1,10 @@
1
1
  require 'rubygems/command_manager'
2
2
 
3
+ ##
4
+ # This is an example of exactly what NOT to do.
5
+ #
6
+ # DO NOT include code like this in your rubygems_plugin.rb
7
+
3
8
  class Gem::Commands::InterruptCommand < Gem::Command
4
9
 
5
10
  def initialize
data/test/simple_gem.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  SIMPLE_GEM = <<-GEMDATA
2
- MD5SUM = "e3701f9db765a2358aef94c40ded71c8"
2
+ MD5SUM = "b12a4d48febeb2289c539c2574c4b6f8"
3
3
  if $0 == __FILE__
4
4
  require 'optparse'
5
-
5
+
6
6
  options = {}
7
7
  ARGV.options do |opts|
8
8
  opts.on_tail("--help", "show this message") {puts opts; exit}
@@ -13,45 +13,45 @@ SIMPLE_GEM = <<-GEMDATA
13
13
  end
14
14
 
15
15
  require 'rubygems'
16
- @directory = options[:directory] || Gem.dir
16
+ @directory = options[:directory] || Gem.dir
17
17
  @force = options[:force]
18
-
19
- gem = Gem::Installer.new(__FILE__).install(@force, @directory)
18
+
19
+ gem = Gem::Installer.new(__FILE__).install(@force, @directory)
20
20
  if options[:gen_rdoc]
21
21
  Gem::DocManager.new(gem).generate_rdoc
22
22
  end
23
23
  end
24
24
 
25
25
  __END__
26
- --- !ruby/object:Gem::Specification
26
+ --- !ruby/object:Gem::Specification
27
27
  rubygems_version: "1.0"
28
28
  name: testing
29
- version: !ruby/object:Gem::Version
29
+ version: !ruby/object:Gem::Version
30
30
  version: 1.2.3
31
31
  date: 2004-03-18 22:01:52.859121 -05:00
32
- platform:
32
+ platform:
33
33
  summary: This exercise the gem testing stuff.
34
- require_paths:
34
+ require_paths:
35
35
  - lib
36
- files:
36
+ files:
37
37
  - lib/foo.rb
38
38
  - lib/test
39
39
  - lib/test.rb
40
40
  - lib/test/wow.rb
41
41
  autorequire: test
42
42
  test_suite_file: foo
43
- requirements:
43
+ requirements:
44
44
  - a computer processor
45
- ---
46
- -
45
+ ---
46
+ -
47
47
  size: 109
48
48
  mode: 420
49
49
  path: lib/foo.rb
50
- -
50
+ -
51
51
  size: 0
52
52
  mode: 420
53
53
  path: lib/test.rb
54
- -
54
+ -
55
55
  size: 15
56
56
  mode: 420
57
57
  path: lib/test/wow.rb