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