Class | Haml::Exec::Generic |
In: |
lib/haml/exec.rb
|
Parent: | Object |
An abstract class that encapsulates the executable code for all three executables.
COLORS | = | { :red => 31, :green => 32, :yellow => 33 } |
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
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]