confidential_info_redactor_lite 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad118f207a2c77d6576afe2450015ffb53362817
|
4
|
+
data.tar.gz: 5c62ec610e4ca6361fbf977614eb6a8565424451
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da649dbf21c536a4ba5404636297447db7adcafb78e5cbd7375a5d8bd21ee4d087c192214cfe52167c5a0090fd853fdccbe0d9f9aaf7212bb7d422ceb0348ab
|
7
|
+
data.tar.gz: 05c05072e9ebb34139c959f4e1c2351a36a6e48ea7d8bcd4a853cd75eea3ccc57e8fd4d5095e90a86c1fef8d84eb4657117f654457ed88eb1461fcb1962a6c28
|
@@ -4,8 +4,8 @@ require 'confidential_info_redactor_lite/hyperlink'
|
|
4
4
|
module ConfidentialInfoRedactorLite
|
5
5
|
# This class redacts various tokens from a text
|
6
6
|
class Redactor
|
7
|
-
# Rubular: http://rubular.com/r/
|
8
|
-
NUMBER_REGEX = /(?<=\A|\A\()[^(]?\d+((,|\.)*\d)*(\D?\s|\s|\.?\s|\.$)|(?<=\s|\s\()[^(]?\d+((,|\.)*\d)*(?=(\D?\s|\s|\.?\s|\.$))|(?<=\s)\d+(nd|th|st)|(?<=\s)\d+\/\d+\"*(?=\s)/
|
7
|
+
# Rubular: http://rubular.com/r/OI2wQZ0KSl
|
8
|
+
NUMBER_REGEX = /(?<=\A|\A\()[^(]?\d+((,|\.)*\d)*(\D?\s|\s|\.?\s|\.$)|(?<=\s|\s\()[^(]?\d+((,|\.)*\d)*(?=(\D?\s|\s|\.?\s|\.$))|(?<=\s)\d+(nd|th|st)|(?<=\s)\d+\/\d+\"*(?=\s)|(?<=\()\S{1}\d+(?=\))|(?<=\s{1})\S{1}\d+\z/
|
9
9
|
# Rubular: http://rubular.com/r/mxcj2G0Jfa
|
10
10
|
EMAIL_REGEX = /(?<=\A|\s|\()[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+(?=\z|\s|\.|\))/i
|
11
11
|
|
@@ -163,7 +163,7 @@ module ConfidentialInfoRedactorLite
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def redact_numbers(txt)
|
166
|
-
txt.gsub(NUMBER_REGEX, " #{number_text} ").gsub(/\s*#{Regexp.escape(number_text)}\s*/, " #{number_text} ").gsub(/\A\s*#{Regexp.escape(number_text)}\s*/, "#{number_text} ").gsub(/#{Regexp.escape(number_text)}\s{1}\.{1}/, "#{number_text}.").gsub(/#{Regexp.escape(number_text)}\s{1}\,{1}/, "#{number_text},").gsub(/#{Regexp.escape(number_text)}\s{1}\){1}/, "#{number_text})").gsub(/\(\s{1}#{Regexp.escape(number_text)}/, "(#{number_text}")
|
166
|
+
txt.gsub(NUMBER_REGEX, " #{number_text} ").gsub(/\s*#{Regexp.escape(number_text)}\s*/, " #{number_text} ").gsub(/\A\s*#{Regexp.escape(number_text)}\s*/, "#{number_text} ").gsub(/#{Regexp.escape(number_text)}\s{1}\.{1}/, "#{number_text}.").gsub(/#{Regexp.escape(number_text)}\s{1}\,{1}/, "#{number_text},").gsub(/#{Regexp.escape(number_text)}\s{1}\){1}/, "#{number_text})").gsub(/\(\s{1}#{Regexp.escape(number_text)}/, "(#{number_text}").gsub(/#{Regexp.escape(number_text)}\s\z/, "#{number_text}")
|
167
167
|
end
|
168
168
|
|
169
169
|
def redact_emails(txt)
|
@@ -66,6 +66,16 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
66
66
|
text = 'It was his 1st time, not yet his 10th, not even his 2nd. The wood was 3/4" thick.'
|
67
67
|
expect(described_class.new(text: text, language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).numbers).to eq('It was his <redacted number> time, not yet his <redacted number>, not even his <redacted number>. The wood was <redacted number> thick.')
|
68
68
|
end
|
69
|
+
|
70
|
+
it 'redacts numbers from a text #004' do
|
71
|
+
text = 'Checking file of %2'
|
72
|
+
expect(described_class.new(text: text, language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).numbers).to eq('Checking file of <redacted number>')
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'redacts numbers from a text #005' do
|
76
|
+
text = 'zawiera pliki skompresowane (%2).'
|
77
|
+
expect(described_class.new(text: text, language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).numbers).to eq('zawiera pliki skompresowane (<redacted number>).')
|
78
|
+
end
|
69
79
|
end
|
70
80
|
|
71
81
|
describe '#numbers_html' do
|