Sha256: fb724a002d9a5307addbecb95b3431dfdbf5f0af255985839c4c785754603061

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

class Gratan::Identifier::Auto
  def initialize(output, options = {})
    @options = options

    unless @options[:dry_run]
      if output == '-'
        @output = $stdout
      else
        @output = open(output, 'w')
      end
    end
  end

  def identify(user, host)
    password = mkpasswd
    puts_password(user, host, password)
    password
  end

  private

  def mkpasswd(len = 8)
    [*1..9, *'A'..'Z', *'a'..'z'].shuffle.slice(0, len).join
  end

  def puts_password(user, host, password)
    if @output
      @output.puts("#{user}@#{host},#{password}")
      @output.flush
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gratan-0.2.0 lib/gratan/identifier/auto.rb