Sha256: 5e964a3a349cd2b0d07a4c08155eb17235c02ff1b4735c430dac95b5e820b76d
Contents?: true
Size: 1.02 KB
Versions: 14
Compression:
Stored size: 1.02 KB
Contents
require 'yaml' require 'thor' module Karo class NoConfigFileFoundError < StandardError; end class Config def self.default_file_name ".karo.yml" end def self.load_configuration(options) begin config_file = File.expand_path(options[:config_file]) configuration = read_configuration(config_file)[options[:environment]] if configuration.nil? || configuration.empty? raise Thor::Error, "Please pass a valid configuration for an environment '#{options[:environment]}' within this file '#{config_file}'" else configuration end rescue Karo::NoConfigFileFoundError puts "You can use 'karo generate' to generate a skeleton .karo.yml file" puts "Please make sure that this configuration file exists? '#{config_file}'" raise Thor::Error, "and run the command again" end end private def self.read_configuration(file_name) if File.exist?(file_name) YAML.load_file(file_name) else raise NoConfigFileFoundError end end end end
Version data entries
14 entries across 14 versions & 1 rubygems