Class: Emerald::CLI

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

Overview

The Emerald CLI

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/emerald.rb', line 24

def self.exit_on_failure?
  true
end

Instance Method Details

#process(file_name, context_file_name = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/emerald.rb', line 32

def process(file_name, context_file_name = nil)
  begin
    output_name = options[:output] || file_name
    context =
      if context_file_name
        JSON.parse(IO.read(context_file_name))
      else
        {}
      end

    input = IO.read(file_name)

    Emerald.write_html(
      Emerald.convert(input, context),
      output_name,
      options['beautify']
    )
  rescue Grammar::PreProcessorError, Grammar::ParserError => e
    raise Thor::Error, e.message
  end
end