lib/cany/recipes/rails.rb in cany-0.2.1 vs lib/cany/recipes/rails.rb in cany-0.3.0
- old
+ new
@@ -3,17 +3,18 @@
class Rails < Recipe
register_as :rails
hook :env
class DSL < Recipe::DSL
- delegate :compile_assets
+ delegate :compile_assets, :assets_env
end
- attr_accessor :compile_assets
+ attr_accessor :compile_assets, :assets_env
def initialize(*args)
@compile_assets = true
+ @assets_env = 'production'
super
end
def clean
rmtree 'tmp', 'public/assets'
@@ -24,11 +25,14 @@
recipe(:bundler).configure :env_vars, RAILS_ENV: 'production'
end
def build
run_hook :env, :before
+ if compile_assets
+ ENV['RAILS_ENV'] = assets_env
+ ruby_bin 'bundle', 'exec', 'rake', 'assets:precompile'
+ end
ENV['RAILS_ENV'] = 'production'
- ruby_bin 'bundle', 'exec', 'rake', 'assets:precompile' if compile_assets
inner.build
end
def binary
run_hook :env, :after