confidential_info_redactor 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7c9a3022b0122037ea64027a97f943cc753ac89
|
4
|
+
data.tar.gz: 77397cc9d846338bb693f1fc809c3811b286cc85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e07f637b20ca03bb595f540a9e631d2b78fd8f1b739073d79b06b2fa1caafde0882c6190b4d572b278779fddf7a7a49a69f2c96690de9410a57bbd17b364b738
|
7
|
+
data.tar.gz: 5ce788d7905e95ee76f92a9edd572e015d68e794986e1c26a9bb1a74e9cce0edd285dedcafd828d2a8ec71e8f632a04fa8295b07fdea4a5e23454b4de317d59f
|
@@ -75,7 +75,7 @@ module ConfidentialInfoRedactor
|
|
75
75
|
|
76
76
|
def redact_tokens(txt)
|
77
77
|
tokens.sort_by{ |x| x.split.count }.reverse.each do |token|
|
78
|
-
txt.gsub!(
|
78
|
+
txt.gsub!(/(?<=\s|^|\")#{Regexp.escape(token)}/, "#{token_text}")
|
79
79
|
end
|
80
80
|
txt
|
81
81
|
end
|
@@ -169,5 +169,11 @@ RSpec.describe ConfidentialInfoRedactor::Redactor do
|
|
169
169
|
text = 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
|
170
170
|
expect(described_class.new(text: text, language: 'en', tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****').redact).to eq('***** announced a merger with ***** that will happen on ^^redacted date^^ for **redacted number**. Please contact ***** at ***** or visit *****.')
|
171
171
|
end
|
172
|
+
|
173
|
+
it 'redacts all confidential information from a text #006' do
|
174
|
+
tokens = ['CLA']
|
175
|
+
text = 'LEGAL DISCLAIMER - CLA will not be held reponsible for changes.'
|
176
|
+
expect(described_class.new(text: text, language: 'en', tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****').redact).to eq("LEGAL DISCLAIMER - ***** will not be held reponsible for changes.")
|
177
|
+
end
|
172
178
|
end
|
173
179
|
end
|