Sha256: e22029504306300a9196110fed04e523347ab1bb3228b4feb7eb1ef72b3bcf1c
Contents?: true
Size: 1003 Bytes
Versions: 7
Compression:
Stored size: 1003 Bytes
Contents
module Idonethis::UseCases module Config class << self def apply(_, args={}) log = args[:log] || fail("You need to supply :log adapter") log.call "args: #{args}" require 'yaml' settings = File.exists?(filename) ? YAML.load_file(filename) : {} token = (args[:opts].map{|it| it.match /user.token=(.+)/}.compact || []).first if token File.open filename, "w+" do |f| f.puts(settings.merge({token: token[1]}).to_yaml) end end team = (args[:opts].map{|it| it.match /user.team=(.+)/}.compact || []).first if team File.open filename, "w+" do |f| f.puts(settings.merge({team: team[1]}).to_yaml) end end puts "Settings saved to <#{filename}>" end private def filename require 'settings_file' Idonethis::SettingsFile.path end end end end
Version data entries
7 entries across 7 versions & 1 rubygems