Module: Trackman::Path::Rails32Resolver
- Includes:
- Resolver
- Defined in:
- lib/trackman/path/rails32_resolver.rb
Instance Method Summary
collapse
Methods included from Resolver
#file_exist?, #parent_of, #working_dir
Instance Method Details
#old_rails_translate ⇒ Object
6
|
# File 'lib/trackman/path/rails32_resolver.rb', line 6
alias old_rails_translate translate
|
#prepare_for_sprocket(path, parent_url, root) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/trackman/path/rails32_resolver.rb', line 25
def prepare_for_sprocket path, parent_url, root
folder = (root + Pathname.new(parent_url)).parent.realpath
path = (folder + path).to_s
same_path = sprockets.paths.select{|p| path.include? p }.first
path.slice!(same_path) unless same_path.nil?
path
end
|
#sprockets ⇒ Object
35
36
37
|
# File 'lib/trackman/path/rails32_resolver.rb', line 35
def sprockets
::Rails.application.assets
end
|
#translate(url, parent_url) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/trackman/path/rails32_resolver.rb', line 8
def translate url, parent_url
root = working_dir.realpath
path = url.dup
path.slice! /^\/?assets/
path = Pathname.new(path)
path = prepare_for_sprocket(path, parent_url, root) if path.relative?
begin
path = sprockets.resolve path
rescue Sprockets::FileNotFound => e
Trackman::Utility::Debugger.trace "Sprocket did not find path: #{path}\n#{e.message}"
return old_rails_translate(url, parent_url)
end
path.relative_path_from(root).to_s
end
|