Sha256: 34c6190e6f85086dc805b591c44587dd420b5e2761086fa25805125253d76aaf

Contents?: true

Size: 706 Bytes

Versions: 4

Compression:

Stored size: 706 Bytes

Contents

module HammerCLIForeman
  class Credentials < HammerCLI::Apipie::AbstractCredentials

    def initialize(params={})
      @username = params[:username]
      @password = params[:password]
    end

    def username
      @username ||= ask_user(_("[Foreman] username: ")) if HammerCLI.interactive?
      @username
    end

    def password
      @password ||= ask_user(_("[Foreman] password for %s: ") % @username, true) if HammerCLI.interactive?
      @password
    end

    def empty?
      !@username && !@password
    end

    def clear
      @username = nil
      @password = nil
    end

    def to_params
      {
        :username => username,
        :password => password
      }
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hammer_cli_foreman-0.1.3 lib/hammer_cli_foreman/credentials.rb
hammer_cli_foreman-0.1.2 lib/hammer_cli_foreman/credentials.rb
hammer_cli_foreman-0.1.1 lib/hammer_cli_foreman/credentials.rb
hammer_cli_foreman-0.1.0 lib/hammer_cli_foreman/credentials.rb