lib/egi.rb in egi-0.0.3 vs lib/egi.rb in egi-0.0.4
- old
+ new
@@ -4,18 +4,19 @@
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
- name = ENV['EGI_ENV'] || 'default'
- self[name]
+ 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))
@@ -26,18 +27,17 @@
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
-
- module_function :env, :[], :load, :reset, :config_file, :config_file=
end