class Microstation::TemplateRunner
Attributes
file[R]
template_hash[R]
Public Class Methods
new(file)
click to toggle source
# File lib/microstation/template_runner.rb, line 7 def initialize(file) puts "running #{file}" @file = file @template_hash = load(file) end
Public Instance Methods
load(file)
click to toggle source
# File lib/microstation/template_runner.rb, line 13 def load(file) begin File.open(file) do |f| YAML.load(f) end rescue => e binding.pry puts "Could not parse YAML: #{e.message}" end end
locals()
click to toggle source
# File lib/microstation/template_runner.rb, line 28 def locals template_hash[:locals] end
name()
click to toggle source
# File lib/microstation/template_runner.rb, line 24 def name template_hash[:name] || Pathname(template).basename.ext('.dgn') end
output_dir()
click to toggle source
# File lib/microstation/template_runner.rb, line 36 def output_dir template_hash[:output_dir] end
run(options = {})
click to toggle source
# File lib/microstation/template_runner.rb, line 49 def run(options = {}) begin the_template = Template.new(template) template_options = { output_dir: output_dir, locals: locals, name: name, tagsets: tagsets } run_options = template_options.merge(options) the_template.render(run_options) rescue binding.pry end end
run_with_app(app,options = {})
click to toggle source
# File lib/microstation/template_runner.rb, line 44 def run_with_app(app,options = {}) run_options = { app: app}.merge(options) run(run_options) end
template()
click to toggle source
# File lib/microstation/template_runner.rb, line 40 def template template_hash[:template] end