rbinstall.rb.gem_executables.diff

Eric Hodel, 07/09/2011 08:47 AM

Download (2.04 KB)

View differences:

tool/rbinstall.rb (working copy)
534 534
install?(:ext, :comm, :gem) do
535 535
  $:.unshift(File.join(srcdir, "lib"))
536 536
  require("rubygems.rb")
537
  gpath = Gem.default_dir
538
  directories = Gem.ensure_gem_subdirectories(gpath)
539
  prepare "default gems", gpath, directories
537
  gem_dir = Gem.default_dir
538
  directories = Gem.ensure_gem_subdirectories(gem_dir)
539
  prepare "default gems", gem_dir, directories
540 540

  
541
  destdir = File.join(gpath, directories.grep(/^spec/)[0])
541
  spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0])
542 542
  default_gems = [
543
    ['rake', 'lib/rake/version.rb'],
544
    ['rdoc', 'lib/rdoc.rb'],
543
    ['rake', 'lib/rake/version.rb', ['rake']],
544
    ['rdoc', 'lib/rdoc.rb', ['rdoc', 'ri']],
545 545
    ['minitest', 'lib/minitest/unit.rb'],
546 546
    ['json', 'ext/json/lib/json/version.rb'],
547 547
    ['io-console', 'ext/io/console/io-console.gemspec'],
548 548
  ]
549
  default_gems.each do |name, src|
549

  
550
  default_gems.each do |name, src, execs|
551
    execs ||= []
550 552
    src = File.join(srcdir, src)
551 553
    version = open(src) {|f| f.find {|s| /^\s*\w*VERSION\s*=(?!=)/ =~ s}} or next
552 554
    version = version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
555
    full_name = "#{name}-#{version}"
556

  
553 557
    puts "#{" "*30}#{name} #{version}"
554
    open_for_install(File.join(destdir, "#{name}-#{version}.gemspec"), $data_mode) do
558
    open_for_install(File.join(spec_dir, "#{full_name}.gemspec"), $data_mode) do
555 559
      <<-GEMSPEC
556 560
Gem::Specification.new do |s|
557 561
  s.name = #{name.dump}
558 562
  s.version = #{version.dump}
559 563
  s.summary = "This #{name} is bundled with Ruby"
564
  s.executables = #{execs.inspect}
560 565
end
561 566
      GEMSPEC
562 567
    end
568

  
569
    unless execs.empty? then
570
      bin_dir = File.join(gem_dir, 'gems', full_name, 'bin')
571
      makedirs(bin_dir)
572

  
573
      execs.each do |exec|
574
        open_for_install(File.join(bin_dir, exec), $prog_mode) do
575
          File.read(File.join(srcdir, 'bin', exec))
576
        end
577
      end
578
    end
563 579
  end
564 580
end
565 581