module RailsappFactory::HelperMethods
Attributes
db[RW]
gem_source[RW]
logger[RW]
timeout[RW]
Public Instance Methods
alive?()
click to toggle source
def rubies(rails_v = @version)
self.class.rubies(rails_v)
end
# File lib/railsapp_factory/helper_methods.rb, line 43 def alive? if @pid begin Process.kill(0, @pid) self.logger.debug "Process #{@pid} is alive" true rescue Errno::EPERM self.logger.warning "Process #{@pid} has changed uid - we will not be able to signal it to finish" true # changed uid rescue Errno::ESRCH self.logger.debug "Process #{@pid} not found" false # NOT running rescue Exception => ex self.logger.warning "Process #{@pid} in unknown state: #{ex}" nil # Unable to determine status end end end
env()
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 33 def env rails_env = self.override_ENV['RAILS_ENV'] || self.override_ENV['RACK_ENV'] || 'test' @_env = nil unless @_env.to_s == rails_env @_env ||= RailsappFactory::StringInquirer.new(rails_env) end
env=(value)
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 27 def env=(value) self.override_ENV['RAILS_ENV'] = value self.override_ENV['RACK_ENV'] = value self.env end
logger()
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 15 def logger @logger ||= Logger.new(STDERR) end
override_ENV()
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 11 def override_ENV @override_ENV ||= {} end
uri(path = '', query_args = {})
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 19 def uri(path = '', query_args = {}) URI(self.url(path, query_args)) end
url(path = '', query_args = {})
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 23 def url(path = '', query_args = {}) "http://127.0.0.1:#{self.port}/" + path.to_s.sub(/^\//, '') + self.class.encode_query(query_args) end
Private Instance Methods
append_log(file)
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 78 def append_log(file) self.logger.debug? ? '' : " >> #{file} 2>&1" end
bundle_command()
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 82 def bundle_command "#{self.class.ruby_command_prefix(self.using)} bundle" end
find_command(script_name, rails_arg)
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 90 def find_command(script_name, rails_arg) result = Dir.chdir(root) do if File.exists?("script/#{script_name}") "#{bundle_command} exec script/#{script_name}" elsif File.exists?('script/rails') "#{bundle_command} exec script/rails #{rails_arg}" else "#{ruby_command(false)} .bundle/bin/rails #{rails_arg}" end end self.logger.info("find_command(#{script_name.inspect}, #{rails_arg.inspect}) returned #{result.inspect}") result end
generate_command()
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 104 def generate_command find_command('generate', 'generate') end
get_backtrace()
click to toggle source
get backtrace except for this method
# File lib/railsapp_factory/helper_methods.rb, line 66 def get_backtrace raise 'get backtrace' rescue => ex trace = ex.backtrace trace.shift trace end
ruby_command(bundled = true)
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 86 def ruby_command(bundled = true) "#{self.class.ruby_command_prefix(self.using)} #{bundled ? 'bundle exec' : ''} ruby" end
runner_command()
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 108 def runner_command find_command('runner', 'runner') end
see_log(file)
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 74 def see_log(file) self.logger.debug? ? '' : " - see #{file}" end
server_command()
click to toggle source
# File lib/railsapp_factory/helper_methods.rb, line 112 def server_command find_command('server', 'server') end