Sha256: f96caec78edc23a98ff8cfce89b3f8166d1587388768831b85d8a2a42c43a9d1

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

require 'socket'

module StackAgent
  class Configuration
    DEFAULT_API_HOST = 'https://stackotron-discover.herokuapp.com'

    attr_accessor :api_host
    attr_accessor :app_token
    attr_accessor :name
    attr_accessor :group
    attr_accessor :uri

    def initialize
      @api_host = DEFAULT_API_HOST
      @name = Socket.gethostname

      # If we're running inside rails, attempt to fill in a bunch of the blanks
      if defined?(Rails)
        # only do this if we're in development environment
        if Rails.env.development? && defined?(Rails::Server)
          ip = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address
          port = Rails::Server.new.options[:Port]
          @uri = "http://#{ip}:#{port}"
          @group = 'Development'
        end

      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stack-agent-0.1.0 lib/stack-agent/configuration.rb