Module: Paste::Resolver

Included in:
Glue, Glue
Defined in:
lib/paste/resolver.rb

Instance Method Summary collapse

Instance Method Details

#find(source) ⇒ Object

Raises:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/paste/resolver.rb', line 32

def find source
  source += '.js' unless source.end_with?('.js') || source.end_with?('.erb')

  path = (load_path + ['']).detect do |path|
    File.exists? File.join(path, source)
  end

  raise ResolveError, "Source #{source} couldn't be found!" if path.nil?

  File.join(path, source)
end

#load_pathObject



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

def load_path
  config.js_load_path.map { |p| resolve p }
end

#resolve(path) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/paste/resolver.rb', line 7

def resolve path
  if Pathname.new(path).absolute?
    File.expand_path path
  else
    File.join config.root, path
  end
end