Class: PasswordBlacklist::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/password_blacklist/checker.rb

Instance Method Summary collapse

Constructor Details

#initializeChecker

Returns a new instance of Checker.



3
4
5
6
7
# File 'lib/password_blacklist/checker.rb', line 3

def initialize
  file_path = File.expand_path('../../../data/100k_passwords.txt', __FILE__)

  @data = File.read(file_path)
end

Instance Method Details

#blacklisted?(password) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/password_blacklist/checker.rb', line 9

def blacklisted?(password)
  !@data.match(/#{Regexp.quote(password)}/).nil?
end

#inspectObject



13
14
15
# File 'lib/password_blacklist/checker.rb', line 13

def inspect
  "#<#{self.class}:0x#{__id__.to_s(16)}>"
end