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
# File 'lib/fir/util/config.rb', line 17

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

#current_tokenObject



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

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



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

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

#write_config(hash) ⇒ Object



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

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