trackman 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/trackman/assets/asset_factory.rb +1 -1
- data/lib/trackman/path/rails32_resolver.rb +4 -4
- data/lib/trackman/path/resolver.rb +8 -7
- data/lib/trackman/path.rb +0 -1
- data/lib/trackman/version.rb +1 -1
- data/spec/fixtures/sprockets/app/assets/images/trackman70x70.png +5359 -0
- data/spec/helpers/fakable_pathman_tester.rb +8 -1
- data/spec/paths/{rails32_pathman_spec.rb → rails32_resolver_spec.rb} +23 -0
- data/spec/paths/{pathman_spec.rb → resolver_spec.rb} +16 -2
- data/spec/rails32_resolver_spec.rb +13 -2
- data/spec/spec_helper.rb +0 -1
- metadata +7 -6
- data/lib/trackman/path/rails_resolver.rb +0 -29
@@ -1,5 +1,5 @@
|
|
1
1
|
class FakablePathManTester
|
2
|
-
@@modules = [Resolver, Rails32Resolver
|
2
|
+
@@modules = [Resolver, Rails32Resolver]
|
3
3
|
Conventions = Trackman::Components::Conventions
|
4
4
|
|
5
5
|
def self.switch_on prepath
|
@@ -18,10 +18,14 @@ class FakablePathManTester
|
|
18
18
|
|
19
19
|
Resolver.module_eval do
|
20
20
|
alias real_working_dir working_dir
|
21
|
+
alias real_file_exist file_exist?
|
21
22
|
|
22
23
|
define_method :working_dir do
|
23
24
|
real_working_dir + prepath
|
24
25
|
end
|
26
|
+
define_method :file_exist? do |path|
|
27
|
+
File.exist?(prepath + path)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
@@modules.each do |m|
|
@@ -84,6 +88,9 @@ class FakablePathManTester
|
|
84
88
|
Resolver.module_eval do
|
85
89
|
alias :working_dir :real_working_dir
|
86
90
|
remove_method :real_working_dir
|
91
|
+
|
92
|
+
alias file_exist? real_file_exist
|
93
|
+
remove_method :real_file_exist
|
87
94
|
end
|
88
95
|
|
89
96
|
@@modules.each do |m|
|
@@ -11,6 +11,19 @@ end
|
|
11
11
|
|
12
12
|
|
13
13
|
describe Rails32Resolver do
|
14
|
+
before :all do
|
15
|
+
module Resolver
|
16
|
+
alias old_exist file_exist?
|
17
|
+
def file_exist? path
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
after :all do
|
23
|
+
module Resolver
|
24
|
+
alias file_exist? old_exist
|
25
|
+
end
|
26
|
+
end
|
14
27
|
it "serves an image linked by an html" do
|
15
28
|
parent_url = 'public/503.html'
|
16
29
|
url = '/assets/bombero.jpeg'
|
@@ -100,4 +113,14 @@ describe Rails32Resolver do
|
|
100
113
|
|
101
114
|
actual.should == expected
|
102
115
|
end
|
116
|
+
|
117
|
+
it "can find this image" do
|
118
|
+
parent_url = 'public/503.html'
|
119
|
+
url = 'assets/trackman70x70.png'
|
120
|
+
|
121
|
+
actual = Rails32Tester.translate url, parent_url
|
122
|
+
expected = 'app/assets/images/trackman70x70.png'
|
123
|
+
|
124
|
+
actual.should == expected
|
125
|
+
end
|
103
126
|
end
|
@@ -5,6 +5,20 @@ class PathTester
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe Resolver do
|
8
|
+
before :all do
|
9
|
+
module Resolver
|
10
|
+
alias old_exist file_exist?
|
11
|
+
def file_exist? path
|
12
|
+
true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
after :all do
|
17
|
+
module Resolver
|
18
|
+
alias file_exist? old_exist
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
8
22
|
it 'gives a path at the same level as the parent if the url is relative and there is no parent specified' do
|
9
23
|
parent_url = 'allo/home.html'
|
10
24
|
url = 'bob.jpg'
|
@@ -20,7 +34,7 @@ describe Resolver do
|
|
20
34
|
url = '/bob.jpg'
|
21
35
|
|
22
36
|
actual = PathTester.translate url, parent_url
|
23
|
-
expected = 'bob.jpg'
|
37
|
+
expected = 'public/bob.jpg'
|
24
38
|
|
25
39
|
actual.should == expected
|
26
40
|
end
|
@@ -37,7 +51,7 @@ describe Resolver do
|
|
37
51
|
url = '/johnny/cash/likes/women/but/not/bob.jpg'
|
38
52
|
|
39
53
|
actual = PathTester.translate url, parent_url
|
40
|
-
expected = 'johnny/cash/likes/women/but/not/bob.jpg'
|
54
|
+
expected = 'public/johnny/cash/likes/women/but/not/bob.jpg'
|
41
55
|
|
42
56
|
actual.should == expected
|
43
57
|
end
|
@@ -29,7 +29,18 @@ describe Trackman::Path::Rails32Resolver do
|
|
29
29
|
|
30
30
|
result = @test.translate 'favicon.ico', 'spec/fixtures/rails32/happy-path/public/503.html'
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
result.should == 'spec/fixtures/rails32/happy-path/public/favicon.ico'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns nil it cannot find anything" do
|
36
|
+
sprocket = double "SprocketEnvironment"
|
37
|
+
sprocket.stub(:paths).and_return([])
|
38
|
+
sprocket.stub(:resolve).and_raise Sprockets::FileNotFound
|
39
|
+
|
40
|
+
@test.stub(:sprockets).and_return(sprocket)
|
41
|
+
|
42
|
+
result = @test.translate 'non-existent.jpg', 'spec/fixtures/rails32/happy-path/public/503.html'
|
43
|
+
|
44
|
+
result.should be_nil
|
34
45
|
end
|
35
46
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -44,5 +44,4 @@ RemoteAsset = Trackman::Assets::RemoteAsset unless defined?(RemoteAsset)
|
|
44
44
|
|
45
45
|
Resolver = Trackman::Path::Resolver unless defined?(Resolver)
|
46
46
|
Rails32Resolver = Trackman::Path::Rails32Resolver unless defined?(Rails32Resolver)
|
47
|
-
RailsResolver = Trackman::Path::RailsResolver unless defined?(RailsResolver)
|
48
47
|
Configuration = Trackman::Utility::Configuration unless defined?(Configuration)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -184,7 +184,6 @@ files:
|
|
184
184
|
- lib/trackman/errors/config_setup_error.rb
|
185
185
|
- lib/trackman/path.rb
|
186
186
|
- lib/trackman/path/rails32_resolver.rb
|
187
|
-
- lib/trackman/path/rails_resolver.rb
|
188
187
|
- lib/trackman/path/resolver.rb
|
189
188
|
- lib/trackman/scaffold.rb
|
190
189
|
- lib/trackman/scaffold/content_saver.rb
|
@@ -441,6 +440,7 @@ files:
|
|
441
440
|
- spec/fixtures/sprockets/app/assets/images/bombero/tralala/img.jpg
|
442
441
|
- spec/fixtures/sprockets/app/assets/images/image.jpg
|
443
442
|
- spec/fixtures/sprockets/app/assets/images/img.png
|
443
|
+
- spec/fixtures/sprockets/app/assets/images/trackman70x70.png
|
444
444
|
- spec/fixtures/sprockets/app/assets/stylesheets/a/css.css
|
445
445
|
- spec/fixtures/sprockets/app/assets/stylesheets/bombero.css
|
446
446
|
- spec/fixtures/sprockets/app/assets/stylesheets/bombero/tralala/trundle.css
|
@@ -451,8 +451,8 @@ files:
|
|
451
451
|
- spec/helpers/app_creator.rb
|
452
452
|
- spec/helpers/fakable_pathman_tester.rb
|
453
453
|
- spec/html_asset_spec.rb
|
454
|
-
- spec/paths/
|
455
|
-
- spec/paths/
|
454
|
+
- spec/paths/rails32_resolver_spec.rb
|
455
|
+
- spec/paths/resolver_spec.rb
|
456
456
|
- spec/rails2311/first_push_spec.rb
|
457
457
|
- spec/rails32/first_push_spec.rb
|
458
458
|
- spec/rails32_resolver_spec.rb
|
@@ -756,6 +756,7 @@ test_files:
|
|
756
756
|
- spec/fixtures/sprockets/app/assets/images/bombero/tralala/img.jpg
|
757
757
|
- spec/fixtures/sprockets/app/assets/images/image.jpg
|
758
758
|
- spec/fixtures/sprockets/app/assets/images/img.png
|
759
|
+
- spec/fixtures/sprockets/app/assets/images/trackman70x70.png
|
759
760
|
- spec/fixtures/sprockets/app/assets/stylesheets/a/css.css
|
760
761
|
- spec/fixtures/sprockets/app/assets/stylesheets/bombero.css
|
761
762
|
- spec/fixtures/sprockets/app/assets/stylesheets/bombero/tralala/trundle.css
|
@@ -766,8 +767,8 @@ test_files:
|
|
766
767
|
- spec/helpers/app_creator.rb
|
767
768
|
- spec/helpers/fakable_pathman_tester.rb
|
768
769
|
- spec/html_asset_spec.rb
|
769
|
-
- spec/paths/
|
770
|
-
- spec/paths/
|
770
|
+
- spec/paths/rails32_resolver_spec.rb
|
771
|
+
- spec/paths/resolver_spec.rb
|
771
772
|
- spec/rails2311/first_push_spec.rb
|
772
773
|
- spec/rails32/first_push_spec.rb
|
773
774
|
- spec/rails32_resolver_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Trackman
|
2
|
-
module Path
|
3
|
-
module RailsResolver
|
4
|
-
include Resolver
|
5
|
-
|
6
|
-
alias old_translate translate
|
7
|
-
alias old_parent_of parent_of
|
8
|
-
|
9
|
-
def parent_of(url)
|
10
|
-
if url.to_s.include?('assets')
|
11
|
-
old_parent_of(url).ascend do |p|
|
12
|
-
return p if p.basename.to_s == 'assets'
|
13
|
-
end
|
14
|
-
else
|
15
|
-
return old_parent_of(url)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def translate url, parent_url
|
20
|
-
path = old_translate(url, parent_url)
|
21
|
-
|
22
|
-
parts = path.split('/')
|
23
|
-
parts.insert(0, 'public') if parts.first != 'public'
|
24
|
-
|
25
|
-
parts.join('/')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|