Class: Fozzie::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#appnameObject

Returns the value of attribute appname.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def appname
  @appname
end

#config_pathObject

Returns the value of attribute config_path.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def config_path
  @config_path
end

#envObject

Returns the value of attribute env.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def env
  @env
end

#hostObject

Returns the value of attribute host.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def host
  @host
end

#ignore_prefixObject

Returns the value of attribute ignore_prefix.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def ignore_prefix
  @ignore_prefix
end

#monitor_classesObject

Returns the value of attribute monitor_classes.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def monitor_classes
  @monitor_classes
end

#namespacesObject

Returns the value of attribute namespaces.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def namespaces
  @namespaces
end

#portObject

Returns the value of attribute port.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def port
  @port
end

#prefixObject

Returns the value of attribute prefix.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def prefix
  @prefix
end

#sniff_envsObject

Returns the value of attribute sniff_envs.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def sniff_envs
  @sniff_envs
end

#timeoutObject

Returns the value of attribute timeout.



17
18
19
# File 'lib/fozzie/configuration.rb', line 17

def timeout
  @timeout
end

Instance Method Details

#adapterObject



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_prefixObject

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_prefixObject



36
37
38
# File 'lib/fozzie/configuration.rb', line 36

def disable_prefix
  @ignore_prefix = true
end

#origin_nameObject

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

Returns:

  • (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