trackman 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/trackman.rb +14 -7
- data/lib/trackman/assets.rb +4 -14
- data/lib/trackman/assets/asset.rb +3 -3
- data/lib/trackman/assets/asset_factory.rb +46 -0
- data/lib/trackman/assets/bundled_asset.rb +26 -0
- data/lib/trackman/assets/composite_asset.rb +40 -0
- data/lib/trackman/assets/css_asset.rb +1 -1
- data/lib/trackman/assets/html_asset.rb +1 -1
- data/lib/trackman/assets/persistence.rb +9 -0
- data/lib/trackman/assets/persistence/remote.rb +54 -0
- data/lib/trackman/assets/remote_asset.rb +4 -45
- data/lib/trackman/assets/remote_asset_factory.rb +11 -0
- data/lib/trackman/components.rb +9 -0
- data/lib/trackman/components/conventions.rb +21 -0
- data/lib/trackman/components/diffable.rb +28 -0
- data/lib/trackman/components/hashable.rb +27 -0
- data/lib/trackman/components/shippable.rb +29 -0
- data/lib/trackman/errors.rb +9 -0
- data/lib/trackman/errors/asset_not_found_error.rb +6 -0
- data/lib/trackman/errors/config_not_found_error.rb +6 -0
- data/lib/trackman/errors/config_setup_error.rb +7 -0
- data/lib/trackman/path.rb +9 -0
- data/lib/trackman/path/rails32_resolver.rb +35 -0
- data/lib/trackman/path/rails_resolver.rb +29 -0
- data/lib/trackman/path/resolver.rb +32 -0
- data/lib/trackman/scaffold.rb +2 -14
- data/lib/trackman/utility.rb +9 -0
- data/lib/trackman/utility/configuration.rb +98 -0
- data/lib/trackman/{core_extensions.rb → utility/core_extensions.rb} +0 -0
- data/lib/trackman/utility/debugger.rb +24 -0
- data/lib/{trackman_railtie.rb → trackman/utility/railtie.rb} +2 -1
- data/lib/trackman/version.rb +1 -1
- data/rails_generators/trackman_tasks/templates/trackman.rake +1 -1
- data/spec/asset_factory_spec.rb +3 -3
- data/spec/asset_spec.rb +1 -1
- data/spec/composite_asset_spec.rb +2 -2
- data/spec/{configuration_handler_spec.rb → configuration_spec.rb} +6 -6
- data/spec/diffable_spec.rb +2 -2
- data/spec/helpers/act_like_rails2311.rb +2 -2
- data/spec/helpers/act_like_rails32.rb +2 -2
- data/spec/helpers/app_creator.rb +12 -5
- data/spec/helpers/fakable_pathman_tester.rb +5 -5
- data/spec/paths/pathman_spec.rb +2 -2
- data/spec/paths/rails32_pathman_spec.rb +2 -2
- data/spec/{rails32_path_resolver_spec.rb → rails32_resolver_spec.rb} +3 -3
- data/spec/remote_asset_spec.rb +13 -17
- data/spec/{scaffolding_spec.rb → scaffold_spec.rb} +0 -0
- data/spec/shippable_spec.rb +2 -2
- data/spec/spec_helper.rb +6 -6
- data/spec/sync_spec.rb +1 -1
- metadata +32 -27
- data/lib/trackman/assets/components.rb +0 -13
- data/lib/trackman/assets/components/asset_factory.rb +0 -48
- data/lib/trackman/assets/components/bundled_asset.rb +0 -29
- data/lib/trackman/assets/components/composite_asset.rb +0 -42
- data/lib/trackman/assets/components/conventions.rb +0 -23
- data/lib/trackman/assets/components/diffable.rb +0 -30
- data/lib/trackman/assets/components/hashable.rb +0 -29
- data/lib/trackman/assets/components/path_resolver.rb +0 -34
- data/lib/trackman/assets/components/rails32_path_resolver.rb +0 -39
- data/lib/trackman/assets/components/rails_path_resolver.rb +0 -31
- data/lib/trackman/assets/components/remote_asset_factory.rb +0 -13
- data/lib/trackman/assets/components/shippable.rb +0 -31
- data/lib/trackman/assets/errors.rb +0 -10
- data/lib/trackman/assets/errors/asset_not_found_error.rb +0 -8
- data/lib/trackman/assets/errors/config_not_found_error.rb +0 -8
- data/lib/trackman/configuration_handler.rb +0 -99
- data/lib/trackman/debugger.rb +0 -9
data/spec/diffable_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Trackman::
|
3
|
+
describe Trackman::Components::Diffable do
|
4
4
|
class TestDiff
|
5
|
-
extend Trackman::
|
5
|
+
extend Trackman::Components::Diffable
|
6
6
|
end
|
7
7
|
|
8
8
|
it "specify the html to update and the image to delete" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
class ActLikeRails2311
|
3
3
|
def self.switch_on
|
4
|
-
Trackman::Assets::
|
4
|
+
Trackman::Assets::AssetFactory.module_eval do
|
5
5
|
alias :old_rails_defined? :rails_defined?
|
6
6
|
alias :old_asset_pipeline_enabled? :asset_pipeline_enabled?
|
7
7
|
|
@@ -16,7 +16,7 @@ class ActLikeRails2311
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.switch_off
|
19
|
-
Trackman::Assets::
|
19
|
+
Trackman::Assets::AssetFactory.module_eval do
|
20
20
|
alias :rails_defined? :old_rails_defined?
|
21
21
|
alias :asset_pipeline_enabled? :old_asset_pipeline_enabled?
|
22
22
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class ActLikeRails32
|
2
2
|
def self.switch_on
|
3
|
-
Trackman::Assets::
|
3
|
+
Trackman::Assets::AssetFactory.module_eval do
|
4
4
|
alias :old_asset_pipeline_enabled? :asset_pipeline_enabled?
|
5
5
|
|
6
6
|
define_method :asset_pipeline_enabled? do
|
@@ -10,7 +10,7 @@ class ActLikeRails32
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.switch_off
|
13
|
-
Trackman::Assets::
|
13
|
+
Trackman::Assets::AssetFactory.module_eval do
|
14
14
|
alias :asset_pipeline_enabled? :old_asset_pipeline_enabled?
|
15
15
|
remove_method :old_asset_pipeline_enabled?
|
16
16
|
end
|
data/spec/helpers/app_creator.rb
CHANGED
@@ -5,7 +5,7 @@ class AppCreator
|
|
5
5
|
|
6
6
|
trackman_url = json['config']['TRACKMAN_URL'].gsub('https', 'http')
|
7
7
|
|
8
|
-
[[
|
8
|
+
[[:server_url, trackman_url], [:site, "#{trackman_url}/assets"]]
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.create
|
@@ -15,8 +15,12 @@ class AppCreator
|
|
15
15
|
|
16
16
|
@@config = get_config "http://#{user}:#{pass}@#{server}/heroku/resources"
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
|
19
|
+
#singleton = class << self; self; end
|
20
|
+
@@config.each do |k, v|
|
21
|
+
alias_method "old_#{k}", k
|
22
|
+
define_method(k, lambda { v })
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
@@config
|
@@ -25,8 +29,11 @@ class AppCreator
|
|
25
29
|
def self.reset
|
26
30
|
RemoteAsset.all.each { |a| a.delete }
|
27
31
|
|
28
|
-
|
29
|
-
|
32
|
+
Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
|
33
|
+
#singleton = class << self; self; end
|
34
|
+
@@config.each do |k,v|
|
35
|
+
alias_method k, "old_#{k}"
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class FakablePathManTester
|
2
|
-
@@modules = [
|
3
|
-
Conventions = Trackman::
|
2
|
+
@@modules = [Resolver, Rails32Resolver, RailsResolver]
|
3
|
+
Conventions = Trackman::Components::Conventions
|
4
4
|
|
5
5
|
def self.switch_on prepath
|
6
6
|
override_remote_assets prepath
|
@@ -16,7 +16,7 @@ class FakablePathManTester
|
|
16
16
|
|
17
17
|
def self.override_resolvers prepath
|
18
18
|
|
19
|
-
|
19
|
+
Resolver.module_eval do
|
20
20
|
alias real_working_dir working_dir
|
21
21
|
|
22
22
|
define_method :working_dir do
|
@@ -81,7 +81,7 @@ class FakablePathManTester
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def self.reset_resolvers
|
84
|
-
|
84
|
+
Resolver.module_eval do
|
85
85
|
alias :working_dir :real_working_dir
|
86
86
|
remove_method :real_working_dir
|
87
87
|
end
|
@@ -92,7 +92,7 @@ class FakablePathManTester
|
|
92
92
|
remove_method :real_translate
|
93
93
|
end
|
94
94
|
end
|
95
|
-
|
95
|
+
Rails32Resolver.send(:class_variable_set, :@@sprockets, nil)
|
96
96
|
end
|
97
97
|
|
98
98
|
def self.reset_conventions
|
data/spec/paths/pathman_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
class PathTester
|
4
|
-
extend
|
4
|
+
extend Resolver
|
5
5
|
end
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe Resolver do
|
8
8
|
it 'gives a path at the same level as the parent if the url is relative and there is no parent specified' do
|
9
9
|
parent_url = 'allo/home.html'
|
10
10
|
url = 'bob.jpg'
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'sprockets'
|
3
3
|
|
4
4
|
class Rails32Tester
|
5
|
-
extend
|
5
|
+
extend Rails32Resolver
|
6
6
|
|
7
7
|
def self.working_dir
|
8
8
|
Pathname.new('spec/fixtures/sprockets')
|
@@ -10,7 +10,7 @@ class Rails32Tester
|
|
10
10
|
end
|
11
11
|
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe Rails32Resolver do
|
14
14
|
it "serves an image linked by an html" do
|
15
15
|
parent_url = 'public/503.html'
|
16
16
|
url = '/assets/bombero.jpeg'
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
class Rails32ResolverTest
|
4
|
-
include
|
4
|
+
include Rails32Resolver
|
5
5
|
end
|
6
6
|
|
7
|
-
describe Trackman::
|
8
|
-
|
7
|
+
describe Trackman::Path::Rails32Resolver do
|
8
|
+
|
9
9
|
before :all do
|
10
10
|
@test = Rails32ResolverTest.new
|
11
11
|
end
|
data/spec/remote_asset_spec.rb
CHANGED
@@ -3,20 +3,8 @@ require 'helpers/app_creator'
|
|
3
3
|
|
4
4
|
describe Trackman::Assets::RemoteAsset do
|
5
5
|
before :each do
|
6
|
-
# user = ENV['HEROKU_USERNAME']
|
7
|
-
# pass = ENV['HEROKU_PASSWORD']
|
8
|
-
# server = ENV['TRACKMAN_SERVER_URL']
|
9
6
|
@old_file = nil
|
10
7
|
@config = AppCreator.create
|
11
|
-
|
12
|
-
# response = RestClient.post "http://#{user}:#{pass}@#{server}/heroku/resources", :plan => 'test', :heroku_id => 123
|
13
|
-
# json = JSON.parse response
|
14
|
-
# @trackman_url = json['config']['TRACKMAN_URL'].gsub('https', 'http')
|
15
|
-
|
16
|
-
# @config = [[:@@server_url, @trackman_url], [:@@site, "#{@trackman_url}/assets"]]
|
17
|
-
# @config.each do |s, v|
|
18
|
-
# RemoteAsset.send(:class_variable_set, s, v)
|
19
|
-
# end
|
20
8
|
end
|
21
9
|
|
22
10
|
after :each do
|
@@ -74,13 +62,21 @@ describe Trackman::Assets::RemoteAsset do
|
|
74
62
|
end
|
75
63
|
|
76
64
|
it "throws if a config is missing" do
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
65
|
+
config = @config
|
66
|
+
begin
|
67
|
+
Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
|
68
|
+
config.each do |k,v|
|
69
|
+
alias_method "temp_#{k}", k
|
70
|
+
define_method(k, lambda{ nil })
|
71
|
+
end
|
81
72
|
end
|
73
|
+
lambda { RemoteAsset.create(:path => 'spec/test_data/a.js') }.should raise_error(Trackman::Errors::ConfigNotFoundError)
|
82
74
|
ensure
|
83
|
-
|
75
|
+
Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
|
76
|
+
config.each do |k,v|
|
77
|
+
alias_method k, "temp_#{k}"
|
78
|
+
end
|
79
|
+
end
|
84
80
|
end
|
85
81
|
end
|
86
82
|
end
|
File without changes
|
data/spec/shippable_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Trackman::
|
3
|
+
describe Trackman::Components::Shippable do
|
4
4
|
class Test
|
5
|
-
extend Trackman::
|
5
|
+
extend Trackman::Components::Shippable
|
6
6
|
|
7
7
|
@@events = []
|
8
8
|
def self.events
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ RSpec.configure do |config|
|
|
12
12
|
config.filter_run :focus
|
13
13
|
end
|
14
14
|
|
15
|
-
module Trackman::
|
15
|
+
module Trackman::Components::BundledAsset
|
16
16
|
def env
|
17
17
|
working_dir = Pathname.new(Dir.pwd)
|
18
18
|
env = ::Sprockets::Environment.new
|
@@ -24,7 +24,7 @@ module Trackman::Assets::Components::BundledAsset
|
|
24
24
|
env
|
25
25
|
end
|
26
26
|
end
|
27
|
-
module Trackman::
|
27
|
+
module Trackman::Path::Rails32Resolver
|
28
28
|
def sprockets
|
29
29
|
env = ::Sprockets::Environment.new
|
30
30
|
paths = ['app', 'lib', 'vendor'].inject([]) do |array, f|
|
@@ -42,7 +42,7 @@ CssAsset = Trackman::Assets::CssAsset unless defined?(CssAsset)
|
|
42
42
|
HtmlAsset = Trackman::Assets::HtmlAsset unless defined?(HtmlAsset)
|
43
43
|
RemoteAsset = Trackman::Assets::RemoteAsset unless defined?(RemoteAsset)
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
Resolver = Trackman::Path::Resolver unless defined?(Resolver)
|
46
|
+
Rails32Resolver = Trackman::Path::Rails32Resolver unless defined?(Rails32Resolver)
|
47
|
+
RailsResolver = Trackman::Path::RailsResolver unless defined?(RailsResolver)
|
48
|
+
Configuration = Trackman::Utility::Configuration unless defined?(Configuration)
|
data/spec/sync_spec.rb
CHANGED
@@ -74,7 +74,7 @@ describe Trackman::Assets::Asset do
|
|
74
74
|
it "logs the error when sync is broken" do
|
75
75
|
MyTestAsset.stub!(:sync).and_raise("something is wrong")
|
76
76
|
|
77
|
-
|
77
|
+
Trackman::Utility::Debugger.should_receive(:log_exception).once
|
78
78
|
|
79
79
|
lambda { result = MyTestAsset.autosync }.should_not raise_error
|
80
80
|
end
|
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.5.
|
4
|
+
version: 0.5.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -164,32 +164,37 @@ files:
|
|
164
164
|
- lib/trackman.rb
|
165
165
|
- lib/trackman/assets.rb
|
166
166
|
- lib/trackman/assets/asset.rb
|
167
|
-
- lib/trackman/assets/
|
168
|
-
- lib/trackman/assets/
|
169
|
-
- lib/trackman/assets/
|
170
|
-
- lib/trackman/assets/components/composite_asset.rb
|
171
|
-
- lib/trackman/assets/components/conventions.rb
|
172
|
-
- lib/trackman/assets/components/diffable.rb
|
173
|
-
- lib/trackman/assets/components/hashable.rb
|
174
|
-
- lib/trackman/assets/components/path_resolver.rb
|
175
|
-
- lib/trackman/assets/components/rails32_path_resolver.rb
|
176
|
-
- lib/trackman/assets/components/rails_path_resolver.rb
|
177
|
-
- lib/trackman/assets/components/remote_asset_factory.rb
|
178
|
-
- lib/trackman/assets/components/shippable.rb
|
167
|
+
- lib/trackman/assets/asset_factory.rb
|
168
|
+
- lib/trackman/assets/bundled_asset.rb
|
169
|
+
- lib/trackman/assets/composite_asset.rb
|
179
170
|
- lib/trackman/assets/css_asset.rb
|
180
|
-
- lib/trackman/assets/errors.rb
|
181
|
-
- lib/trackman/assets/errors/asset_not_found_error.rb
|
182
|
-
- lib/trackman/assets/errors/config_not_found_error.rb
|
183
171
|
- lib/trackman/assets/html_asset.rb
|
172
|
+
- lib/trackman/assets/persistence.rb
|
173
|
+
- lib/trackman/assets/persistence/remote.rb
|
184
174
|
- lib/trackman/assets/remote_asset.rb
|
185
|
-
- lib/trackman/
|
186
|
-
- lib/trackman/
|
187
|
-
- lib/trackman/
|
175
|
+
- lib/trackman/assets/remote_asset_factory.rb
|
176
|
+
- lib/trackman/components.rb
|
177
|
+
- lib/trackman/components/conventions.rb
|
178
|
+
- lib/trackman/components/diffable.rb
|
179
|
+
- lib/trackman/components/hashable.rb
|
180
|
+
- lib/trackman/components/shippable.rb
|
181
|
+
- lib/trackman/errors.rb
|
182
|
+
- lib/trackman/errors/asset_not_found_error.rb
|
183
|
+
- lib/trackman/errors/config_not_found_error.rb
|
184
|
+
- lib/trackman/errors/config_setup_error.rb
|
185
|
+
- lib/trackman/path.rb
|
186
|
+
- lib/trackman/path/rails32_resolver.rb
|
187
|
+
- lib/trackman/path/rails_resolver.rb
|
188
|
+
- lib/trackman/path/resolver.rb
|
188
189
|
- lib/trackman/scaffold.rb
|
189
190
|
- lib/trackman/scaffold/content_saver.rb
|
190
191
|
- lib/trackman/scaffold/pretty-print.xslt
|
192
|
+
- lib/trackman/utility.rb
|
193
|
+
- lib/trackman/utility/configuration.rb
|
194
|
+
- lib/trackman/utility/core_extensions.rb
|
195
|
+
- lib/trackman/utility/debugger.rb
|
196
|
+
- lib/trackman/utility/railtie.rb
|
191
197
|
- lib/trackman/version.rb
|
192
|
-
- lib/trackman_railtie.rb
|
193
198
|
- rails_generators/trackman_controller/USAGE
|
194
199
|
- rails_generators/trackman_controller/templates/controller_layout.rb.erb
|
195
200
|
- rails_generators/trackman_controller/templates/view_layout.html.erb
|
@@ -201,7 +206,7 @@ files:
|
|
201
206
|
- spec/asset_factory_spec.rb
|
202
207
|
- spec/asset_spec.rb
|
203
208
|
- spec/composite_asset_spec.rb
|
204
|
-
- spec/
|
209
|
+
- spec/configuration_spec.rb
|
205
210
|
- spec/css_asset_spec.rb
|
206
211
|
- spec/diffable_spec.rb
|
207
212
|
- spec/fixtures/composite_assets/query_string_in_path.html
|
@@ -447,9 +452,9 @@ files:
|
|
447
452
|
- spec/paths/rails32_pathman_spec.rb
|
448
453
|
- spec/rails2311/first_push_spec.rb
|
449
454
|
- spec/rails32/first_push_spec.rb
|
450
|
-
- spec/
|
455
|
+
- spec/rails32_resolver_spec.rb
|
451
456
|
- spec/remote_asset_spec.rb
|
452
|
-
- spec/
|
457
|
+
- spec/scaffold_spec.rb
|
453
458
|
- spec/shippable_spec.rb
|
454
459
|
- spec/spec_helper.rb
|
455
460
|
- spec/sync_spec.rb
|
@@ -513,7 +518,7 @@ test_files:
|
|
513
518
|
- spec/asset_factory_spec.rb
|
514
519
|
- spec/asset_spec.rb
|
515
520
|
- spec/composite_asset_spec.rb
|
516
|
-
- spec/
|
521
|
+
- spec/configuration_spec.rb
|
517
522
|
- spec/css_asset_spec.rb
|
518
523
|
- spec/diffable_spec.rb
|
519
524
|
- spec/fixtures/composite_assets/query_string_in_path.html
|
@@ -759,9 +764,9 @@ test_files:
|
|
759
764
|
- spec/paths/rails32_pathman_spec.rb
|
760
765
|
- spec/rails2311/first_push_spec.rb
|
761
766
|
- spec/rails32/first_push_spec.rb
|
762
|
-
- spec/
|
767
|
+
- spec/rails32_resolver_spec.rb
|
763
768
|
- spec/remote_asset_spec.rb
|
764
|
-
- spec/
|
769
|
+
- spec/scaffold_spec.rb
|
765
770
|
- spec/shippable_spec.rb
|
766
771
|
- spec/spec_helper.rb
|
767
772
|
- spec/sync_spec.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Trackman
|
2
|
-
module Assets
|
3
|
-
module Components
|
4
|
-
@@modules = [:Conventions, :Diffable, :Hashable,
|
5
|
-
:Shippable, :CompositeAsset, :AssetFactory, :PathResolver,
|
6
|
-
:Rails32PathResolver, :RailsPathResolver, :BundledAsset, :RemoteAssetFactory]
|
7
|
-
|
8
|
-
::Trackman::Assets.autoloads 'trackman/assets/components', @@modules do |s,p|
|
9
|
-
autoload s, p
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Trackman
|
2
|
-
module Assets
|
3
|
-
module Components
|
4
|
-
module AssetFactory
|
5
|
-
def create attributes = {}
|
6
|
-
path = attributes[:path]
|
7
|
-
instance = retrieve_parent(path).new attributes
|
8
|
-
add_content_behavior instance
|
9
|
-
end
|
10
|
-
|
11
|
-
def retrieve_parent path
|
12
|
-
if File.extname(path) == '.html'
|
13
|
-
parent = HtmlAsset
|
14
|
-
elsif File.extname(path) == '.css'
|
15
|
-
parent = CssAsset
|
16
|
-
else
|
17
|
-
parent = Asset
|
18
|
-
end
|
19
|
-
parent
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_content_behavior instance
|
23
|
-
if asset_pipeline_enabled?
|
24
|
-
instance.extend Rails32PathResolver, BundledAsset
|
25
|
-
return instance
|
26
|
-
elsif rails_defined? #fallback to rails without asset pipeline
|
27
|
-
instance.extend RailsPathResolver
|
28
|
-
end
|
29
|
-
instance.extend Hashable
|
30
|
-
|
31
|
-
instance
|
32
|
-
end
|
33
|
-
|
34
|
-
def rails_defined?
|
35
|
-
Object.const_defined?(:Rails)
|
36
|
-
end
|
37
|
-
|
38
|
-
def asset_pipeline_enabled?
|
39
|
-
rails_defined? &&
|
40
|
-
Rails.respond_to?(:application) &&
|
41
|
-
Rails.application.config.assets.enabled &&
|
42
|
-
Rails.application.respond_to?(:assets) &&
|
43
|
-
Rails.application.assets
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|