Class: CloudfrontDeployer

Inherits:
S3Deployer show all
Defined in:
lib/spar/deployers/cloudfront_deployer.rb

Instance Method Summary collapse

Methods inherited from S3Deployer

#age_out, #deploy, #upload

Methods inherited from Spar::Deployer

#deploy, #run

Instance Method Details

#finishObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/spar/deployers/cloudfront_deployer.rb', line 17

def finish
  to_invalidate = @deployed_assets.collect do |asset|
    if asset.write_path =~ /\.html$/
      [ asset.write_path, asset.write_path.gsub('index.html',''), asset.write_path.gsub('/index.html','') ]
    else
      asset.write_path
    end
  end
  to_invalidate << 'TIMESTAMP.txt'

  @invalidator.invalidate(to_invalidate.flatten) do |status,time|
    puts "Invalidation #{status} after %.2f seconds" % time.to_f
  end

  super
end

#prepare(assets) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/spar/deployers/cloudfront_deployer.rb', line 6

def prepare(assets)
  super
  @cloudfront_distribution = Spar.settings['cloudfront_distribution']
  raise "ERROR: You should set a :cloudfront_distribution in your config.yml file so you can deploy to Cloudfront" unless @cloudfront_distribution
  @invalidator = CloudfrontInvalidator.new(
    @aws_key,
    @aws_secret,
    @cloudfront_distribution
  )
end