Class: Sprockets::Sass::Importer

Inherits:
Sass::Importers::Base
  • Object
show all
Defined in:
lib/sprockets/sass/importer.rb

Constant Summary collapse

GLOB =
/\*|\[.+\]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Importer

Returns a new instance of Importer.



13
14
15
# File 'lib/sprockets/sass/importer.rb', line 13

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Reference to the Sprockets context



10
11
12
# File 'lib/sprockets/sass/importer.rb', line 10

def context
  @context
end

Instance Method Details

#find(path, options) ⇒ Object

See Also:

  • Sass::Importers::Base#find


27
28
29
# File 'lib/sprockets/sass/importer.rb', line 27

def find(path, options)
  engine_from_path(path, nil, options)
end

#find_relative(path, base_path, options) ⇒ Object

See Also:

  • Sass::Importers::Base#find_relative


18
19
20
21
22
23
24
# File 'lib/sprockets/sass/importer.rb', line 18

def find_relative(path, base_path, options)
  if path =~ GLOB
    engine_from_glob(path, base_path, options)
  else
    engine_from_path(path, base_path, options)
  end
end

#key(path, options) ⇒ Object

See Also:

  • Sass::Importers::Base#key


41
42
43
44
# File 'lib/sprockets/sass/importer.rb', line 41

def key(path, options)
  path = Pathname.new(path)
  ["#{self.class.name}:#{path.dirname.expand_path}", path.basename]
end

#mtime(path, options) ⇒ Object

See Also:

  • Sass::Importers::Base#mtime


32
33
34
35
36
37
38
# File 'lib/sprockets/sass/importer.rb', line 32

def mtime(path, options)
  if pathname = resolve(path)
    pathname.mtime
  end
rescue Errno::ENOENT
  nil
end

#to_sObject

See Also:

  • Sass::Importers::Base#to_s


47
48
49
# File 'lib/sprockets/sass/importer.rb', line 47

def to_s
  "#{self.class.name}:#{context.pathname}"
end