Skip to content

Commit 974512f

Browse files
authored
Merge pull request #148 from Earlopain/drop-ostruct-ruby-3.5
Drop usage of `OpenStruct` for Ruby 3.5
2 parents 642deba + 5ae4ca0 commit 974512f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/rotp/arguments.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
require 'optparse'
2-
require 'ostruct'
32

43
module ROTP
54
class Arguments
5+
Options = Struct.new(:time, :counter, :mode, :digest, :secret, :warnings)
6+
67
def initialize(filename, arguments)
78
@filename = filename
89
@arguments = Array(arguments)
@@ -26,7 +27,15 @@ def options!
2627
end
2728

2829
def default_options
29-
OpenStruct.new time: true, counter: 0, mode: :time
30+
o = Options.new
31+
o.time = true
32+
o.counter = 0
33+
o.mode = :time
34+
o
35+
end
36+
37+
def to_h
38+
options!.to_h
3039
end
3140

3241
def parse

lib/rotp/cli.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def output
3131
return arguments.to_s if options.mode == :help
3232

3333
if options.mode == :time
34-
ROTP::TOTP.new(options.secret, options).now
34+
ROTP::TOTP.new(options.secret, options.to_h).now
3535
elsif options.mode == :hmac
36-
ROTP::HOTP.new(options.secret, options).at options.counter
36+
ROTP::HOTP.new(options.secret, options.to_h).at options.counter
3737
end
3838
end
3939

0 commit comments

Comments
 (0)