Class: Sass::Importers::JsonImporter

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ JsonImporter

Creates a new filesystem importer that imports files relative to a given path.

Parameters:

  • root (String)

    The root path. This importer will import files relative to this path.



33
34
35
36
# File 'lib/JsonImporter.rb', line 33

def initialize(root)
  @root = File.expand_path(root)
  @same_name_warnings = Set.new
end

Instance Attribute Details

#rootObject

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

Returns:

  • (Boolean)


82
83
84
# File 'lib/JsonImporter.rb', line 82

def eql?(other)
  root.eql?(other.root)
end

#find(name, options) ⇒ Object

See Also:

  • Base#find


53
54
55
# File 'lib/JsonImporter.rb', line 53

def find(name, options)
  _find(@root, name, options)
end

#find_relative(name, base, options) ⇒ Object

See Also:

  • Base#find_relative


48
49
50
# File 'lib/JsonImporter.rb', line 48

def find_relative(name, base, options)
  _find(File.dirname(base), name, options)
end

#hashObject



78
79
80
# File 'lib/JsonImporter.rb', line 78

def hash
  @root.hash
end

#key(name, options) ⇒ Object

See Also:

  • Base#key


67
68
69
70
71
# File 'lib/JsonImporter.rb', line 67

def key(name, options)
  name = strip_varname(name);
  [self.class.name + ":" + File.dirname(File.expand_path(name)),
    File.basename(name)]
end

#mtime(name, options) ⇒ Object

See Also:

  • Base#mtime


58
59
60
61
62
63
64
# File 'lib/JsonImporter.rb', line 58

def mtime(name, options)
  name = strip_varname(name);
  file, _ = Sass::Util.destructure(find_real_file(@root, name, options))
  File.mtime(file) if file
rescue Errno::ENOENT
  nil
end

#to_sObject

See Also:

  • Base#to_s


74
75
76
# File 'lib/JsonImporter.rb', line 74

def to_s
  @root
end

#watched_directoriesObject

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+

Returns:

  • (Boolean)


44
45
46
# File 'lib/JsonImporter.rb', line 44

def watched_file?(file)
  file.start_with?(root+File::SEPARATOR) && File.extname(file) == ".json"
end