class Resque::God::Configuration
Public Class Methods
new(*paths)
click to toggle source
# File lib/resque/god/configuration.rb, line 37 def initialize(*paths) @configuration = {} paths.each { |f| load f } end
Public Instance Methods
config_file()
click to toggle source
# File lib/resque/god/configuration.rb, line 50 def config_file self['resque.config_file'] || ::Rails.root.join('config/resque.god').to_s end
env()
click to toggle source
# File lib/resque/god/configuration.rb, line 70 def env env = self['env'] || {} Hash[env.map { |k, v| [k, v.to_s] }] end
log_file()
click to toggle source
# File lib/resque/god/configuration.rb, line 46 def log_file self['resque.log_file'] || ::Rails.root.join('log/resque.log').to_s end
pid_file()
click to toggle source
# File lib/resque/god/configuration.rb, line 54 def pid_file "#{pids}/resque-god.pid" end
pids()
click to toggle source
# File lib/resque/god/configuration.rb, line 58 def pids self['resque.pids'] || ::Rails.root.join('tmp/pids').to_s end
root()
click to toggle source
# File lib/resque/god/configuration.rb, line 62 def root self['resque.root'] || ::Rails.root.to_s end
terminate_timeout()
click to toggle source
# File lib/resque/god/configuration.rb, line 66 def terminate_timeout workers.map(&:stop_timeout).compact.max.to_i + 10 end
to_god()
click to toggle source
# File lib/resque/god/configuration.rb, line 76 def to_god template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'god.erb'))) template.result(binding) end
workers()
click to toggle source
# File lib/resque/god/configuration.rb, line 42 def workers @workers ||= (self[:workers] || {}).map { |k, v| Worker.new(k, v) } end
Private Instance Methods
[](path)
click to toggle source
get value from configuration
# File lib/resque/god/configuration.rb, line 92 def [](path) parts = path.to_s.split('.') result = @configuration parts.each do |k| result = result[k] break if result.nil? end result end
load(path)
click to toggle source
# File lib/resque/god/configuration.rb, line 83 def load(path) if File.exists?(path) config = YAML.load(File.read(path)) @configuration.merge!(config) end end