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



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

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

#evaluate(path) ⇒ Object

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



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

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:

  • (Boolean)


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

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