trackman 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/trackman/path/rails32_resolver.rb +10 -4
- data/lib/trackman/version.rb +1 -1
- data/spec/rails32_resolver_spec.rb +12 -0
- metadata +1 -1
@@ -1,8 +1,10 @@
|
|
1
1
|
module Trackman
|
2
2
|
module Path
|
3
3
|
module Rails32Resolver
|
4
|
-
include
|
4
|
+
include RailsResolver
|
5
5
|
|
6
|
+
alias old_rails_translate translate
|
7
|
+
|
6
8
|
def translate url, parent_url
|
7
9
|
root = working_dir.realpath
|
8
10
|
|
@@ -14,16 +16,20 @@ module Trackman
|
|
14
16
|
begin
|
15
17
|
path = sprockets.resolve path
|
16
18
|
rescue Sprockets::FileNotFound => e
|
17
|
-
Trackman::Utility::Debugger.trace "
|
18
|
-
return
|
19
|
+
Trackman::Utility::Debugger.trace "Sprocket did not find path: #{path}\n#{e.message}"
|
20
|
+
return old_rails_translate(url, parent_url)
|
19
21
|
end
|
20
22
|
path.relative_path_from(root).to_s
|
21
23
|
end
|
22
24
|
|
25
|
+
|
23
26
|
def prepare_for_sprocket path, parent_url, root
|
24
27
|
folder = (root + Pathname.new(parent_url)).parent.realpath
|
25
28
|
path = (folder + path).to_s
|
26
|
-
|
29
|
+
|
30
|
+
same_path = sprockets.paths.select{|p| path.include? p }.first
|
31
|
+
path.slice!(same_path) unless same_path.nil?
|
32
|
+
|
27
33
|
path
|
28
34
|
end
|
29
35
|
|
data/lib/trackman/version.rb
CHANGED
@@ -19,5 +19,17 @@ describe Trackman::Path::Rails32Resolver do
|
|
19
19
|
|
20
20
|
lambda { @test.translate 'some/path', 'path/to/my/parent' }.should_not raise_error
|
21
21
|
end
|
22
|
+
|
23
|
+
it "can resolve public assets when sprocket cannot find anything" do
|
24
|
+
sprocket = double "SprocketEnvironment"
|
25
|
+
sprocket.stub(:paths).and_return([])
|
26
|
+
sprocket.stub(:resolve).and_raise Sprockets::FileNotFound
|
22
27
|
|
28
|
+
@test.stub(:sprockets).and_return(sprocket)
|
29
|
+
|
30
|
+
result = @test.translate 'favicon.ico', 'spec/fixtures/rails32/happy-path/public/503.html'
|
31
|
+
|
32
|
+
#I know path is not good but I think this is what we want to achieve
|
33
|
+
result.should == 'public/spec/fixtures/rails32/happy-path/public/favicon.ico'
|
34
|
+
end
|
23
35
|
end
|