Class: Fozzie::Configuration
- Inherits:
-
Object
- Object
- Fozzie::Configuration
- Extended by:
- Forwardable
- Includes:
- Sys
- Defined in:
- lib/fozzie/configuration.rb
Overview
Fozzie configuration allows assignment of global properties that will be used within the Fozzie codebase.
Instance Attribute Summary collapse
-
#appname ⇒ Object
Returns the value of attribute appname.
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#env ⇒ Object
Returns the value of attribute env.
-
#host ⇒ Object
Returns the value of attribute host.
-
#ignore_prefix ⇒ Object
Returns the value of attribute ignore_prefix.
-
#monitor_classes ⇒ Object
Returns the value of attribute monitor_classes.
-
#namespaces ⇒ Object
Returns the value of attribute namespaces.
-
#port ⇒ Object
Returns the value of attribute port.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#sniff_envs ⇒ Object
Returns the value of attribute sniff_envs.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #adapter ⇒ Object
- #adapter=(adapter) ⇒ Object
-
#data_prefix ⇒ Object
Returns the prefix for any stat requested to be registered.
- #disable_prefix ⇒ Object
-
#initialize(args = {}) ⇒ Configuration
constructor
A new instance of Configuration.
-
#origin_name ⇒ Object
Returns the origin name of the current machine to register the stat against.
- #sniff? ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ Configuration
Returns a new instance of Configuration.
20 21 22 23 24 |
# File 'lib/fozzie/configuration.rb', line 20 def initialize(args = {}) merge_and_assign_config(args) self.adapter self.origin_name end |
Instance Attribute Details
#appname ⇒ Object
Returns the value of attribute appname.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def appname @appname end |
#config_path ⇒ Object
Returns the value of attribute config_path.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def config_path @config_path end |
#env ⇒ Object
Returns the value of attribute env.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def env @env end |
#host ⇒ Object
Returns the value of attribute host.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def host @host end |
#ignore_prefix ⇒ Object
Returns the value of attribute ignore_prefix.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def ignore_prefix @ignore_prefix end |
#monitor_classes ⇒ Object
Returns the value of attribute monitor_classes.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def monitor_classes @monitor_classes end |
#namespaces ⇒ Object
Returns the value of attribute namespaces.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def namespaces @namespaces end |
#port ⇒ Object
Returns the value of attribute port.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def port @port end |
#prefix ⇒ Object
Returns the value of attribute prefix.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def prefix @prefix end |
#sniff_envs ⇒ Object
Returns the value of attribute sniff_envs.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def sniff_envs @sniff_envs end |
#timeout ⇒ Object
Returns the value of attribute timeout.
17 18 19 |
# File 'lib/fozzie/configuration.rb', line 17 def timeout @timeout end |
Instance Method Details
#adapter ⇒ Object
32 33 34 |
# File 'lib/fozzie/configuration.rb', line 32 def adapter @adapter || default_configuration[:adapter] end |
#adapter=(adapter) ⇒ Object
26 27 28 29 30 |
# File 'lib/fozzie/configuration.rb', line 26 def adapter=(adapter) @adapter = eval("Fozzie::Adapter::#{adapter}").new rescue NoMethodError raise AdapterMissing, "Adapter could not be found for given provider #{@provider}" end |
#data_prefix ⇒ Object
Returns the prefix for any stat requested to be registered
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fozzie/configuration.rb', line 41 def data_prefix return nil if @ignore_prefix return @data_prefix if @data_prefix escaped_prefix_with_dynamically_resolved_parts = prefix.map do |part| resolved_part = (part.kind_of?(Symbol) && self.respond_to?(part) ? self.send(part) : part.to_s) escaped_resolved_part = resolved_part.gsub(delimeter, safe_separator) escaped_resolved_part == "" ? nil : escaped_resolved_part end.compact @data_prefix = if escaped_prefix_with_dynamically_resolved_parts.any? escaped_prefix_with_dynamically_resolved_parts.join(delimeter).strip else nil end end |
#disable_prefix ⇒ Object
36 37 38 |
# File 'lib/fozzie/configuration.rb', line 36 def disable_prefix @ignore_prefix = true end |
#origin_name ⇒ Object
Returns the origin name of the current machine to register the stat against
59 60 61 |
# File 'lib/fozzie/configuration.rb', line 59 def origin_name @origin_name ||= Uname.nodename end |
#sniff? ⇒ Boolean
63 64 65 |
# File 'lib/fozzie/configuration.rb', line 63 def sniff? self.sniff_envs.collect(&:to_sym).include?(self.env.to_sym) end |