Class: Sass::Exec::SassConvert

Inherits:
Base
  • Object
show all
Defined in:
lib/sassmagic/reset.rb

Overview

The ‘sass-convert` executable.

Instance Method Summary collapse

Methods inherited from Base

#parse, #parse!, #to_s

Constructor Details

#initialize(args) ⇒ SassConvert

Returns a new instance of SassConvert.

Parameters:

  • args (Array<String>)

    The command-line arguments



912
913
914
915
916
917
# File 'lib/sassmagic/reset.rb', line 912

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

Instance Method Details

#process_resultObject

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



940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
# File 'lib/sassmagic/reset.rb', line 940

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) ⇒ Object

Tells optparse how to parse the arguments.

Parameters:

  • opts (OptionParser)


922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
# File 'lib/sassmagic/reset.rb', line 922

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