Sha256: 28355b26d1d592ebd41c1c1ad2313a29b970e664889708e93da17d297da2624d

Contents?: true

Size: 465 Bytes

Versions: 4

Compression:

Stored size: 465 Bytes

Contents

require 'csv'

class Gratan::Identifier::CSV
  include Gratan::Logger::Helper

  def initialize(path, options = {})
    @options = options
    @passwords = {}

    CSV.foreach(path) do |row|
      @passwords[row[0]] = row[1]
    end
  end

  def identify(user, host)
    user_host = "#{user}@#{host}"
    password = @passwords[user_host]

    unless password
      log(:warn, "password for `#{user_host}` can not be found", :yellow)
    end

    password
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gratan-0.1.3 lib/gratan/identifier/csv.rb
gratan-0.1.2 lib/gratan/identifier/csv.rb
gratan-0.1.1 lib/gratan/identifier/csv.rb
gratan-0.1.0 lib/gratan/identifier/csv.rb