### コンパイル対象を絞り込みするオプション
# 指定がない場合のコンパイル対象
DEFAULT_TARGET_PATTERN = "IE"
# 値にマッチするscssファイルをコンパイル対象として絞り込む
SASS_FILE_PATTERNS = {
  "IE" => "^.*ie.*$",
  "PRINT" => "^.*print.*$",
}
TARGET_PATTERN = DEFAULT_TARGET_PATTERN


### コンパイル対象を絞り込む対応
module ::Compass
  class Compiler
    def sass_files(options = {})
      exclude_partials = options.fetch(:exclude_partials, true)
      opt_sass_files = self.options[:sass_files]

      # ファイル指定あり
      if opt_sass_files
        return opt_sass_files
      end

      # ファイル指定なし
      sass_files =  Dir.glob(separate("#{from}/**/#{'[^_]' if exclude_partials}*.s[ac]ss"))


      ##### 取得したsass_filesを操作することで、コンパイル対象を変更することができる
      target_pattern = SASS_FILE_PATTERNS[TARGET_PATTERN]

      # 指定がないので絞り込ままい
      if target_pattern.nil? || target_pattern.empty?
        return sass_files
      end

      # 指定があるので正規表現で絞り込み
      target_regexp = Regexp.new(target_pattern)
      _sass_files = []
      sass_files.each do |file|
        _file = File.basename(file)
        if target_regexp =~ _file
          _sass_files.push(file)
        end
      end
      return _sass_files
      #####
    end
  end
end