Sha256: 9f05d436ecd0f69651e286f7ead7cbfc45dc9d9b822dfc531429e05c36c4cb65
Contents?: true
Size: 776 Bytes
Versions: 18
Compression:
Stored size: 776 Bytes
Contents
class Gratan::Identifier::Auto def initialize(output, options = {}) @output = output @options = options @cache = {} end def identify(user, host) if @cache[user] password = @cache[user] else password = mkpasswd @cache[user] = password end 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) open_output do |f| f.puts("#{user}@#{host},#{password}") end end def open_output return if @options[:dry_run] if @output == '-' yield($stdout) $stdout.flush else open(@output, 'a') do |f| yield(f) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems