Class: Abtest::AssetTask
- Inherits:
-
Sprockets::Rails::Task
- Object
- Sprockets::Rails::Task
- Abtest::AssetTask
- Defined in:
- lib/abtest/asset_task.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(app = nil) ⇒ AssetTask
constructor
A new instance of AssetTask.
Constructor Details
#initialize(app = nil) ⇒ AssetTask
Returns a new instance of AssetTask.
7 8 9 10 |
# File 'lib/abtest/asset_task.rb', line 7 def initialize(app = nil) self.app = app super(app) end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5 6 7 |
# File 'lib/abtest/asset_task.rb', line 5 def app @app end |
Instance Method Details
#define ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/abtest/asset_task.rb', line 12 def define namespace :abtest do desc "Compile application.css and application.js in our experiment directories as well as anything called out in config.abtest.precompile_assets." task :precompile => :environment do # Remove the abtest root for this task Rails.application.config.assets.paths = Rails.application.config.assets.paths.reject { |path| path==File.join(Rails.root, 'abtest') } configured_experiments = app.config.abtest.registered_tests # Precompile assets for each experiment configured_experiments.each do |experiment| name = experiment[:name] manifest = Abtest::ManifestManager.instance.retrieve_manifest(name) # Add our experiments asset path assets << lambda {|filename, path| path =~ /#{name}\/assets/ && !%w(.js .css).include?(File.extname(filename))} assets << lambda {|filename, path| path =~ /#{name}\/assets/ && %w(application.js application.css).include?(filename)} assets << lambda {|filename, path| path =~ /#{name}\/assets/ && app.config.abtest.precompile_assets.include?(filename)} with_logger do manifest.compile(assets) end end end end end |