Sha256: 568cfa34a832ffb6a7b144d144a29f1cc72a14ba1f74cb0d83345dcec16f19b0

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 Bytes

Contents

require 'extlib'

module NexusCli
  module Configuration
    class << self
      def parse(overrides)
        config_path = File.expand_path("~/.nexus_cli")
        config = File.exists?(config_path) ? YAML::load_file(config_path) : Hash.new
        if config.nil? && (overrides.nil? || overrides.empty?)
          raise MissingSettingsFileException
        end
        overrides.each{|key, value| config[key] = value} unless overrides.nil? || overrides.empty?
        validate_config(config)
        config
      end

      def validate_config(configuration)
        ["url", "repository", "username","password"].each do |key|
          raise InvalidSettingsException.new(key) if configuration[key].blank?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nexus_cli-0.4.0 lib/nexus_cli/configuration.rb