Module: Rig::Template
- Defined in:
- lib/rig/template.rb
Defined Under Namespace
Classes: Balancer, Base, DSL, Listener, Server
Class Method Summary
collapse
Class Method Details
.list ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/rig/template.rb', line 26
def list
Dir["#{dir}/*"].inject({ }) do |h, e|
f = e.gsub("#{dir}/", "")
f = File.basename(f, ".yml")
h[f.to_sym] = e
h
end
end
|
.load(name) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/rig/template.rb', line 4
def load(name)
@templates ||= { }
template_name = name.to_sym
template_file = "#{dir}/#{name}.rb"
raise "could not load template #{template_name} (#{template_file})" unless File.file?(template_file)
@templates[template_name] ||= begin
t = Rig::Template::DSL.new(template_name)
t.instance_eval(File.read(template_file), "Template(#{template_file})")
@templates[template_name] = t
end
end
|
.load_yaml_file(path) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/rig/template.rb', line 17
def load_yaml_file(path)
file = File.expand_path(path)
raise "Configuration not found: #{path} (#{file})" unless File.exists?(file)
yaml = YAML.load_file(file)
yaml = yaml[yaml.keys.first] if yaml.keys.count == 1
yaml
end
|