Class: Zxcvbn::Data
- Inherits:
-
Object
- Object
- Zxcvbn::Data
- Defined in:
- lib/zxcvbn/data.rb
Instance Attribute Summary collapse
-
#adjacency_graphs ⇒ Object
readonly
Returns the value of attribute adjacency_graphs.
-
#dictionary_tries ⇒ Object
readonly
Returns the value of attribute dictionary_tries.
-
#graph_stats ⇒ Object
readonly
Returns the value of attribute graph_stats.
-
#ranked_dictionaries ⇒ Object
readonly
Returns the value of attribute ranked_dictionaries.
Instance Method Summary collapse
- #add_word_list(name, list) ⇒ Object
-
#initialize ⇒ Data
constructor
A new instance of Data.
Constructor Details
#initialize ⇒ Data
Returns a new instance of Data.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/zxcvbn/data.rb', line 9 def initialize @ranked_dictionaries = DictionaryRanker.rank_dictionaries( 'english' => read_word_list('english.txt'), 'female_names' => read_word_list('female_names.txt'), 'male_names' => read_word_list('male_names.txt'), 'passwords' => read_word_list('passwords.txt'), 'surnames' => read_word_list('surnames.txt') ) @adjacency_graphs = JSON.parse(DATA_PATH.join('adjacency_graphs.json').read) @dictionary_tries = build_tries @graph_stats = compute_graph_stats end |
Instance Attribute Details
#adjacency_graphs ⇒ Object (readonly)
Returns the value of attribute adjacency_graphs.
22 23 24 |
# File 'lib/zxcvbn/data.rb', line 22 def adjacency_graphs @adjacency_graphs end |
#dictionary_tries ⇒ Object (readonly)
Returns the value of attribute dictionary_tries.
22 23 24 |
# File 'lib/zxcvbn/data.rb', line 22 def dictionary_tries @dictionary_tries end |
#graph_stats ⇒ Object (readonly)
Returns the value of attribute graph_stats.
22 23 24 |
# File 'lib/zxcvbn/data.rb', line 22 def graph_stats @graph_stats end |
#ranked_dictionaries ⇒ Object (readonly)
Returns the value of attribute ranked_dictionaries.
22 23 24 |
# File 'lib/zxcvbn/data.rb', line 22 def ranked_dictionaries @ranked_dictionaries end |
Instance Method Details
#add_word_list(name, list) ⇒ Object
24 25 26 27 28 |
# File 'lib/zxcvbn/data.rb', line 24 def add_word_list(name, list) ranked_dict = DictionaryRanker.rank_dictionary(list) @ranked_dictionaries[name] = ranked_dict @dictionary_tries[name] = build_trie(ranked_dict) end |