Sha256: 5e9f6f0be6562f9782f8b4f2dd474859341ad833a0560b03421c5f0b47e43433

Contents?: true

Size: 731 Bytes

Versions: 3

Compression:

Stored size: 731 Bytes

Contents

# -*- encoding: utf-8 -*-
module Abak::Flow
  class Config < Struct.new(:api_user, :api_token, :proxy)
    [:api_user, :api_token, :proxy].each {|attribute| define_method("#{attribute}?") { !send(attribute).to_s.empty? } }

    def self.current
      return @current_config unless @current_config.nil?

      HighLine.color_scheme = HighLine::SampleColorScheme.new
      git_reader = Hub::Commands.send(:git_reader)

      api_user  = git_reader.read_config('abak.apiuser')
      api_token = git_reader.read_config('abak.apitoken')
      proxy     = git_reader.read_config('abak.proxy')
      env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']

      @current_config = new(api_user, api_token, proxy || env_proxy)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
abak-flow-0.3.2 lib/abak-flow/config.rb
abak-flow-0.3.1 lib/abak-flow/config.rb
abak-flow-0.3.0 lib/abak-flow/config.rb