class AllSeeingEye def self.environment ENV['RUBBER_ENV'] || ENV['RAILS_ENV'] || ENV['ALL_SEEING_EYE_ENV'] || 'development' end def self.configuration location = ENV['ALL_SEEING_EYE_CONFIG'] || 'config' @@configuration ||= Hash.new @@configuration[:all_seeing_eye] ||= YAML::load_file("./#{location}/all_seeing_eye.yml") @@configuration[:redis] ||= if @@configuration[:all_seeing_eye]['redis'] && @@configuration[:all_seeing_eye]['redis'][AllSeeingEye.environment] @@configuration[:all_seeing_eye]['redis'][AllSeeingEye.environment] else begin YAML::load_file("./#{location}/resque.yml")[AllSeeingEye.environment] rescue begin YAML::load_file("./#{location}/redis.yml")[AllSeeingEye.environment] rescue 'localhost:6379' end end end @@configuration[:models] ||= [] @@configuration[:all_seeing_eye].each do |key, value| next if self.default_keys.include?(key) || AllSeeingEye.const_defined?(key.capitalize.to_sym) klass = Class.new(AllSeeingEye::Model) AllSeeingEye.const_set(key.capitalize.to_sym, klass) @@configuration[:models] << klass end @@configuration end def self.default_keys ['timeout', 'round_to_seconds', 'redis'] end def self.redis @@redis ||= Redis.new(:host => AllSeeingEye.configuration[:redis].split(':').first, :port => AllSeeingEye.configuration[:redis].split(':').last, :db => 7) end require 'redis' require 'yaml' require 'chronic' require 'active_support' require 'active_support/all' require 'all_seeing_eye/model' if defined?(Rails) require 'all_seeing_eye/integrations/rails2' require 'all_seeing_eye/generators/all_seeing_eye_generator' end self.configuration end