Sha256: 294a26bfe783cab4302d0720e9357242057d3c24213839824e110410d9f4b3ec

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 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 " \
           "wizard` or `./bin/troo wizard` 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

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.15 lib/troo.rb
troo-0.0.14 lib/troo.rb
troo-0.0.13 lib/troo.rb