class EY::Serverside::RailsAssets::Strategy::Private

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.

Attributes

paths[R]
runner[R]

Public Class Methods

new(paths, runner) click to toggle source
# File lib/engineyard-serverside/rails_assets/strategy.rb, line 31
def initialize(paths, runner)
  @paths = paths
  @runner = runner
end

Public Instance Methods

prepare() { || ... } click to toggle source

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
# File lib/engineyard-serverside/rails_assets/strategy.rb, line 49
def prepare
  if previous_assets_path
    last = paths.path(:public,'last_assets')
    run "mkdir -p #{last} && ln -nfs #{previous_assets_path} #{last.join('assets')}"
  end

  yield
end
reusable?() click to toggle source
# File lib/engineyard-serverside/rails_assets/strategy.rb, line 36
def reusable?
  previous_assets_path && previous_assets_path.entries.any?
end
reuse() click to toggle source
# 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

Protected Instance Methods

previous_assets_path() click to toggle source

Just to be safe, we don’t check the real path until runtime to make sure the relevant directories are there.

# File lib/engineyard-serverside/rails_assets/strategy.rb, line 66
def previous_assets_path
  return @previous_assets_path if defined? @previous_assets_path
  if prev = paths.previous_release(paths.active_release)
    @previous_assets_path = prev.join('public','assets')
    @previous_assets_path = nil unless @previous_assets_path.directory?
  else
    @previous_assets_path = nil
  end
  @previous_assets_path
end
run(cmd) click to toggle source
# File lib/engineyard-serverside/rails_assets/strategy.rb, line 60
def run(cmd)
  runner.run cmd
end