Permalink
Browse files

Cleanup

1 parent 857dd37 commit 43cb2817aca1e1fb9f58d9e941a91254bbdaab6a @jfirebaugh committed Feb 11, 2016
Showing with 17 additions and 21 deletions.
  1. +4 −0 lib/konacha.rb
  2. +13 −21 lib/konacha/engine.rb
View
@@ -75,5 +75,9 @@ def precompiled_assets
def asset_precompiled?(logical_path)
precompiled_assets.include? logical_path
end
+
+ def sprockets_rails_3?
+ defined?(Sprockets::Rails::VERSION) && Sprockets::Rails::VERSION.start_with?('3')
+ end
end
end
View
@@ -7,19 +7,12 @@ class Engine < ::Rails::Engine
config.konacha = ActiveSupport::OrderedOptions.new
def self.application(app)
- # Compatibility workaround for supporting both sprockets 2 and 3 with sprocket-rails 2 or 3
- if defined?(Sprockets::Rails::VERSION) && Sprockets::Rails::VERSION.start_with?('3')
- app.config.cache_classes = false
- sprockets_env = Sprockets::Railtie.build_environment(app)
- end
-
Rack::Builder.app do
use Rack::ShowExceptions
map app.config.assets.prefix do
- # Compatibility workaround for supporting both sprockets 2 and 3 with sprocket-rails 2 or 3
- if defined?(Sprockets::Rails::VERSION) && Sprockets::Rails::VERSION.start_with?('3')
- run sprockets_env
+ if Konacha.sprockets_rails_3?
+ run Sprockets::Railtie.build_environment(app)
else
run app.assets
end
@@ -57,22 +50,21 @@ def self.formatters
spec_dirs = [options.spec_dir].flatten
app.config.assets.paths += spec_dirs.map{|d| app.root.join(d).to_s}
- if !defined?(Sprockets::Rails::VERSION) || Sprockets::Rails::VERSION.start_with?('2')
- app.config.assets.raise_runtime_errors = false
- end
- options.application ||= self.class.application(app)
- end
- config.after_initialize do
- # Compatibility workaround for supporting both sprockets 2 and 3 with sprocket-rails 2 or 3
- if defined?(Sprockets::Rails::VERSION) && Sprockets::Rails::VERSION.start_with?('3')
- ActiveSupport.on_load(:action_view) do
- default_checker = ActionView::Base.precompiled_asset_checker
- ActionView::Base.precompiled_asset_checker = -> logical_path do
- default_checker[logical_path] || Konacha.asset_precompiled?(logical_path)
+ if Konacha.sprockets_rails_3?
+ config.after_initialize do
+ ActiveSupport.on_load(:action_view) do
+ default_checker = ActionView::Base.precompiled_asset_checker
+ ActionView::Base.precompiled_asset_checker = -> logical_path do
+ default_checker[logical_path] || Konacha.asset_precompiled?(logical_path)
+ end
end
end
+ else
+ app.config.assets.raise_runtime_errors = false
end
+
+ options.application ||= self.class.application(app)
end
end
end

0 comments on commit 43cb281

Please sign in to comment.