Sha256: 7644191d14849a5a9c45c3dc67891f7619c6d6ac9bfd0569b1c695452ff1a9c8

Contents?: true

Size: 978 Bytes

Versions: 4

Compression:

Stored size: 978 Bytes

Contents

module Vitals
  class Configuration
    attr_accessor :environment
    attr_accessor :facility
    attr_accessor :host
    attr_accessor :reporter
    attr_accessor :format

    def initialize
      @environment = fetch_development
      @facility = "default"
      @host = fetch_host
      @reporter = Vitals::Reporters::InmemReporter.new
      @format = Vitals::Formats::ProductionFormat
      self.path_sep = '.'
    end

    # delegate to utils, until this part of the utils
    # finds a new home with a new abstraction
    def path_sep=(val)
      Vitals::Utils.path_sep = val
    end

    def path_sep
      Vitals::Utils.path_sep = val
    end

    def build_format
      @format.new(
        environment: self.environment,
        facility: self.facility,
        host: self.host
      )
    end

    private

    def fetch_development
      ENV["RACK_ENV"] || ENV["NODE_ENV"] || "development"
    end

    def fetch_host
      Vitals::Utils.hostname
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vitals-0.10.0 lib/vitals/configuration.rb
vitals-0.9.1 lib/vitals/configuration.rb
vitals-0.9.0 lib/vitals/configuration.rb
vitals-0.8.1 lib/vitals/configuration.rb