Sha256: 3071b875ff5f49ed46d6694b6c91965060cee500aa78c58560decbe6c0e11833

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

require 'tmpdir'
require 'open-uri'
require 'archive/tar/minitar'
require 'zlib'
require 'fileutils'
require 'bundler'
Bundler::GemHelper.install_tasks

desc 'Add ruby headers under lib for a given VERSION and PATCHLEVEL'
task :add_source do
  version = ENV['VERSION'] or abort "Need a $VERSION"
  ruby_dir = "ruby-#{version}"
  minor_version = version.split('.')[0..1].join('.')
  uri_path = "http://ftp.ruby-lang.org/pub/ruby/#{minor_version}/#{ruby_dir}.tar.gz"
  dest_dir = File.dirname(__FILE__) + "/lib/debase/ruby_core_source/#{ruby_dir}"

  patchlevel = ENV['PATCHLEVEL']
  if patchlevel
    dest_dir = dest_dir + "-p" + patchlevel
  elsif !version.include?('-p')
    abort "Need a $PATCHLEVEL"
  end


  puts "Downloading #{uri_path}..."
  temp = open(uri_path)
  puts "Unpacking #{uri_path}..."
  tgz = Zlib::GzipReader.new(File.open(temp, "rb"))

  FileUtils.mkdir_p(dest_dir)
  Dir.mktmpdir do |dir|
    inc_dir = dir + "/" + ruby_dir + "/*.inc"
    hdr_dir = dir + "/" + ruby_dir + "/*.h"
    more_hdr_dir = dir + "/" + ruby_dir + "/ccan/**/*.h"
    Archive::Tar::Minitar.unpack(tgz, dir)
    Dir.glob([ inc_dir, hdr_dir, more_hdr_dir ]).each do |file|
      target = file.sub(dir + '/' + ruby_dir, dest_dir)
      FileUtils.mkdir_p(File.dirname(target))
      FileUtils.cp(file, target, verbose: false)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
debase-ruby_core_source-0.8.6 Rakefile
debase-ruby_core_source-0.8.5 Rakefile
debase-ruby_core_source-0.8.4 Rakefile
debase-ruby_core_source-0.8.3 Rakefile
debase-ruby_core_source-0.8.2 Rakefile
debase-ruby_core_source-0.8.1 Rakefile
debase-ruby_core_source-0.8.0 Rakefile
debase-ruby_core_source-0.7.10 Rakefile
debase-ruby_core_source-0.7.9 Rakefile