class Emerald::CLI

The Emerald CLI

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/emerald.rb, line 24
def self.exit_on_failure?
  true
end

Public Instance Methods

process(file_name, context_file_name = nil) click to toggle source
# 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