Class: Emcee::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/emcee/resolver.rb

Overview

Resolver is responsible for interfacing with Sprockets.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Resolver

Returns a new instance of Resolver.



4
5
6
7
# File 'lib/emcee/resolver.rb', line 4

def initialize(context)
  @context = context
  @directory = File.dirname(context.pathname)
end

Instance Method Details

#absolute_path(path) ⇒ Object



32
33
34
# File 'lib/emcee/resolver.rb', line 32

def absolute_path(path)
  File.absolute_path(path, @directory)
end

#depend_on_asset(path) ⇒ Object

Allows to state an asset dependency without including it



16
17
18
# File 'lib/emcee/resolver.rb', line 16

def depend_on_asset(path)
  @context.depend_on_asset(path)
end

#evaluate(path) ⇒ Object

Return the contents of a file. Does any required processing, such as SCSS or CoffeeScript.



22
23
24
# File 'lib/emcee/resolver.rb', line 22

def evaluate(path)
  @context.evaluate(path)
end

#require_asset(path) ⇒ Object

Declare a file as a dependency to Sprockets. The dependency will be included in the application’s html bundle.



11
12
13
# File 'lib/emcee/resolver.rb', line 11

def require_asset(path)
  @context.require_asset(path)
end

#should_inline?(path) ⇒ Boolean

Indicate if an asset should be inlined or not. References to files at an external web address, for example, should not be inlined.

Returns:



28
29
30
# File 'lib/emcee/resolver.rb', line 28

def should_inline?(path)
  path !~ /\A\/\//
end