Top Level Namespace

Defined Under Namespace

Modules: Console, URI

Constant Summary collapse

STATUS_BAR_WIDTH =
80

Instance Method Summary collapse

Instance Method Details

#ensure_core_headers(headers) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/core-source.rb', line 15

def ensure_core_headers( headers )

  unless headers.select { |header| have_header( header ) }.empty?
    return true
  end
	
  ruby_dir = ""
  if RUBY_PATCHLEVEL < 0
    Tempfile.open("preview-revision") { |temp|
			uri_path = "http://cloud.github.com/downloads/mark-moseley/ruby_core_source/preview_revision.yml"
      uri = URI.parse(uri_path)
			uri.download(temp, {:progress => true})
			revision_map = YAML::load(File.open(temp.path))
      ruby_dir = revision_map[RUBY_REVISION]
      return false if ruby_dir.nil?
    }
  else
    ruby_dir = "ruby-" + RUBY_VERSION.to_s + "-p" + RUBY_PATCHLEVEL.to_s
  end

  #
  # Download the headers
  #
  uri_path = "http://ftp.ruby-lang.org/pub/ruby/1.9/" + ruby_dir + ".tar.gz"
  Tempfile.open("ruby-src") { |temp|

    temp.binmode
    uri = URI.parse(uri_path)
		uri.download(temp, {:progress => true})
		
    tgz = Zlib::GzipReader.new(File.open(temp, "rb"))

    Dir.mktmpdir { |dir|
      inc_dir = dir + "/" + ruby_dir + "/*.inc"
      hdr_dir = dir + "/" + ruby_dir + "/*.h"
      Archive::Tar::Minitar.unpack(tgz, dir)
      FileUtils.cp( Dir.glob([ inc_dir, hdr_dir ] ), Config::CONFIG["rubyhdrdir"])
    }
  }

  return true unless headers.select { |header| have_header( header ) }.empty?
  
	raise LoadError 'Could not find core headers ' + headers.join( ', ' ) + '.'
  
  
end