Sha256: 3fa632429bf0fbe24b810cd4a22ba27b63e96622ced67705baafad9426ccc648

Contents?: true

Size: 746 Bytes

Versions: 11

Compression:

Stored size: 746 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

11 entries across 11 versions & 1 rubygems

Version Path
nexus_cli-0.8.4 lib/nexus_cli/configuration.rb
nexus_cli-0.8.3 lib/nexus_cli/configuration.rb
nexus_cli-0.8.2 lib/nexus_cli/configuration.rb
nexus_cli-0.8.1 lib/nexus_cli/configuration.rb
nexus_cli-0.8.0 lib/nexus_cli/configuration.rb
nexus_cli-0.7.3 lib/nexus_cli/configuration.rb
nexus_cli-0.7.2 lib/nexus_cli/configuration.rb
nexus_cli-0.7.1 lib/nexus_cli/configuration.rb
nexus_cli-0.7.0 lib/nexus_cli/configuration.rb
nexus_cli-0.6.0 lib/nexus_cli/configuration.rb
nexus_cli-0.5.0 lib/nexus_cli/configuration.rb