Sha256: c0f6bb791d69634ca1e351294545fee6a454295b8781a82869082d6a682c4cc5

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib')

require_relative 'troo/troo'
require_relative 'troo/version'

module Troo
  ConfigurationNotFound = Class.new(StandardError)
  ConfigurationAborted  = Class.new(StandardError)
  ExpiredAccessToken    = Class.new(StandardError)
  EndpointNotFound      = Class.new(StandardError)

  # @param  [String]
  # @param  [String]
  # @return [Troo::Configuration]
  def self.configuration(file = Dir.home + '/.trooconf', env = 'default')
    unless File.exist?(file)
      warn "\nConfiguration cannot be found, please run `troo " \
           "init` or `./bin/troo init` first.\n"
      file = root_path + '/config/trooconf.yml'
    end

    @configuration ||= Troo::Configuration.load(file, env)
  end

  # @return [TrueClass]
  def self.logger
    @logger ||= Logger
      .new(root_path + '/logs/troo.log').tap do |log|
      log.formatter = proc do |mode, time, prog, msg|
        "\n" + Esc.green + "#{time.iso8601}:" + Esc.reset + " #{msg}\n"
      end
    end
  end

  def self.root_path
    File.expand_path('../..', __FILE__)
  end

  # RestClient.log = log_dir + '/restclient.log'

  Database.connect(configuration)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.12 lib/troo.rb