lib/fozzie/configuration.rb in fozzie-0.0.20 vs lib/fozzie/configuration.rb in fozzie-0.0.21

- old
+ new

@@ -8,11 +8,11 @@ # Fozzie configuration allows assignment of global properties # that will be used within the Fozzie codebase. class Configuration include Sys - attr_accessor :env, :config_path, :host, :port, :appname, :namespaces, :timeout + attr_accessor :env, :config_path, :host, :port, :appname, :namespaces, :timeout, :monitor_classes, :sniff_envs def initialize(args = {}) merge_and_assign_config(args) self.origin_name end @@ -28,10 +28,14 @@ # Returns the origin name of the current machine to register the stat against def origin_name @origin_name ||= Uname.uname.nodename end + def sniff? + self.sniff_envs.collect(&:to_sym).include?(self.env.to_sym) + end + private # Handle the merging of the given configuaration, and the default config. def merge_and_assign_config(args = {}) arg = self.class.default_configuration.merge(args.symbolize_keys) @@ -42,16 +46,18 @@ end # Default configuration settings def self.default_configuration { - :host => '127.0.0.1', - :port => 8125, - :config_path => '', - :env => (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'), - :appname => '', - :namespaces => %w{Stats S Statistics Warehouse}, - :timeout => 0.5 + :host => '127.0.0.1', + :port => 8125, + :config_path => '', + :env => (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'), + :appname => '', + :namespaces => %w{Stats S Statistics Warehouse}, + :timeout => 0.5, + :monitor_classes => [], + :sniff_envs => [:development, :staging, :production] }.dup end # Loads the configuration from YAML, if possible def config_from_yaml(args) \ No newline at end of file