Sha256: 9c960c877a7b67c518a4364eaac4a22d8640a8c7b6b5e489ce6c025d2bf75899

Contents?: true

Size: 1004 Bytes

Versions: 2

Compression:

Stored size: 1004 Bytes

Contents

# encoding: utf-8

module FIR
  module Config
    CONFIG_PATH   = "#{ENV['HOME']}/.fir-cli"
    APP_INFO_PATH = "#{ENV['HOME']}/.fir-cli-app"
    API_YML_PATH  = File.expand_path('../../', __FILE__) + '/api.yml'
    APP_FILE_TYPE = %w(.ipa .apk).freeze

    def fir_api
      @fir_api ||= YAML.load_file(API_YML_PATH).deep_symbolize_keys[:fir]
    end

    def bughd_api
      @bughd_api ||= YAML.load_file(API_YML_PATH).deep_symbolize_keys[:bughd]
    end

    def config
      return unless File.exist?(CONFIG_PATH)
      @config ||= YAML.load_file(CONFIG_PATH).deep_symbolize_keys
    end

    def reload_config
      @config = YAML.load_file(CONFIG_PATH).deep_symbolize_keys
    end

    def write_config(hash)
      File.open(CONFIG_PATH, 'w+') { |f| f << YAML.dump(hash) }
    end

    def write_app_info(hash)
      File.open(APP_INFO_PATH, 'w+') { |f| f << YAML.dump(hash) }
    end

    def current_token
      @token ||= config[:token] if config
    end

    alias_method :☠, :exit
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fir-cli-1.5.1 lib/fir/util/config.rb
fir-cli-1.5.0 lib/fir/util/config.rb