module EC2::Platform

Constants

ARCH
ARCHITECTURES
Current
IMPLEMENTATIONS
PEER

Public Class Methods

guess() click to toggle source
# File lib/ec2/platform.rb, line 42
def self.guess
  os = :unknown
  impl = :unknown
  arch = :unknown
  IMPLEMENTATIONS.each do |r, o, i|
    if r and RUBY_PLATFORM =~ r
      os, impl = [o, i]
      break
    end
  end
  ARCHITECTURES.each do |r, a|
    if r and RUBY_PLATFORM =~ r
      arch = a
      break
    end
  end
  return [os, impl, arch]
end
initialize() click to toggle source
# File lib/ec2/platform/current.rb, line 33
def self.initialize
  return EC2::Platform::PEER if defined? EC2::Platform::PEER
  impl = Platform::IMPL
  base = impl.to_s
  
  # must be a known architecture
  raise Unknown.new(base), caller if base.nil? or impl == :unknown      
  
  # base file must exist in same directory as this one
  file = Pathname.new(__FILE__).dirname + base
  raise Unsupported.new(base), caller unless File.exists? file
  
  # a require statement must succeed
  implemented = require "ec2/platform/#{base}" rescue false
  raise Unsupported.new(impl), caller unless implemented
  
  # cross fingers and hope the 'required' peer set the PEER constant
  raise Unsupported.new(impl), caller unless defined? EC2::Platform::PEER
  EC2::Platform::PEER
end