class RaadTotem::Bootstrap
The bootstrap class for RaadTotem
. This will execute in the at_exit handler to run the service.
Public Class Methods
caller_files()
click to toggle source
Like Kernel#caller but excluding certain magic entries and without line / method information; the resulting array contains filenames only.
# File lib/raad_totem/bootstrap.rb, line 18 def self.caller_files caller_locations.map { |file, line| file } end
caller_locations()
click to toggle source
like caller_files
, but containing Arrays rather than strings with the first element being the file, and the second being the line.
# File lib/raad_totem/bootstrap.rb, line 24 def self.caller_locations caller(1). map { |line| line.split(/:(?=\d|in )/)[0,2] }. reject { |file, line| CALLERS_TO_IGNORE.any? { |pattern| file =~ pattern } } end
run!()
click to toggle source
execute the service
@return [Nil]
# File lib/raad_totem/bootstrap.rb, line 42 def self.run! service_class = Object.module_eval(camel_case(File.basename(service_file, '.rb'))) Runner.new(ARGV, service_class).run end
service_file()
click to toggle source
find the service_file
that was used to execute the service
@return [String] The service file
# File lib/raad_totem/bootstrap.rb, line 33 def self.service_file c = caller_files.first c = $0 if !c || c.empty? c end
Private Class Methods
camel_case(str)
click to toggle source
convert a string to camel case
@param str [String] The string to convert @return [String] The camel cased string
# File lib/raad_totem/bootstrap.rb, line 53 def self.camel_case(str) return str if str !~ /_/ && str =~ /[A-Z]+.*/ str.split('_').map { |e| e.capitalize }.join end