Class: Deployer::Stage

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Stage

Returns a new instance of Stage.



4
5
6
7
# File 'lib/deployer/stage.rb', line 4

def initialize(name)
  @name = name
  @hosts = []
end

Instance Attribute Details

#hostsObject (readonly)

Returns the value of attribute hosts.



2
3
4
# File 'lib/deployer/stage.rb', line 2

def hosts
  @hosts
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/deployer/stage.rb', line 2

def name
  @name
end

Class Method Details

.load(name, file) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/deployer/stage.rb', line 26

def self.load(name, file)
  data = YAML.load_file(file)
  data.map do |_, config|
    stage = Deployer::Stage.new(name)
    config["hosts"].each do |host|
      stage.host(host["host"], host["port"], host["user"])
    end
    stage
  end.first
end

Instance Method Details

#host(host, port, user) ⇒ Object



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

def host(host, port, user)
  @hosts << {
    host: host,
    port: port,
    user: user
  }
  self
end

#single_host_stageObject

returns a new stage which only contains one host



20
21
22
23
24
# File 'lib/deployer/stage.rb', line 20

def single_host_stage
  stage = Deployer::Stage.new(name)
  stage.host(hosts[0][:host], hosts[0][:port], hosts[0][:user])
  stage
end