Class Haml::Exec::Generic
In: lib/haml/exec.rb
Parent: Object

An abstract class that encapsulates the executable code for all three executables.

Methods

color   get_line   new   parse   parse!   process_result   puts   puts_action   set_opts   to_s  

Constants

COLORS = { :red => 31, :green => 32, :yellow => 33 }

Public Class methods

@param args [Array<String>] The command-line arguments

Public Instance methods

Parses the command-line arguments and runs the executable. This does not handle exceptions or exit the program.

@see parse!

Parses the command-line arguments and runs the executable. Calls `Kernel#exit` at the end, so it never returns.

@see parse

@return [String] A description of the executable

Protected Instance methods

Wraps the given string in terminal escapes causing it to have the given color. If terminal esapes aren‘t supported on this platform, just returns the string instead.

@param color [Symbol] The name of the color to use.

  Can be `:red`, `:green`, or `:yellow`.

@param str [String] The string to wrap in the given color. @return [String] The wrapped string.

Finds the line of the source template on which an exception was raised.

@param exception [Exception] The exception @return [String] The line number

Processes the options set by the command-line arguments. In particular, sets `@options[:input]` and `@options[:output]` to appropriate IO streams.

This is meant to be overridden by subclasses so they can run their respective programs.

Same as \{Kernel.puts}, but doesn‘t print anything if the `—quiet` option is set.

@param args [Array] Passed on to \{Kernel.puts}

Prints a status message about performing the given action, colored using the given color (via terminal escapes) if possible.

@param name [to_s] A short name for the action being performed.

  Shouldn't be longer than 11 characters.

@param color [Symbol] The name of the color to use for this action.

  Can be `:red`, `:green`, or `:yellow`.

Tells optparse how to parse the arguments available for all executables.

This is meant to be overridden by subclasses so they can add their own options.

@param opts [OptionParser]

[Validate]