Class: Sass::Exec::SassScss

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

Overview

The sass and scss executables.

Constant Summary

Constants inherited from Base

Base::COLORS

Instance Attribute Summary collapse

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, default_syntax) ⇒ SassScss

Returns a new instance of SassScss.

Parameters:

  • args (Array<String>)

    The command-line arguments



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

def initialize(args, default_syntax)
  super(args)
  @options[:sourcemap] = :auto
  @options[:for_engine] = {
    :load_paths => default_sass_path
  }
  @default_syntax = default_syntax
end

Instance Attribute Details

#default_syntax (readonly)

Returns the value of attribute default_syntax.



4
5
6
# File 'lib/sass/exec/sass_scss.rb', line 4

def default_syntax
  @default_syntax
end

Instance Method Details

#process_result (protected)

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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sass/exec/sass_scss.rb', line 37

def process_result
  require 'sass'

  if !@options[:update] && !@options[:watch] &&
      @args.first && colon_path?(@args.first)
    if @args.size == 1
      @args = split_colon_path(@args.first)
    else
      @fake_update = true
      @options[:update] = true
    end
  end
  load_compass if @options[:compass]
  return interactive if @options[:interactive]
  return watch_or_update if @options[:watch] || @options[:update]
  super

  if @options[:sourcemap] != :none && @options[:output_filename]
    @options[:sourcemap_filename] = Sass::Util.sourcemap_name(@options[:output_filename])
  end

  @options[:for_engine][:filename] = @options[:filename]
  @options[:for_engine][:css_filename] = @options[:output] if @options[:output].is_a?(String)
  @options[:for_engine][:sourcemap_filename] = @options[:sourcemap_filename]
  @options[:for_engine][:sourcemap] = @options[:sourcemap]

  run
end

#set_opts(opts) (protected)

Tells optparse how to parse the arguments.

Parameters:

  • opts (OptionParser)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sass/exec/sass_scss.rb', line 21

def set_opts(opts)
  opts.banner = <<END
Usage: #{default_syntax} [options] [INPUT] [OUTPUT]

Description:
  Converts SCSS or Sass files to CSS.
END

  common_options(opts)
  watching_and_updating(opts)
  input_and_output(opts)
  miscellaneous(opts)
end