Module: Capistrano::Artifact::DefaultStrategy

Defined in:
lib/capistrano/artifact.rb

Instance Method Summary collapse

Instance Method Details

#asset_url(region = "us-east-1") ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/capistrano/artifact.rb', line 25

def asset_url(region = "us-east-1")
  bucket_info = fetch(:artifact_aws_buckets).find { |b| b[:region] == region}

  connection = Fog::Storage.new({
    provider:  "AWS",
    aws_access_key_id: fetch(:artifact_aws_access_key),
    aws_secret_access_key: fetch(:artifact_aws_secret_key),
    region: bucket_info[:region]
  })
  item = fetch(:artifact_pattern)
  connection.directories.get(bucket_info[:name]).files.head(item).url(Time.now + 600)
end

#checkObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/capistrano/artifact.rb', line 10

def check
  fetch(:artifact_aws_buckets).each do |bucket|
    connection = Fog::Storage.new({
      provider:  "AWS",
      aws_access_key_id: fetch(:artifact_aws_access_key),
      aws_secret_access_key: fetch(:artifact_aws_secret_key),
      region: bucket[:region]
    })
    item = fetch(:artifact_pattern)
    artifact = connection.directories.get(bucket[:name]).files.head(item)

    raise "Unable to download asset #{item} from any mirrors, ensure it was built!" unless artifact
  end
end

#regionObject



38
39
40
# File 'lib/capistrano/artifact.rb', line 38

def region
  context.capture(fetch(:artifact_region_query)).chomp
end