Sha256: a982d18259f578788ef92c6d93f14fe1af88fbd9ed6fc83c0f3c4d82bc53310c

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

module Egi
  VERSION = File.read(File.join(File.dirname(__FILE__), %w[ .. VERSION ])).chomp

  autoload :Sandbox, 'egi/sandbox'
  autoload :Env,     'egi/env'
  autoload :Group,   'egi/group'
  autoload :Item,    'egi/item'

  module_function
  def env
    load_file(config_file) unless @env

    self[(ENV['EGI_ENV'] || 'default').to_sym]
  end
  
  def [](name)
    name = name.to_sym
    @env.has_key?(name) ? @env[name] : nil
  end

  def load_file(file)
    load(File.read(file))
  end

  def load(str)
    @env = Sandbox.new.eval(str)
  end

  def reset
    @env = nil
  end

  def config_file
    @config_file || 
      ( File.exist?('./egi.conf')    && './egi.conf' ) ||
      ( File.exist?('/etc/egi.conf') && '/etc/egi.conf') ||
      raise('you should set Egi.config_file or put ./egi.conf or /etc/egi.conf')
  end

  def config_file=(file)
    @config_file = file
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
egi-0.0.4 lib/egi.rb