Sha256: c8da706c2c9a2dd6c36dcc26df56999ea99b04e393e97d66883fbc0fd6363a95

Contents?: true

Size: 431 Bytes

Versions: 2

Compression:

Stored size: 431 Bytes

Contents

module Zxcvbn
  require "execjs"

  class Tester
    DATA_PATH = Pathname(File.expand_path('../../../vendor/assets/javascripts/zxcvbn.js', __FILE__))

    def initialize
      src = File.open(DATA_PATH, 'r').read
      @context = ExecJS.compile(src)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zxcvbn-rails-4.4.1.1 lib/zxcvbn/tester.rb
zxcvbn-rails-4.4.1.0 lib/zxcvbn/tester.rb