Class: Sass::Importers::JsonImporter
- Inherits:
-
Base
- Object
- Base
- Sass::Importers::JsonImporter
- Defined in:
- lib/JsonImporter.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.
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #find(name, options) ⇒ Object
- #find_relative(name, base, options) ⇒ Object
- #hash ⇒ Object
-
#initialize(root) ⇒ JsonImporter
constructor
Creates a new filesystem importer that imports files relative to a given path.
- #key(name, options) ⇒ Object
- #mtime(name, options) ⇒ Object
- #to_s ⇒ Object
-
#watched_directories ⇒ Object
Enable watching of json files in Sass 3.3+.
-
#watched_file?(file) ⇒ Boolean
Enable watching of json files in Sass 3.3+.
Constructor Details
#initialize(root) ⇒ JsonImporter
Creates a new filesystem importer that imports files relative to a given path.
33 34 35 36 |
# File 'lib/JsonImporter.rb', line 33 def initialize(root) @root = File.(root) @same_name_warnings = Set.new end |
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
27 28 29 |
# File 'lib/JsonImporter.rb', line 27 def root @root end |
Instance Method Details
#eql?(other) ⇒ Boolean
82 83 84 |
# File 'lib/JsonImporter.rb', line 82 def eql?(other) root.eql?(other.root) end |
#find(name, options) ⇒ Object
53 54 55 |
# File 'lib/JsonImporter.rb', line 53 def find(name, ) _find(@root, name, ) end |
#find_relative(name, base, options) ⇒ Object
48 49 50 |
# File 'lib/JsonImporter.rb', line 48 def find_relative(name, base, ) _find(File.dirname(base), name, ) end |
#hash ⇒ Object
78 79 80 |
# File 'lib/JsonImporter.rb', line 78 def hash @root.hash end |
#key(name, options) ⇒ Object
67 68 69 70 71 |
# File 'lib/JsonImporter.rb', line 67 def key(name, ) name = strip_varname(name); [self.class.name + ":" + File.dirname(File.(name)), File.basename(name)] end |
#mtime(name, options) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/JsonImporter.rb', line 58 def mtime(name, ) name = strip_varname(name); file, _ = Sass::Util.destructure(find_real_file(@root, name, )) File.mtime(file) if file rescue Errno::ENOENT nil end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/JsonImporter.rb', line 74 def to_s @root end |
#watched_directories ⇒ Object
Enable watching of json files in Sass 3.3+
39 40 41 |
# File 'lib/JsonImporter.rb', line 39 def watched_directories [root] end |
#watched_file?(file) ⇒ Boolean
Enable watching of json files in Sass 3.3+
44 45 46 |
# File 'lib/JsonImporter.rb', line 44 def watched_file?(file) file.start_with?(root+File::SEPARATOR) && File.extname(file) == ".json" end |