Module: Egi
- Defined in:
- lib/egi.rb,
lib/egi/env.rb,
lib/egi/item.rb,
lib/egi/group.rb,
lib/egi/sandbox.rb
Defined Under Namespace
Classes: Env, Group, Item, Sandbox
Constant Summary
collapse
- VERSION =
File.read(File.join(File.dirname(__FILE__), %w[ .. VERSION ])).chomp
Class Method Summary
collapse
Class Method Details
.[](name) ⇒ Object
16
17
18
19
|
# File 'lib/egi.rb', line 16
def [](name)
name = name.to_sym
@env.has_key?(name) ? @env[name] : nil
end
|
.config_file ⇒ Object
33
34
35
36
37
38
|
# File 'lib/egi.rb', line 33
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
|
.config_file=(file) ⇒ Object
40
41
42
|
# File 'lib/egi.rb', line 40
def config_file=(file)
@config_file = file
end
|
.env ⇒ Object
10
11
12
13
14
|
# File 'lib/egi.rb', line 10
def env
load_file(config_file) unless @env
self[(ENV['EGI_ENV'] || 'default').to_sym]
end
|
.load(str) ⇒ Object
25
26
27
|
# File 'lib/egi.rb', line 25
def load(str)
@env = Sandbox.new.eval(str)
end
|
.load_file(file) ⇒ Object
21
22
23
|
# File 'lib/egi.rb', line 21
def load_file(file)
load(File.read(file))
end
|
.reset ⇒ Object
29
30
31
|
# File 'lib/egi.rb', line 29
def reset
@env = nil
end
|