module Capistrano::SimpleNginx::Helpers

Public Instance Methods

deploy_user() click to toggle source
# File lib/capistrano/simple_nginx/helpers.rb, line 27
def deploy_user
  capture :id, '-un'
end
file_exists?(path) click to toggle source
# File lib/capistrano/simple_nginx/helpers.rb, line 23
def file_exists? path
  test "[ -e #{path} ]"
end
nginx_config_file() click to toggle source
# File lib/capistrano/simple_nginx/helpers.rb, line 35
def nginx_config_file
  if os_is_ubuntu?
    "/etc/nginx/sites-available/#{fetch(:nginx_config_name)}.conf"
  else
    "/etc/nginx/conf.d/#{fetch(:nginx_config_name)}.conf"
  end
end
os_is_ubuntu?() click to toggle source
# File lib/capistrano/simple_nginx/helpers.rb, line 31
def os_is_ubuntu?
  capture(:cat, "/etc/*-release").include? "ubuntu"
end
sudo_upload!(from, to) click to toggle source
# File lib/capistrano/simple_nginx/helpers.rb, line 15
def sudo_upload! from, to
  filename = File.basename(to)
  to_dir = File.dirname(to)
  tmp_file = "/tmp/#{filename}"
  upload! from, tmp_file
  sudo :mv, tmp_file, to_dir
end
template(template_name) click to toggle source
# File lib/capistrano/simple_nginx/helpers.rb, line 6
def template template_name
  StringIO.new(template_to_s(template_name))
end
template_to_s(template_name) click to toggle source
# File lib/capistrano/simple_nginx/helpers.rb, line 10
def template_to_s template_name
  config_file = File.join(File.dirname(__FILE__), "../../templates/#{template_name}")
  ERB.new(File.read(config_file), nil, '-').result(binding)
end