module Capistrano::Helpers::Base
Helper functions for both runit and monit
Public Instance Methods
app_env_underscore()
click to toggle source
# File lib/capistrano/helpers/base.rb, line 20 def app_env_underscore "#{fetch(:application)}_#{environment}".squish.downcase.gsub(/[\s|-]/, '_') end
environment()
click to toggle source
Automatically sets the environment based on presence of :stage (multistage) :rails_env RAILS_ENV variable;
Defaults to “production” if not found
# File lib/capistrano/helpers/base.rb, line 32 def environment # rubocop:disable Metrics/MethodLength if !fetch(:rails_env).nil? fetch(:rails_env) elsif !fetch(:rack_env).nil? fetch(:rack_env) elsif !fetch(:stage).nil? fetch(:stage) else info '---------------------------------------------------------------' info '- Stage, rack or rails environment isn\'t set in -' info '- :stage, :rails_env or :rack_env, defaulting to \'production\' -' info '---------------------------------------------------------------' 'production' end end
run_rake(task)
click to toggle source
Execute a rake taske using the proper env. run_rake
db:migrate
# File lib/capistrano/helpers/base.rb, line 57 def run_rake(task) within(current_path) do with rails_env: fetch(:rails_env) do execute :rake, "#{task}" end end end
template_to_s_io(template_file)
click to toggle source
# File lib/capistrano/helpers/base.rb, line 48 def template_to_s_io(template_file) fail "Cannot find template #{template_file}" unless File.exist?(template_file) StringIO.new(ERB.new(File.read(template_file)).result(binding)) end
user_app_env_underscore()
click to toggle source
# File lib/capistrano/helpers/base.rb, line 8 def user_app_env_underscore "#{fetch(:user)}_#{fetch(:application)}_#{environment}".squish.downcase.gsub(/[\s|-]/, '_') end
user_app_env_underscore_short()
click to toggle source
# File lib/capistrano/helpers/base.rb, line 12 def user_app_env_underscore_short "#{fetch(:user)[0...1]}_#{environment[0...1]}_#{fetch(:application)}".squish.downcase.gsub(/[\s|-]/, '_') end
user_app_env_underscore_short_char_safe()
click to toggle source
# File lib/capistrano/helpers/base.rb, line 16 def user_app_env_underscore_short_char_safe user_app_env_underscore_short.squish.downcase.gsub(/[\s|-]/, '_') end