Project

General

Profile

Bug #13842 ยป rubygems-2612-ruby24.patch

hsbt (Hiroshi SHIBATA), 08/28/2017 08:03 AM

View differences:

lib/rubygems.rb
10 10
require 'thread'
11 11

  
12 12
module Gem
13
  VERSION = "2.6.11"
13
  VERSION = "2.6.12"
14 14
end
15 15

  
16 16
# Must be first since it unloads the prelude from 1.9.2
......
234 234

  
235 235
  def self.finish_resolve(request_set=Gem::RequestSet.new)
236 236
    request_set.import Gem::Specification.unresolved_deps.values
237
    request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) }
237 238

  
238 239
    request_set.resolve_current.each do |s|
239 240
      s.full_spec.activate
lib/rubygems/commands/open_command.rb
72 72
  end
73 73

  
74 74
  def spec_for name
75
    spec = Gem::Specification.find_all_by_name(name, @version).last
75
    spec = Gem::Specification.find_all_by_name(name, @version).first
76 76

  
77 77
    return spec if spec
78 78

  
lib/rubygems/commands/query_command.rb
86 86
      name = Array(options[:name])
87 87
    else
88 88
      args = options[:args].to_a
89
      name = options[:exact] ? args : args.map{|arg| /#{arg}/i }
89
      name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
90 90
    end
91 91

  
92 92
    prerelease = options[:prerelease]
lib/rubygems/commands/sources_command.rb
44 44
    source = Gem::Source.new source_uri
45 45

  
46 46
    begin
47
      if Gem.sources.include? source_uri then
47
      if Gem.sources.include? source then
48 48
        say "source #{source_uri} already present in the cache"
49 49
      else
50 50
        source.load_specs :released
lib/rubygems/dependency_list.rb
104 104
  end
105 105

  
106 106
  def inspect # :nodoc:
107
    "#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }]
107
    "%s %p>" % [super[0..-2], map { |s| s.full_name }]
108 108
  end
109 109

  
110 110
  ##
lib/rubygems/installer.rb
214 214

  
215 215
      ruby_executable = true
216 216
      existing = io.read.slice(%r{
217
          ^(
217
          ^\s*(
218 218
            gem \s |
219 219
            load \s Gem\.bin_path\( |
220 220
            load \s Gem\.activate_bin_path\(
......
701 701
  # Return the text for an application file.
702 702

  
703 703
  def app_script_text(bin_file_name)
704
    # note that the `load` lines cannot be indented, as old RG versions match
705
    # against the beginning of the line
704 706
    return <<-TEXT
705 707
#{shebang bin_file_name}
706 708
#
......
723 725
  end
724 726
end
725 727

  
728
if Gem.respond_to?(:activate_bin_path)
726 729
load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
730
else
731
gem #{spec.name.dump}, version
732
load Gem.bin_path(#{spec.name.dump}, #{bin_file_name.dump}, version)
733
end
727 734
TEXT
728 735
  end
729 736

  
lib/rubygems/platform.rb
112 112
  end
113 113

  
114 114
  def inspect
115
    "#<%s:0x%x @cpu=%p, @os=%p, @version=%p>" % [self.class, object_id, *to_a]
115
    "%s @cpu=%p, @os=%p, @version=%p>" % [super[0..-2], *to_a]
116 116
  end
117 117

  
118 118
  def to_a
lib/rubygems/security.rb
455 455

  
456 456
  ##
457 457
  # Creates a new key pair of the specified +length+ and +algorithm+.  The
458
  # default is a 2048 bit RSA key.
458
  # default is a 3072 bit RSA key.
459 459

  
460 460
  def self.create_key length = KEY_LENGTH, algorithm = KEY_ALGORITHM
461 461
    algorithm.new length
lib/rubygems/server.rb
657 657
      "only_one_executable" => true,
658 658
      "full_name" => "rubygems-#{Gem::VERSION}",
659 659
      "has_deps" => false,
660
      "homepage" => "http://docs.rubygems.org/",
660
      "homepage" => "http://guides.rubygems.org/",
661 661
      "name" => 'rubygems',
662 662
      "ri_installed" => true,
663 663
      "summary" => "RubyGems itself",
lib/rubygems/specification.rb
2105 2105
    if $DEBUG
2106 2106
      super
2107 2107
    else
2108
      "#<#{self.class}:0x#{__id__.to_s(16)} #{full_name}>"
2108
      "#{super[0..-2]} #{full_name}>"
2109 2109
    end
2110 2110
  end
2111 2111

  
lib/rubygems/test_case.rb
484 484

  
485 485
      system @git, 'add', gemspec
486 486
      system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet'
487
      head = Gem::Util.popen('git', 'rev-parse', 'master').strip
487
      head = Gem::Util.popen(@git, 'rev-parse', 'master').strip
488 488
    end
489 489

  
490 490
    return name, git_spec.version, directory, head
......
1498 1498
begin
1499 1499
  gem 'rdoc'
1500 1500
  require 'rdoc'
1501

  
1502
  require 'rubygems/rdoc'
1501 1503
rescue LoadError, Gem::LoadError
1502 1504
end
1503 1505

  
......
1514 1516
pid = $$
1515 1517
END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
1516 1518
Gem.clear_paths
1519
Gem.loaded_specs.clear
test/rubygems/test_gem.rb
75 75
    end
76 76
  end
77 77

  
78
  def test_self_finish_resolve_respects_loaded_specs
79
    save_loaded_features do
80
      a1 = new_spec "a", "1", "b" => "> 0"
81
      b1 = new_spec "b", "1", "c" => ">= 1"
82
      b2 = new_spec "b", "2", "c" => ">= 2"
83
      c1 = new_spec "c", "1"
84
      c2 = new_spec "c", "2"
85

  
86
      install_specs c1, c2, b1, b2, a1
87

  
88
      a1.activate
89
      c1.activate
90

  
91
      assert_equal %w(a-1 c-1), loaded_spec_names
92
      assert_equal ["b (> 0)"], unresolved_names
93

  
94
      Gem.finish_resolve
95

  
96
      assert_equal %w(a-1 b-1 c-1), loaded_spec_names
97
      assert_equal [], unresolved_names
98
    end
99
  end
100

  
78 101
  def test_self_install
79 102
    spec_fetcher do |f|
80 103
      f.gem  'a', 1
......
492 515
    skip if RUBY_VERSION <= "1.8.7"
493 516

  
494 517
    cwd = File.expand_path("test/rubygems", @@project_dir)
495
    $LOAD_PATH.unshift cwd
518
    actual_load_path = $LOAD_PATH.unshift(cwd).dup
496 519

  
497 520
    discover_path = File.join 'lib', 'sff', 'discover.rb'
498 521

  
......
518 541
    expected = [
519 542
      File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
520 543
      File.join(foo1.full_gem_path, discover_path)
521
    ]
544
    ].sort
522 545

  
523
    assert_equal expected, Gem.find_files('sff/discover')
524
    assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
546
    assert_equal expected, Gem.find_files('sff/discover').sort
547
    assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]'
525 548
  ensure
526
    assert_equal cwd, $LOAD_PATH.shift unless RUBY_VERSION <= "1.8.7"
549
    assert_equal cwd, actual_load_path.shift unless RUBY_VERSION <= "1.8.7"
527 550
  end
528 551

  
529 552
  def test_self_find_latest_files
test/rubygems/test_gem_commands_open_command.rb
24 24
    @cmd.options[:args] = %w[foo]
25 25
    @cmd.options[:editor] = "#{Gem.ruby} -e0 --"
26 26

  
27
    spec = gem 'foo'
27
    gem 'foo', '1.0.0'
28
    spec = gem 'foo', '1.0.1'
28 29
    mock = MiniTest::Mock.new
29 30
    mock.expect(:call, true, [spec.full_gem_path])
30 31

  
test/rubygems/test_gem_commands_query_command.rb
642 642
    assert_equal expected, @ui.output
643 643
  end
644 644

  
645
  def test_execute_exact
645
  def test_execute_exact_remote
646 646
    spec_fetcher do |fetcher|
647 647
      fetcher.spec 'coolgem-omg', 3
648 648
      fetcher.spec 'coolgem', '4.2.1'
......
665 665
    assert_equal expected, @ui.output
666 666
  end
667 667

  
668
  def test_execute_exact_local
669
    spec_fetcher do |fetcher|
670
      fetcher.spec 'coolgem-omg', 3
671
      fetcher.spec 'coolgem', '4.2.1'
672
      fetcher.spec 'wow_coolgem', 1
673
    end
674

  
675
    @cmd.handle_options %w[--exact coolgem]
676

  
677
    use_ui @ui do
678
      @cmd.execute
679
    end
680

  
681
    expected = <<-EOF
682

  
683
*** LOCAL GEMS ***
684

  
685
coolgem (4.2.1)
686
    EOF
687

  
688
    assert_equal expected, @ui.output
689
  end
690

  
691
  def test_execute_exact_multiple
692
    spec_fetcher do |fetcher|
693
      fetcher.spec 'coolgem-omg', 3
694
      fetcher.spec 'coolgem', '4.2.1'
695
      fetcher.spec 'wow_coolgem', 1
696

  
697
      fetcher.spec 'othergem-omg', 3
698
      fetcher.spec 'othergem', '1.2.3'
699
      fetcher.spec 'wow_othergem', 1
700
    end
701

  
702
    @cmd.handle_options %w[--exact coolgem othergem]
703

  
704
    use_ui @ui do
705
      @cmd.execute
706
    end
707

  
708
    expected = <<-EOF
709

  
710
*** LOCAL GEMS ***
711

  
712
coolgem (4.2.1)
713

  
714
*** LOCAL GEMS ***
715

  
716
othergem (1.2.3)
717
    EOF
718

  
719
    assert_equal expected, @ui.output
720
  end
721

  
668 722
  private
669 723

  
670 724
  def add_gems_to_fetcher
test/rubygems/test_gem_commands_sources_command.rb
108 108
    assert_equal '', @ui.error
109 109
  end
110 110

  
111
  def test_execute_add_redundant_source_trailing_slash
112
    # Remove pre-existing gem source (w/ slash)
113
    repo_with_slash = "http://gems.example.com/"
114
    @cmd.handle_options %W[--remove #{repo_with_slash}]
115
    use_ui @ui do
116
      @cmd.execute
117
    end
118
    source = Gem::Source.new repo_with_slash
119
    assert_equal false, Gem.sources.include?(source)
120

  
121
    expected = <<-EOF
122
#{repo_with_slash} removed from sources
123
    EOF
124

  
125
    assert_equal expected, @ui.output
126
    assert_equal '', @ui.error
127

  
128
    # Re-add pre-existing gem source (w/o slash)
129
    repo_without_slash = "http://gems.example.com"
130
    @cmd.handle_options %W[--add #{repo_without_slash}]
131
    use_ui @ui do
132
      @cmd.execute
133
    end
134
    source = Gem::Source.new repo_without_slash
135
    assert_equal true, Gem.sources.include?(source)
136

  
137
    expected = <<-EOF
138
http://gems.example.com/ removed from sources
139
http://gems.example.com added to sources
140
    EOF
141

  
142
    assert_equal expected, @ui.output
143
    assert_equal '', @ui.error
144

  
145
    # Re-add original gem source (w/ slash)
146
    @cmd.handle_options %W[--add #{repo_with_slash}]
147
    use_ui @ui do
148
      @cmd.execute
149
    end
150
    source = Gem::Source.new repo_with_slash
151
    assert_equal true, Gem.sources.include?(source)
152

  
153
    expected = <<-EOF
154
http://gems.example.com/ removed from sources
155
http://gems.example.com added to sources
156
source http://gems.example.com/ already present in the cache
157
    EOF
158

  
159
    assert_equal expected, @ui.output
160
    assert_equal '', @ui.error 
161
  end
162

  
111 163
  def test_execute_add_http_rubygems_org
112 164
    http_rubygems_org = 'http://rubygems.org'
113 165

  
test/rubygems/test_gem_installer.rb
62 62
  end
63 63
end
64 64

  
65
if Gem.respond_to?(:activate_bin_path)
65 66
load Gem.activate_bin_path('a', 'executable', version)
67
else
68
gem "a", version
69
load Gem.bin_path("a", "executable", version)
70
end
66 71
    EOF
67 72

  
68 73
    wrapper = @installer.app_script_text 'executable'
test/rubygems/test_require.rb
301 301
    assert_equal %w(default-2.0.0.0), loaded_spec_names
302 302
  end
303 303

  
304
  def test_realworld_default_gem
305
    skip "no default gems on ruby < 2.0" unless RUBY_VERSION >= "2"
306
    cmd = <<-RUBY
307
      $stderr = $stdout
308
      require "json"
309
      puts Gem.loaded_specs["json"].default_gem?
310
    RUBY
311
    output = Gem::Util.popen(Gem.ruby, "-e", cmd).strip
312
    assert_equal "true", output
313
  end
314

  
304 315
  def test_default_gem_and_normal_gem
305 316
    default_gem_spec = new_default_spec("default", "2.0.0.0",
306 317
                                        nil, "default/gem.rb")