class Sass::Importers::Filesystem
Simply loads Sass files from the filesystem using the default logic.
The default importer, used for any strings found in the load path.
def _find(dir, name, options)
def _find(dir, name, options) full_filename, syntax = find_real_file(dir, name) return unless full_filename && File.readable?(full_filename) options[:syntax] = syntax options[:filename] = full_filename options[:importer] = self Sass::Engine.new(File.read(full_filename), options) end
def eql?(other)
def eql?(other) root.eql?(other.root) end
def escape_glob_characters(name)
def escape_glob_characters(name) name.gsub(/[\*\[\]\{\}\?]/) do |char| "\\#{char}" end end
def extensions
-
({String => Symbol})
-
def extensions {'sass' => :sass, 'scss' => :scss} end
def find(name, options)
- See: Base#find -
def find(name, options) _find(@root, name, options) end
def find_real_file(dir, name)
-
((String, Symbol))
- A filename-syntax pair.
Parameters:
-
name
(String
) -- The filename to search for. -
dir
(String
) -- The directory relative to which to search.
def find_real_file(dir, name) for (f,s) in possible_files(remove_root(name)) path = (dir == "." || Pathname.new(f).absolute?) ? f : "#{dir}/#{f}" if full_path = Dir[path].first full_path.gsub!(REDUNDANT_DIRECTORY,File::SEPARATOR) return full_path, s end end nil end
def find_relative(name, base, options)
- See: Base#find_relative -
def find_relative(name, base, options) _find(File.dirname(base), name, options) end
def hash
def hash @root.hash end
def initialize(root)
-
root
(String
) -- The root path.
def initialize(root) @root = File.expand_path(root) end
def join(base, path)
def join(base, path) Pathname.new(base).join(path).to_s end
def key(name, options)
- See: Base#key -
def key(name, options) [self.class.name + ":" + File.dirname(File.expand_path(name)), File.basename(name)] end
def mtime(name, options)
- See: Base#mtime -
def mtime(name, options) file, s = find_real_file(@root, name) File.mtime(file) if file rescue Errno::ENOENT nil end
def possible_files(name)
-
(Array(String, Symbol))
- An array of pairs.
Parameters:
-
name
(String
) -- The filename.
def possible_files(name) name = escape_glob_characters(name) dirname, basename, extname = split(name) sorted_exts = extensions.sort syntax = extensions[extname] return [["#{dirname}/{_,}#{basename}.#{extensions.invert[syntax]}", syntax]] if syntax sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]} end
def remove_root(name)
If a full uri is passed, this removes the root from it
def remove_root(name) if name.index(@root + "/") == 0 name[(@root.length + 1)..-1] else name end end
def split(name)
Splits a filename into three parts, a directory part, a basename, and an extension
def split(name) extension = nil dirname, basename = File.dirname(name), File.basename(name) if basename =~ /^(.*)\.(#{extensions.keys.map{|e| Regexp.escape(e)}.join('|')})$/ basename = $1 extension = $2 end [dirname, basename, extension] end
def to_s
- See: Base#to_s -
def to_s @root end