Class: Engineyard::Local::Middleware::Rails::Assets
- Inherits:
-
Object
- Object
- Engineyard::Local::Middleware::Rails::Assets
- Includes:
- Helpers::Executable, Helpers::Rvm
- Defined in:
- lib/engineyard-local/middleware/rails/assets.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #commands ⇒ Object
-
#if_task_exists(task) ⇒ Object
if there’s a Rakefile, and rake -T contains the task we’re looking for execute the task.
-
#initialize(app, env) ⇒ Assets
constructor
A new instance of Assets.
Methods included from Helpers::Executable
#project_dir, #ssh_exec, #ssh_exec!
Methods included from Helpers::Rvm
#bash_rvm_setup, #export_ruby, #ruby_env_const, #rvm_env, #use_ruby_with_gemset
Constructor Details
#initialize(app, env) ⇒ Assets
9 10 11 12 |
# File 'lib/engineyard-local/middleware/rails/assets.rb', line 9 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 |
# File 'lib/engineyard-local/middleware/rails/assets.rb', line 14 def call(env) @env[:ui].info I18n.t("eylocal.setup.rails.assets") ssh_exec!(env, commands) @app.call(env) end |
#commands ⇒ Object
20 21 22 23 24 |
# File 'lib/engineyard-local/middleware/rails/assets.rb', line 20 def commands [ "cd #{project_dir}", if_task_exists("assets:precompile"), "sudo /etc/init.d/nginx restart" ] end |
#if_task_exists(task) ⇒ Object
if there’s a Rakefile, and rake -T contains the task we’re looking for execute the task
28 29 30 |
# File 'lib/engineyard-local/middleware/rails/assets.rb', line 28 def if_task_exists(task) "if [[ `rake -T > /dev/null 2>&1 && rake -T | grep -e '#{task}'` ]]; then rake #{task}; fi" end |