Class: Gratan::Identifier::CSV

Inherits:
Object
  • Object
show all
Includes:
Logger::Helper
Defined in:
lib/gratan/identifier/csv.rb

Instance Method Summary collapse

Methods included from Logger::Helper

#log

Constructor Details

#initialize(path, options = {}) ⇒ CSV

Returns a new instance of CSV.



6
7
8
9
10
11
12
13
# File 'lib/gratan/identifier/csv.rb', line 6

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

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

Instance Method Details

#identify(user, host) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/gratan/identifier/csv.rb', line 15

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