Class: Zxcvbn::Tester

Inherits:
Object
  • Object
show all
Defined in:
lib/zxcvbn/tester.rb

Constant Summary collapse

DATA_PATH =
Pathname(File.expand_path('../../../data/zxcvbn.js', __FILE__))

Instance Method Summary collapse

Constructor Details

#initializeTester

Returns a new instance of Tester.



7
8
9
10
# File 'lib/zxcvbn/tester.rb', line 7

def initialize
  src = File.read(DATA_PATH)
  @context = ExecJS.compile(src)
end

Instance Method Details

#test(password, user_inputs = []) ⇒ Object



12
13
14
15
# File 'lib/zxcvbn/tester.rb', line 12

def test(password, user_inputs = [])
  result = @context.eval("zxcvbn(#{password.to_json}, #{user_inputs.to_json})")
  OpenStruct.new(result)
end