class Pushapp::Tasks::ForemanExport

Public Instance Methods

run() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 7
def run
  system "#{sudo} bundle exec foreman export #{arguments}"
end

Private Instance Methods

arguments() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 13
def arguments
  args = ["#{foreman_format} #{foreman_location}"]
  args << "-f #{foreman_procfile}" if foreman_procfile
  args << "-a #{foreman_app}" if foreman_app
  args << "-u #{foreman_user}" if foreman_user
  args << "-d #{foreman_directory}" if foreman_directory
  args << "-e #{foreman_env}" if foreman_env
  args << "-l #{foreman_log}"
  args << "-p #{options[:foreman_port]}" if options[:foreman_port]
  args << "-c #{options[:foreman_concurrency]}" if options[:foreman_concurrency]
  args << "-t #{options[:foreman_template]}" if options[:foreman_template]
  args.join(' ')
end
find_dot_env_file() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 59
def find_dot_env_file
  dot_env = ['.env', rails_env].compact.join('.')
  return dot_env if File.exists?(dot_env)
  return '.env' if File.exists?('.env')
end
find_procfile() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 65
def find_procfile
  procfile = ['config/deploys/Procfile', rails_env].join('.')
  return procfile if File.exists?(procfile)
  procfile = ['Procfile', rails_env].join('.')
  return procfile if File.exists?(procfile)
end
foreman_app() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 39
def foreman_app
  options[:foreman_app] || app_name_from_path
end
foreman_directory() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 47
def foreman_directory
  options[:foreman_directory] || options[:remote].path
end
foreman_env() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 51
def foreman_env
  options[:foreman_env] || find_dot_env_file
end
foreman_format() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 27
def foreman_format
  options[:foreman_format] || "upstart"
end
foreman_location() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 31
def foreman_location
  options[:foreman_location] || foreman_format == 'upstart' ? '/etc/init' : nil
end
foreman_log() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 55
def foreman_log
  options[:foreman_log] || 'log/foreman'
end
foreman_procfile() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 35
def foreman_procfile
  options[:foreman_procfile] || find_procfile
end
foreman_user() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 43
def foreman_user
  options[:foreman_user] || options[:remote].user
end
rails_env() click to toggle source
# File lib/pushapp/tasks/foreman_export.rb, line 72
def rails_env
  env['RAILS_ENV']
end