Class: Sass::Importers::Filesystem
- Inherits:
-
Base
- Object
- Base
- Sass::Importers::Filesystem
- Defined in:
- .ruby-sass/lib/sass/importers/filesystem.rb
Overview
The default importer, used for any strings found in the load path. Simply loads Sass files from the filesystem using the default logic.
Direct Known Subclasses
Direct Known Subclasses
Constant Summary
Instance Attribute Summary (collapse)
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary (collapse)
- #directories_to_watch ⇒ Object
- #eql?(other) ⇒ Boolean
- #find(name, options) ⇒ Object
- #find_relative(name, base, options) ⇒ Object
- #hash ⇒ Object
-
#initialize(root) ⇒ Filesystem
constructor
Creates a new filesystem importer that imports files relative to a given path.
- #key(name, options) ⇒ Object
- #mtime(name, options) ⇒ Object
- #public_url(name, sourcemap_directory) ⇒ Object
- #to_s ⇒ Object
- #watched_file?(filename) ⇒ Boolean
Constructor Details
#initialize(root) ⇒ Filesystem
Creates a new filesystem importer that imports files relative to a given path.
14 15 16 17 18 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 14 def initialize(root) @root = File.(root) @real_root = Sass::Util.realpath(@root).to_s @same_name_warnings = Set.new end |
Constructor Details
#initialize(root) ⇒ Filesystem
Creates a new filesystem importer that imports files relative to a given path.
14 15 16 17 18 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 14 def initialize(root) @root = File.(root) @real_root = Sass::Util.realpath(@root).to_s @same_name_warnings = Set.new end |
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root
8 9 10 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 8 def root @root end |
Instance Method Details
#directories_to_watch ⇒ Object
58 59 60 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 58 def directories_to_watch [root] end |
#eql?(other) ⇒ Boolean
53 54 55 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 53 def eql?(other) !other.nil? && other.respond_to?(:root) && root.eql?(other.root) end |
#find(name, options) ⇒ Object
26 27 28 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 26 def find(name, ) _find(@root, name, ) end |
#find_relative(name, base, options) ⇒ Object
21 22 23 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 21 def find_relative(name, base, ) _find(File.dirname(base), name, ) end |
#hash ⇒ Object
49 50 51 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 49 def hash @root.hash end |
#key(name, options) ⇒ Object
39 40 41 42 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 39 def key(name, ) [self.class.name + ":" + File.dirname(File.(name)), File.basename(name)] end |
#mtime(name, options) ⇒ Object
31 32 33 34 35 36 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 31 def mtime(name, ) file, _ = Sass::Util.destructure(find_real_file(@root, name, )) File.mtime(file) if file rescue Errno::ENOENT nil end |
#public_url(name, sourcemap_directory) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 69 def public_url(name, sourcemap_directory) file_pathname = Sass::Util.cleanpath(File.absolute_path(name, @root)) return Sass::Util.file_uri_from_path(file_pathname) if sourcemap_directory.nil? sourcemap_pathname = Sass::Util.cleanpath(sourcemap_directory) begin Sass::Util.file_uri_from_path( Sass::Util.relative_path_from(file_pathname, sourcemap_pathname)) rescue ArgumentError # when a relative path cannot be constructed Sass::Util.file_uri_from_path(file_pathname) end end |
#to_s ⇒ Object
45 46 47 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 45 def to_s @root end |
#watched_file?(filename) ⇒ Boolean
63 64 65 66 67 |
# File '.ruby-sass/lib/sass/importers/filesystem.rb', line 63 def watched_file?(filename) # Check against the root with symlinks resolved, since Listen # returns fully-resolved paths. filename =~ /\.s[ac]ss$/ && filename.start_with?(@real_root + File::SEPARATOR) end |