Sha256: bcb97301262b5d3b5d27f97f818c177eff5d22b16e551d5af0ab70e310edc767

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 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)
  InvalidAccessToken    = Class.new(StandardError)
  EndpointNotFound      = Class.new(StandardError)

  # @param  []
  # @param  [String]
  # @return []
  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 = configuration_path + '/trooconf.yml'
    end

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

  # @param  [String]
  # @return []
  def self.endpoints(version = 'version_1')
    @endpoints ||= Troo::API::Endpoints
      .load(configuration_path + '/trello_api.yml', version)
  end

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

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

  Database.connect(configuration)

  private

  def self.configuration_path
    File.dirname(__FILE__) + '/../config'
  end

  def self.log_path
    File.dirname(__FILE__) + '/../logs'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.11 lib/troo.rb