Class: DevelopWithPassion::Expander::TemplateVisitor

Inherits:
Object
  • Object
show all
Defined in:
lib/developwithpassion_expander/template_visitor.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ TemplateVisitor

Returns a new instance of TemplateVisitor.



4
5
6
7
# File 'lib/developwithpassion_expander/template_visitor.rb', line 4

def initialize(args = {})
  @processor_registry = args.fetch(:processor_registry,TemplateProcessors.instance)
  @file = args.fetch(:file,File)
end

Instance Method Details

#run_using(file_name) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/developwithpassion_expander/template_visitor.rb', line 9

def run_using(file_name)
  processor = @processor_registry.get_processor_for(file_name)
  generated_name = File.basename(file_name,File.extname(file_name))
  generated_name = generated_name.gsub(/\.dotfile/,"") 
  generated_name = ".#{generated_name}" if (/\.dotfile/ =~ file_name) 
  output = File.join(File.dirname(file_name),generated_name)
  @file.delete(output) if @file.exists?(output)
  processor.process(:input => file_name,:output => output)
end