Sha256: aee4f33f8420a66ce0b9873ce353685697932a053536630f4be4d01a1e098a3d

Contents?: true

Size: 967 Bytes

Versions: 3

Compression:

Stored size: 967 Bytes

Contents

module ApigeeCli
  class << self
    def configuration
      @configuration ||= ApigeeCli::Configuration.new
    end
  end

  class Configuration
    def apigeerc_config
      begin
        @apigeerc_config = YAML.load_file("#{ENV['HOME']}/.apigeerc")
      rescue
        raise "Error loading .apigeerc file"
      end
      @apigeerc_config.merge! local_apigeerc_config
      @apigeerc_config
    end

    def username
      raise 'Not Configured' if apigeerc_config['username'].nil?
      apigeerc_config['username']
    end

    def password
      raise 'Not Configured' if apigeerc_config['password'].nil?
      apigeerc_config['password']
    end

    def org
      raise 'Not Configured' if apigeerc_config['org'].nil?
      apigeerc_config['org']
    end

    def local_apigeerc_config
      File.exists?("./.apigeerc") ? YAML.load_file("./.apigeerc") : {}
    end

    def method_missing(sym, *args, &block)
      apigeerc_config[sym.to_s]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apigee_cli-0.0.3 lib/apigee_cli/configuration.rb
apigee_cli-0.0.2 lib/apigee_cli/configuration.rb
apigee_cli-0.0.1 lib/apigee_cli/configuration.rb