Class: Sass::Exec::Base
- Inherits:
-
Object
- Object
- Sass::Exec::Base
- Defined in:
- lib/sassmagic/reset.rb
Overview
The abstract base class for Sass executables.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(args) ⇒ Base
constructor
A new instance of Base.
-
#parse ⇒ Object
Parses the command-line arguments and runs the executable.
-
#parse! ⇒ Object
Parses the command-line arguments and runs the executable.
-
#to_s ⇒ String
A description of the executable.
Constructor Details
#initialize(args) ⇒ Base
Returns a new instance of Base.
711 712 713 714 |
# File 'lib/sassmagic/reset.rb', line 711 def initialize(args) @args = args @options = {} end |
Instance Method Details
#parse ⇒ Object
Parses the command-line arguments and runs the executable. This does not handle exceptions or exit the program.
752 753 754 755 756 757 758 759 760 |
# File 'lib/sassmagic/reset.rb', line 752 def parse @opts = OptionParser.new(&method(:set_opts)) @opts.parse!(@args) process_result @options end |
#parse! ⇒ Object
Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
# File 'lib/sassmagic/reset.rb', line 720 def parse! # rubocop:disable RescueException begin parse rescue Exception => e # Exit code 65 indicates invalid data per # http://www.freebsd.org/cgi/man.cgi?query=sysexits. Setting it via # at_exit is a bit of a hack, but it allows us to rethrow when --trace # is active and get both the built-in exception formatting and the # correct exit code. at_exit {exit 65} if e.is_a?(Sass::SyntaxError) raise e if @options[:trace] || e.is_a?(SystemExit) if e.is_a?(Sass::SyntaxError) $stderr.puts e.sass_backtrace_str("standard input") else $stderr.print "#{e.class}: " unless e.class == RuntimeError $stderr.puts e..to_s end $stderr.puts " Use --trace for backtrace." exit 1 end exit 0 # rubocop:enable RescueException end |
#to_s ⇒ String
Returns A description of the executable.
763 764 765 |
# File 'lib/sassmagic/reset.rb', line 763 def to_s @opts.to_s end |