Sha256: a43dc999e45465bc66cc14d08e8ead17c306c57d526c3fedc37d3d0d36e60b2e

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

module FIR
  module Config
    CONFIG_PATH   = "#{ENV['HOME']}/.omt-cli"
    APP_INFO_PATH = "#{ENV['HOME']}/.omt-cli-app"
    API_YML_PATH  = File.expand_path('../../', __FILE__) + '/api.yml'
    XCODE_WRAPPER_PATH  = File.expand_path('../../', __FILE__) + '/xcode_wrapper.sh'
    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

4 entries across 4 versions & 1 rubygems

Version Path
omt-cli-1.6.7 lib/fir/util/config.rb
omt-cli-1.6.6 lib/fir/util/config.rb
omt-cli-1.6.5 lib/fir/util/config.rb
omt-cli-1.6.4 lib/fir/util/config.rb