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)


19
20
21
# File 'lib/magma/app.rb', line 19

def exit_on_failure?
  true
end

Instance Method Details

#configObject



26
27
28
29
30
# File 'lib/magma/app.rb', line 26

def config
  config = CONFIG.merge(options)
  File.open(CONFIG_FILE, 'w') { |f| f.write config.to_yaml }
  puts config.to_yaml
end

#prepare(infile = nil) ⇒ Object



83
84
85
# File 'lib/magma/app.rb', line 83

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

#reify(data_file) ⇒ Object



33
34
35
# File 'lib/magma/app.rb', line 33

def reify(data_file)
  Reifier.call data_file, options
end

#render(outfile) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/magma/app.rb', line 50

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

    begin
      Reifier.call(options[:data_file]) if options[:data_file]
      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



75
76
77
# File 'lib/magma/app.rb', line 75

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

#versionObject



88
89
90
# File 'lib/magma/app.rb', line 88

def version
  puts Magma::VERSION
end