Class: Magma::App

Inherits:
Thor
  • Object
show all
Defined in:
lib/magma/app.rb

Overview

The CLI application

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/magma/app.rb', line 14

def exit_on_failure?
  true
end

Instance Method Details

#prepare(infile = nil) ⇒ Object



64
65
66
# File 'lib/magma/app.rb', line 64

def prepare(infile = nil)
  Preparer.call infile, options
end

#render(outfile) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/magma/app.rb', line 32

def render(outfile)
  if options[:skip_template]
    Renderer.call outfile, options
  else
    template = Tempfile.new [File.basename(outfile), '.mlt']

    begin
      Preparer.call options[:infile], options.merge(outfile: template)
      Templater.call template, options.merge(outfile: template)
      Renderer.call outfile, options.merge(infile: template.path)
    ensure
      template.close
      template.unlink
    end
  end
end

#template(infile = nil) ⇒ Object



56
57
58
# File 'lib/magma/app.rb', line 56

def template(infile = nil)
  Templater.call infile, options
end

#versionObject



69
70
71
# File 'lib/magma/app.rb', line 69

def version
  puts Magma::VERSION
end