Module: FIR::Config

Included in:
Util::ClassMethods
Defined in:
lib/fir/util/config.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#bughd_apiObject



13
14
15
# File 'lib/fir/util/config.rb', line 13

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

#configObject



17
18
19
20
# File 'lib/fir/util/config.rb', line 17

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

#current_tokenObject



30
31
32
# File 'lib/fir/util/config.rb', line 30

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

#fir_apiObject



9
10
11
# File 'lib/fir/util/config.rb', line 9

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

#reload_configObject



22
23
24
# File 'lib/fir/util/config.rb', line 22

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

#write_config(hash) ⇒ Object



26
27
28
# File 'lib/fir/util/config.rb', line 26

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