Class: Deploy::Deployment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeployment

Returns a new instance of Deployment.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/deploy.rb', line 20

def initialize()

  @config = YAML::load(File.open(CONFIG_PATH))
  @environments = Array.new

  @config.each do |env|
    @environments.push Environment.new(env[0], env[1])
  end

  @reverse = false

end

Instance Attribute Details

#environmentsObject (readonly)

Returns the value of attribute environments.



16
17
18
# File 'lib/deploy.rb', line 16

def environments
  @environments
end

#reverseObject

Returns the value of attribute reverse.



18
19
20
# File 'lib/deploy.rb', line 18

def reverse
  @reverse
end

Instance Method Details

#go(args = []) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/deploy.rb', line 33

def go(args = [])

  # If there are no arguments, deploy using the first environment in
  # the configuration file, otherwise loop through and deploy each one
  # Note: the to_a statement ensures that args is not nil
  if args.size == 0
    
    @environments.first.deploy
    
  else
    
    # Loop through the arguments and deploy any given ones that are also
    # present in the config file.
    args.each do |arg_env|
      
      curr_env = @environments.find { |e| e.name == arg_env }
      
      if curr_env.nil?
        puts "No environment found for #{arg_env}, add it to `#{Deploy::CONFIG_PATH}`"
      else
        curr_env.deploy
      end
    
    end
    
  end
  
end