class Soyuz::Environment
Public Class Methods
new(attributes={}, defaults={})
click to toggle source
# File lib/soyuz/environment.rb, line 5 def initialize(attributes={}, defaults={}) set_attributes(attributes, defaults) if [:deploy_cmds, :deploy_cmd].all?{ |attr| @attributes.has_key?(attr) } raise ArgumentError, "Only one definiton of deploy_cmd or deploy_cmds is allowed" end build end
Public Instance Methods
after_callbacks()
click to toggle source
# File lib/soyuz/environment.rb, line 26 def after_callbacks @after_callbacks.each do|cmd| cmd.run end end
before_callbacks()
click to toggle source
# File lib/soyuz/environment.rb, line 20 def before_callbacks @before_callbacks.each do|cmd| cmd.run end end
deploy()
click to toggle source
# File lib/soyuz/environment.rb, line 32 def deploy @deploy_cmds.each do |cmd| cmd.run end end
name()
click to toggle source
# File lib/soyuz/environment.rb, line 38 def name @name end
valid?()
click to toggle source
# File lib/soyuz/environment.rb, line 15 def valid? # If the environment built then it's valid true end
Private Instance Methods
build()
click to toggle source
# File lib/soyuz/environment.rb, line 49 def build # deploy_cmd is deprecated and will be removed in a future version @deploy_cmds = Array(Command.build(@attributes[:deploy_cmd])) @deploy_cmds += Array(@attributes[:deploy_cmds]).compact.map{|cmd| Command.build(cmd) } @before_callbacks = Array(@attributes[:before_deploy_cmds]).compact.map{|cmd| Command.build(cmd) } @after_callbacks = Array(@attributes[:after_deploy_cmds]).compact.map{|cmd| Command.build(cmd) } end
set_attributes(attributes={}, defaults={})
click to toggle source
# File lib/soyuz/environment.rb, line 44 def set_attributes(attributes={}, defaults={}) @name = attributes.keys.first @attributes = defaults.merge(attributes[name]) end