credit_card_sanitizer 0.6.9 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/credit_card_sanitizer.rb +15 -6
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8cf23aad6e2adf391430f9aa253458b1015cc1d39f2d937cd44904298e38cb2
|
4
|
+
data.tar.gz: 0bf28a2cc585dd331500bf1dc78ac4ff4ae2cbdb5fd8d4f4bd04e6741a2543f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0a11ad129443d4c1c727d8bd2a09dca6588dbc77a2260c3ffd159b98e65a2e3db3fc9b46fefc388aacfff52fb0e12cf23c18e59a13f7b6ec73cdd9b7ecd8737
|
7
|
+
data.tar.gz: 85c14c0b9bcfa716f3d46d4c0a3d78f11cd93781f02d9b166d2f8145285b0fd3073818126f3dd1b7c56eb7e427716071dbd55a1967e8bef01d014e37c1941da8
|
@@ -88,14 +88,17 @@ class CreditCardSanitizer
|
|
88
88
|
# sanitize!("I want all your credit card numbers!")
|
89
89
|
# #=> nil
|
90
90
|
#
|
91
|
-
#
|
92
|
-
#
|
91
|
+
# If options[:return_changes] is false, returns nil if no redaction happened,
|
92
|
+
# else the full text after redaction.
|
93
|
+
#
|
94
|
+
# If options[:return_changes] is true, returns nil if no redaction happened,
|
95
|
+
# else an array of [old_text, new_text] indicating what substrings were redacted.
|
93
96
|
def sanitize!(text, options = {})
|
94
97
|
options = @settings.merge(options)
|
95
98
|
|
96
99
|
text.force_encoding(Encoding::UTF_8)
|
97
100
|
text.scrub!('�')
|
98
|
-
|
101
|
+
changes = nil
|
99
102
|
|
100
103
|
without_expiration(text) do
|
101
104
|
text.gsub!(NUMBERS_WITH_LINE_NOISE) do |match|
|
@@ -104,15 +107,21 @@ class CreditCardSanitizer
|
|
104
107
|
candidate = Candidate.new(match, match.tr('^0-9', ''), $`, $')
|
105
108
|
|
106
109
|
if valid_context?(candidate, options) && valid_numbers?(candidate, options)
|
107
|
-
|
108
|
-
|
110
|
+
redact_numbers(candidate, options).tap do |redacted_text|
|
111
|
+
changes ||= []
|
112
|
+
changes << [candidate.text, redacted_text]
|
113
|
+
end
|
109
114
|
else
|
110
115
|
match
|
111
116
|
end
|
112
117
|
end
|
113
118
|
end
|
114
119
|
|
115
|
-
|
120
|
+
if options[:return_changes]
|
121
|
+
changes
|
122
|
+
else
|
123
|
+
changes && text
|
124
|
+
end
|
116
125
|
end
|
117
126
|
|
118
127
|
# A proc that can be used
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_card_sanitizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Chapweske
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: irb
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: luhn_checksum
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|