Module: Capistrano::PumaCommon

Instance Method Summary collapse

Instance Method Details

#puma_bindObject



25
26
27
28
29
# File 'lib/capistrano/puma.rb', line 25

def puma_bind
  Array(fetch(:puma_bind)).collect do |bind|
    "bind '#{bind}'"
  end.join("\n")
end

#puma_switch_user(role, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/capistrano/puma.rb', line 6

def puma_switch_user(role, &block)
  user = puma_user(role)
  if user == role.user
    block.call
  else
    backend.as user do
      block.call
    end
  end
end

#puma_user(role) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/capistrano/puma.rb', line 17

def puma_user(role)
  properties = role.properties
  properties.fetch(:puma_user) || # local property for puma only
      fetch(:puma_user) ||
      properties.fetch(:run_as) || # global property across multiple capistrano gems
      role.user
end

#template_puma(from, to, role) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/capistrano/puma.rb', line 32

def template_puma(from, to, role)
  @role = role
  file = [
      "lib/capistrano/templates/#{from}-#{role.hostname}-#{fetch(:stage)}.rb",
      "lib/capistrano/templates/#{from}-#{role.hostname}.rb",
      "lib/capistrano/templates/#{from}-#{fetch(:stage)}.rb",
      "lib/capistrano/templates/#{from}.rb.erb",
      "lib/capistrano/templates/#{from}.rb",
      "lib/capistrano/templates/#{from}.erb",
      "config/deploy/templates/#{from}.rb.erb",
      "config/deploy/templates/#{from}.rb",
      "config/deploy/templates/#{from}.erb",
      File.expand_path("../templates/#{from}.erb", __FILE__),
      File.expand_path("../templates/#{from}.rb.erb", __FILE__)
  ].detect { |path| File.file?(path) }
  erb = File.read(file)
  backend.upload! StringIO.new(ERB.new(erb, nil, '-').result(binding)), to
end