File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 1010
1111module Zxcvbn
1212 class Error < StandardError ; end
13+ Result = Struct . new (
14+ :password ,
15+ :guesses ,
16+ :guesses_log10 ,
17+ :sequence ,
18+ :calc_time ,
19+ :crack_times_seconds ,
20+ :crack_times_display ,
21+ :score ,
22+ :feedback ,
23+ keyword_init : true
24+ )
1325
1426 def self . zxcvbn ( password , user_inputs = [ ] )
1527 start = ( Time . now . to_f * 1000 ) . to_i
@@ -25,7 +37,7 @@ def self.zxcvbn(password, user_inputs = [])
2537 end
2638
2739 def self . test ( password , user_inputs = [ ] )
28- OpenStruct . new ( Zxcvbn . zxcvbn ( password , user_inputs ) ) # rubocop:disable Style/OpenStructUse
40+ Result . new ( Zxcvbn . zxcvbn ( password , user_inputs ) )
2941 end
3042
3143 class Tester
Original file line number Diff line number Diff line change 236236 normal_result = Zxcvbn . zxcvbn ( "@lfred2004" , [ "alfred" ] ) . reject { |k , _v | [ "calc_time" ] . include? k }
237237 result1 = Zxcvbn . test ( "@lfred2004" , [ "alfred" ] )
238238 result2 = Zxcvbn ::Tester . new . test ( "@lfred2004" , [ "alfred" ] )
239- expect ( result1 ) . to be_a ( OpenStruct ) # rubocop:disable Style/OpenStructUse
239+ expect ( result1 ) . to be_a ( Zxcvbn :: Result )
240240 expect ( result1 . to_h . transform_keys ( &:to_s ) . reject { |k , _v | [ "calc_time" ] . include? k } ) . to eq ( normal_result )
241- expect ( result2 ) . to be_a ( OpenStruct ) # rubocop:disable Style/OpenStructUse
241+ expect ( result2 ) . to be_a ( Zxcvbn :: Result )
242242 expect ( result2 . to_h . transform_keys ( &:to_s ) . reject { |k , _v | [ "calc_time" ] . include? k } ) . to eq ( normal_result )
243243 end
244244end
You can’t perform that action at this time.
0 commit comments