Sha256: bcac932f545d8cbed3a0e515cea798d382b9c84d1825cf15c08ff14b6e6799f2

Contents?: true

Size: 475 Bytes

Versions: 30

Compression:

Stored size: 475 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", :color => :yellow)
    end

    password
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
gratan-0.2.3 lib/gratan/identifier/csv.rb
gratan-0.2.2 lib/gratan/identifier/csv.rb
gratan-0.2.1 lib/gratan/identifier/csv.rb
gratan-0.2.0 lib/gratan/identifier/csv.rb
gratan-0.1.9 lib/gratan/identifier/csv.rb
gratan-0.1.8 lib/gratan/identifier/csv.rb
gratan-0.1.7 lib/gratan/identifier/csv.rb
gratan-0.1.6 lib/gratan/identifier/csv.rb
gratan-0.1.5 lib/gratan/identifier/csv.rb
gratan-0.1.4 lib/gratan/identifier/csv.rb