Class: RubyDeployer::Deployer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_deployer/deployer.rb

Instance Method Summary collapse

Constructor Details

#initialize(deploy_file, artifact, environment, artifact_repository) ⇒ Deployer

Returns a new instance of Deployer.



3
4
5
6
7
8
# File 'lib/ruby_deployer/deployer.rb', line 3

def initialize deploy_file, artifact, environment, artifact_repository
  @deploy_file = deploy_file
  @artifact = artifact
  @environment = environment
  @artifact_repository = artifact_repository
end

Instance Method Details

#servers(destinations) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby_deployer/deployer.rb', line 18

def servers(destinations)
  destinations.map do |destination|
    server = connection.servers.all.detect do |s|
      s.state == 'running' and
      s.tags.include? "#{@environment}_#{destination}"
    end
    server.private_key_path = File.join('config', 'aws_key')
    server
  end
end

#startObject



10
11
12
13
14
15
16
# File 'lib/ruby_deployer/deployer.rb', line 10

def start
  destinations = @deploy_file.deployments[@artifact.to_sym]
  targets = servers destinations
  targets.each do |target|
    target.scp(@artifact_repository.get_latest, '/home/ubuntu')
  end
end