Class: SassC::Rails::Importer

Inherits:
Importer
  • Object
show all
Defined in:
lib/sassc/importer.rb

Defined Under Namespace

Classes: CSSExtension, Extension

Constant Summary collapse

EXTENSIONS =
[
  Extension.new(".scss"),
  Extension.new(".sass"),
  CSSExtension.new
]
PREFIXS =
[ "", "_" ]
GLOB =
/(\A|\/)(\*|\*\*\/\*)\z/

Instance Method Summary collapse

Instance Method Details

#imports(path, parent_path) ⇒ Object



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
65
66
67
68
69
70
71
# File 'lib/sassc/importer.rb', line 38

def imports(path, parent_path)
  parent_dir, _ = File.split(parent_path)
  specified_dir, specified_file = File.split(path)

  if m = path.match(GLOB)
    path = path.sub(m[0], "")
    base = File.expand_path(path, File.dirname(parent_path))
    return glob_imports(base, m[2], parent_path)
  end

  search_paths = ([parent_dir] + load_paths).uniq

  if specified_dir != "."
    search_paths.map! do |path|
      File.join(path, specified_dir)
    end
  end

  search_paths.each do |search_path|
    PREFIXS.each do |prefix|
      file_name = prefix + specified_file

      EXTENSIONS.each do |extension|
        try_path = File.join(search_path, file_name + extension.postfix)
        if File.exists?(try_path)
          record_import_as_dependency try_path
          return extension.import_for(try_path, parent_dir, options)
        end
      end
    end
  end

  SassC::Importer::Import.new(path)
end