Class: Sass::Exec::SassConvert

Inherits:
Base
  • Object
show all
Defined in:
lib/sass/exec/sass_convert.rb

Overview

The sass-convert executable.

Constant Summary

Constants inherited from Base

Base::COLORS

Instance Method Summary collapse

Methods inherited from Base

#color, #encoding_option, #get_line, #parse, #parse!, #puts, #puts_action, #to_s, #write_output

Constructor Details

#initialize(args) ⇒ SassConvert

Returns a new instance of SassConvert.

Parameters:

  • args (Array<String>)

    The command-line arguments



8
9
10
11
12
13
# File 'lib/sass/exec/sass_convert.rb', line 8

def initialize(args)
  super
  require 'sass'
  @options[:for_tree] = {}
  @options[:for_engine] = {:cache => false, :read_cache => true}
end

Instance Method Details

#process_result

Processes the options set by the command-line arguments, and runs the CSS compiler appropriately.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sass/exec/sass_convert.rb', line 36

def process_result
  require 'sass'

  if @options[:recursive]
    process_directory
    return
  end

  super
  input = @options[:input]
  if File.directory?(input)
    raise "Error: '#{input.path}' is a directory (did you mean to use --recursive?)"
  end
  output = @options[:output]
  output = input if @options[:in_place]
  process_file(input, output)
end

#set_opts(opts)

Tells optparse how to parse the arguments.

Parameters:

  • opts (OptionParser)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sass/exec/sass_convert.rb', line 18

def set_opts(opts)
  opts.banner = <<END
Usage: sass-convert [options] [INPUT] [OUTPUT]

Description:
  Converts between CSS, indented syntax, and SCSS files. For example,
  this can convert from the indented syntax to SCSS, or from CSS to
  SCSS (adding appropriate nesting).
END

  common_options(opts)
  style(opts)
  input_and_output(opts)
  miscellaneous(opts)
end