Top Level Namespace
Defined Under Namespace
Modules: Bourdain, Trollop
Constant Summary
collapse
- CWD =
Dir.pwd
- PATH =
File.expand_path(__FILE__)
- DIR =
File.dirname(PATH)
- ROOT =
File.expand_path(File.join(DIR, '..', '..'))
- BASE =
Pathname.new(ROOT).relative_path_from(Pathname.new(CWD)).to_s
Instance Method Summary
collapse
Instance Method Details
#apply_template(file, opts) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/bourdain/helpers.rb', line 13
def apply_template file, opts
template_name, locals = opts[:template], opts[:locals]
locals = Bourdain::Helpers::Locals.new(locals).bind unless locals.nil?
template_path = gem_path('templates', *template_name)
template = ERB.new File.read(template_path), nil, '-'
contents = template.result(locals).strip
File.open(file, 'w') { |f| f.write contents }
end
|
#gem_path(*dir) ⇒ Object
9
10
11
|
# File 'lib/bourdain/helpers.rb', line 9
def gem_path *dir
Pathname.new(File.join(BASE, *dir)).cleanpath.to_s
end
|