Class: Haml::Exec::CSS2Sass
Overview
The css2sass
executable.
Instance Method Summary collapse
-
#initialize(args) ⇒ CSS2Sass
constructor
A new instance of CSS2Sass.
-
#process_result
Processes the options set by the command-line arguments, and runs the CSS compiler appropriately.
-
#set_opts(opts)
Tells optparse how to parse the arguments.
Methods inherited from Generic
Constructor Details
#initialize(args) ⇒ CSS2Sass
Returns a new instance of CSS2Sass.
527 528 529 530 |
# File 'lib/haml/exec.rb', line 527
def initialize(args)
super
@module_opts = {}
end
|
Instance Method Details
#process_result
Processes the options set by the command-line arguments, and runs the CSS compiler appropriately.
555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/haml/exec.rb', line 555
def process_result
super
require 'sass/css'
input = @options[:input]
output = @options[:output]
output.write(::Sass::CSS.new(input, @module_opts).render)
rescue ::Sass::SyntaxError => e
raise e if @options[:trace]
raise "Syntax error on line #{get_line e}: #{e.message}\n Use --trace for backtrace"
end
|
#set_opts(opts)
Tells optparse how to parse the arguments.
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/haml/exec.rb', line 535
def set_opts(opts)
opts.banner = <<END
Usage: css2sass [options] [INPUT] [OUTPUT]
Description: Transforms a CSS file into corresponding Sass code.
Options:
END
opts.on('--old', 'Output the old-style ":prop val" property syntax') do
@module_opts[:old] = true
end
opts.on_tail('-a', '--alternate', 'Ignored') {}
super
end
|