Class: Sass::Exec::Base
- Inherits:
-
Object
- Object
- Sass::Exec::Base
- Defined in:
- .ruby-sass/lib/sass/exec/base.rb
Overview
The abstract base class for Sass executables.
Direct Known Subclasses
Direct Known Subclasses
Constant Summary
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
7 8 9 10 |
# File '.ruby-sass/lib/sass/exec/base.rb', line 7 def initialize(args) @args = args @options = {} end |
Constructor Details
#initialize(args) ⇒ Base
Returns a new instance of Base
7 8 9 10 |
# File '.ruby-sass/lib/sass/exec/base.rb', line 7 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.
48 49 50 51 52 53 54 55 |
# File '.ruby-sass/lib/sass/exec/base.rb', line 48 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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File '.ruby-sass/lib/sass/exec/base.rb', line 16 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 Sass::Util.windows? ? 13 : 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
58 59 60 |
# File '.ruby-sass/lib/sass/exec/base.rb', line 58 def to_s @opts.to_s end |