All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.sass-3.5.5.lib.sass.exec.sass_convert.rb Maven / Gradle / Ivy

There is a newer version: 3.7.2
Show newest version
require 'optparse'
require 'fileutils'

module Sass::Exec
  # The `sass-convert` executable.
  class SassConvert < Base
    # @param args [Array] The command-line arguments
    def initialize(args)
      super
      require 'sass'
      @options[:for_tree] = {}
      @options[:for_engine] = {:cache => false, :read_cache => true}
    end

    # Tells optparse how to parse the arguments.
    #
    # @param opts [OptionParser]
    def set_opts(opts)
      opts.banner = < e
      raise e if @options[:trace]
      file = " of #{e.sass_filename}" if e.sass_filename
      raise "Error on line #{e.sass_line}#{file}: #{e.message}\n  Use --trace for backtrace"
    rescue LoadError => err
      handle_load_error(err)
    end

    def path_for(file)
      return file.path if file.is_a?(File)
      return file if file.is_a?(String)
    end

    def read(file)
      if file.respond_to?(:read)
        file.read
      else
        open(file, 'rb') {|f| f.read}
      end
    end
  end
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy