Class: Hat::Deployment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage_name, file_name = nil) ⇒ Deployment

Returns a new instance of Deployment.



14
15
16
17
18
# File 'lib/hat/deployment.rb', line 14

def initialize stage_name, file_name = nil
  self.configuration = Konf.new(file_name || 'deploy.yml')
  self.stage_name = stage_name || "staging"
  self.cap = Capistrano::Application.new
end

Instance Attribute Details

#capObject

Returns the value of attribute cap.



12
13
14
# File 'lib/hat/deployment.rb', line 12

def cap
  @cap
end

#configurationObject

Returns the value of attribute configuration.



12
13
14
# File 'lib/hat/deployment.rb', line 12

def configuration
  @configuration
end

#stage_nameObject

Returns the value of attribute stage_name.



12
13
14
# File 'lib/hat/deployment.rb', line 12

def stage_name
  @stage_name
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
# File 'lib/hat/deployment.rb', line 20

def run
  recipes.download
  run_with_bundler(recipes.gemfile) do
    stage.set_defaults(configuration['defaults'])
    stage.define_task(recipes)
    cap.invoke stage.name   # http://capistranorb.com/documentation/advanced-features/capistrano-pure-ruby/
    cap.invoke 'deploy'
  end
end