Class: EY::Serverside::RailsAssets::Strategy::Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#pathsObject (readonly)

Returns the value of attribute paths


29
30
31
# File 'lib/engineyard-serverside/rails_assets/strategy.rb', line 29

def paths
  @paths
end

#runnerObject (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

#prepareObject

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.path(:public,'last_assets')
    run "mkdir -p #{last} && ln -nfs #{previous_assets_path} #{last.join('assets')}"
  end

  yield
end

#reusable?Boolean

Returns:

  • (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

#reuseObject


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