Class: EY::Serverside::RailsAssets::Strategy::Private
- Inherits:
-
Object
- Object
- EY::Serverside::RailsAssets::Strategy::Private
- Defined in:
- lib/engineyard-serverside/rails_assets/strategy.rb
Overview
Precompile assets fresh every time. Shared assets are not symlinked and assets stay with the release that compiled them. The assets of the previous deploy are symlinked as into the current deploy to prevent errors during deploy.
When no assets changes are detected, the deploy uses rsync to copy the previous release’s assets into the current assets directory.
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
-
#initialize(paths, runner) ⇒ Private
constructor
A new instance of Private.
-
#prepare ⇒ Object
link the previous assets into the new public/last_assets/assets to prevent missing assets during deploy.
- #reusable? ⇒ Boolean
- #reuse ⇒ Object
Constructor Details
#initialize(paths, runner) ⇒ Private
Returns a new instance of Private.
31 32 33 34 |
# File 'lib/engineyard-serverside/rails_assets/strategy.rb', line 31 def initialize(paths, runner) @paths = paths @runner = runner end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
29 30 31 |
# File 'lib/engineyard-serverside/rails_assets/strategy.rb', line 29 def paths @paths end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
29 30 31 |
# File 'lib/engineyard-serverside/rails_assets/strategy.rb', line 29 def runner @runner end |
Instance Method Details
#prepare ⇒ Object
link the previous assets into the new public/last_assets/assets to prevent missing assets during deploy.
This results in the directory structure:
deploy_root/current/public/last_assets/assets -> deploy_root/releases/<prev>/public/assets
49 50 51 52 53 54 55 56 |
# File 'lib/engineyard-serverside/rails_assets/strategy.rb', line 49 def prepare if previous_assets_path last = paths.public.join('last_assets') run "mkdir -p #{last} && ln -nfs #{previous_assets_path} #{last.join('assets')}" end yield end |
#reusable? ⇒ Boolean
36 37 38 |
# File 'lib/engineyard-serverside/rails_assets/strategy.rb', line 36 def reusable? previous_assets_path && previous_assets_path.entries.any? end |
#reuse ⇒ Object
40 41 42 |
# File 'lib/engineyard-serverside/rails_assets/strategy.rb', line 40 def reuse run "mkdir -p #{paths.public_assets} && rsync -aq #{previous_assets_path}/ #{paths.public_assets}" end |