lib/console/output/sensitive.rb in console-1.24.0 vs lib/console/output/sensitive.rb in console-1.25.0
- old
+ new
@@ -1,19 +1,15 @@
# frozen_string_literal: true
# Released under the MIT License.
-# Copyright, 2021-2022, by Samuel Williams.
+# Copyright, 2021-2024, by Samuel Williams.
-require_relative '../serialized/logger'
+require_relative 'wrapper'
module Console
module Output
- class Sensitive
- def initialize(output, **options)
- @output = output
- end
-
+ class Sensitive < Wrapper
REDACT = /
phone
| email
| full_?name
| first_?name
@@ -36,12 +32,18 @@
| token
| password
/xi
+ def initialize(output, redact: REDACT, **options)
+ super(output, **options)
+
+ @redact = redact
+ end
+
def redact?(text)
- text.match?(REDACT)
+ text.match?(@redact)
end
def redact_hash(arguments, filter)
arguments.transform_values do |value|
redact(value, filter)
@@ -94,10 +96,10 @@
subject = redact(subject, filter)
arguments = redact_array(arguments, filter)
end
- @output.call(subject, *arguments, **options)
+ super(subject, *arguments, **options)
end
end
end
end