Module: Flappy::Config

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#configObject

def bughd_api

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

end



18
19
20
21
# File 'lib/flappy/util/config.rb', line 18

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

#current_tokenObject



35
36
37
# File 'lib/flappy/util/config.rb', line 35

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

#fir_apiObject



10
11
12
# File 'lib/flappy/util/config.rb', line 10

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

#reload_configObject



23
24
25
# File 'lib/flappy/util/config.rb', line 23

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

#write_app_info(hash) ⇒ Object



31
32
33
# File 'lib/flappy/util/config.rb', line 31

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

#write_config(hash) ⇒ Object



27
28
29
# File 'lib/flappy/util/config.rb', line 27

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