Sha256: cb11babd3b3229c5c392329390a33ab00155e3883dcbac79c4b9f8c840e031dc
Contents?: true
Size: 771 Bytes
Versions: 11
Compression:
Stored size: 771 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
11 entries across 11 versions & 1 rubygems