Class: Mirah::Commands::Compile

Inherits:
Base
  • Object
show all
Defined in:
lib/mirah/commands/compile.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #argument_processor, #state

Instance Method Summary collapse

Methods inherited from Base

#execute_base, #initialize

Constructor Details

This class inherits a constructor from Mirah::Commands::Base

Instance Method Details

#command_nameObject



34
35
36
# File 'lib/mirah/commands/compile.rb', line 34

def command_name
  :compile
end

#executeObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mirah/commands/compile.rb', line 22

def execute
  execute_base do
    generator = Mirah::Generator.new(@state, @state.compiler_class, true, @state.verbose)
    
    generator.generate(@state.args).each do |result|
      filename = "#{@state.destination}#{result.filename}"
      FileUtils.mkdir_p(File.dirname(filename))
      File.open(filename, 'wb') {|f| f.write(result.bytes)}
    end
  end
end