Class: Passweird::Checker
- Inherits:
-
Object
- Object
- Passweird::Checker
- Defined in:
- lib/passweird/checker.rb
Overview
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Class Method Summary collapse
Instance Method Summary collapse
-
#blacklisted? ⇒ Boolean
Checks if the password is blacklisted.
-
#blacklisted_terms ⇒ ActiveRecord::Relation
Retrieves the blacklisted terms that match the possible terms.
-
#initialize(password) ⇒ Checker
constructor
A new instance of Checker.
-
#possible_terms ⇒ Array<String>
Generates all possible terms from substrings and leet speak equivalents.
Constructor Details
#initialize(password) ⇒ Checker
Returns a new instance of Checker.
17 18 19 20 21 |
# File 'lib/passweird/checker.rb', line 17 def initialize(password) raise ArgumentError, "password must be a String" unless password.is_a?(String) @password = password end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
11 12 13 |
# File 'lib/passweird/checker.rb', line 11 def password @password end |
Class Method Details
.blacklisted?(password) ⇒ Boolean
13 14 15 |
# File 'lib/passweird/checker.rb', line 13 def self.blacklisted?(password) new(password).blacklisted? end |
Instance Method Details
#blacklisted? ⇒ Boolean
Checks if the password is blacklisted
26 27 28 |
# File 'lib/passweird/checker.rb', line 26 def blacklisted? @blacklisted ||= BlacklistedTerm.exists?(term: possible_terms) end |
#blacklisted_terms ⇒ ActiveRecord::Relation
Retrieves the blacklisted terms that match the possible terms
33 34 35 |
# File 'lib/passweird/checker.rb', line 33 def blacklisted_terms @blacklisted_terms ||= BlacklistedTerm.where(term: possible_terms) end |
#possible_terms ⇒ Array<String>
Generates all possible terms from substrings and leet speak equivalents
40 41 42 |
# File 'lib/passweird/checker.rb', line 40 def possible_terms @possible_terms ||= all_substring_case_permutations.uniq end |