Sha256: f2d7d5353ce209f06c2deb1adc5dc9280cbf1bad75661b4468892077a02ebb9d
Contents?: true
Size: 770 Bytes
Versions: 4
Compression:
Stored size: 770 Bytes
Contents
require 'yaml' class RenuoCliConfig CONFIG_FILE_PATH = "#{File.expand_path('~')}/.renuo_cli".freeze class << self def redmine_api_key get_config_value('REDMINE_API_KEY', 'https://redmine.renuo.ch/my/account') end def toggl_api_token get_config_value('TOGGL_API_TOKEN', 'https://toggl.com/app/profile') end private def get_config_value(name, open_url) FileUtils.touch(CONFIG_FILE_PATH) config = YAML.load_file(CONFIG_FILE_PATH, fallback: {}) value = config[name] return value if value system("open #{open_url}") value = ask("You haven't set your #{name}, yet. Please provide one:") config[name] = value File.write(CONFIG_FILE_PATH, config.to_yaml) value end end end
Version data entries
4 entries across 4 versions & 1 rubygems