Sha256: 9117c79d2a0159b2badcf088b89c2c32697649cc2495ce1c96e51dfbe11cf7e6
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
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' require 'all_seeing_eye/integrations/rails2' if defined?(Rails) self.configuration end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
all_seeing_eye-0.1.1 | lib/all_seeing_eye.rb |