confidential_info_redactor_lite 1.0.6 → 1.0.7
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: ab6eaa73743d300fc6918935988e050df53c0640
|
4
|
+
data.tar.gz: cc2fab161debe0f8eddbd9eb48f836896ef2d399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2df1d83ea6d00c0ad7738d420b2b30206c387d420cc511d0d7562aeacf815ef7a0e0d2a37d3416ace7862aad0fc21f0c65885031bf1b8b5c5fc7d0d27785a73c
|
7
|
+
data.tar.gz: 6ff9977e7f1c2a1355842f9de09eb8539340d79a08bb8580f645858569ae0c6b7b76a1fd29d5050deb02da2e418730ce5c78eca307de0c33f7e09b3fa5398191
|
@@ -3,8 +3,8 @@ module ConfidentialInfoRedactorLite
|
|
3
3
|
# Rubular: http://rubular.com/r/73CZ2HU0q6
|
4
4
|
DMY_MDY_REGEX = /(\d{1,2}(\/|\.|-)){2}\d{4}/
|
5
5
|
|
6
|
-
# Rubular: http://rubular.com/r/
|
7
|
-
YMD_YDM_REGEX =
|
6
|
+
# Rubular: http://rubular.com/r/wFI7dRLK3k
|
7
|
+
YMD_YDM_REGEX = /(?<=\A|\s)\d{4}(\/|\.|-)(\d{1,2}(\/|\.|-)){2}/
|
8
8
|
|
9
9
|
# Rubular: http://rubular.com/r/SRZ27XNlvR
|
10
10
|
DIGIT_ONLY_YEAR_FIRST_REGEX = /[12]\d{7}\D/
|
@@ -43,9 +43,9 @@ module ConfidentialInfoRedactorLite
|
|
43
43
|
|
44
44
|
def replace_number_only_date(text)
|
45
45
|
text.gsub(DMY_MDY_REGEX, ' <redacted date> ')
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
.gsub(YMD_YDM_REGEX, ' <redacted date> ')
|
47
|
+
.gsub(DIGIT_ONLY_YEAR_FIRST_REGEX, ' <redacted date> ')
|
48
|
+
.gsub(DIGIT_ONLY_YEAR_LAST_REGEX, ' <redacted date> ')
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
@@ -238,6 +238,12 @@ RSpec.describe ConfidentialInfoRedactorLite::Date do
|
|
238
238
|
ws = ConfidentialInfoRedactorLite::Date.new(dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr)
|
239
239
|
expect(ws.includes_date?(text)).to eq(false)
|
240
240
|
end
|
241
|
+
|
242
|
+
it 'returns false if the text does not include a date #037' do
|
243
|
+
text = '88966-5.0-ENG'
|
244
|
+
ws = ConfidentialInfoRedactorLite::Date.new(dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr)
|
245
|
+
expect(ws.includes_date?(text)).to eq(false)
|
246
|
+
end
|
241
247
|
end
|
242
248
|
|
243
249
|
context '#occurences' do
|
@@ -76,6 +76,16 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
76
76
|
text = '18/01/2013'
|
77
77
|
expect(described_class.new(language: 'de', dow: de_dow, dow_abbr: de_dow_abbr, months: de_months, months_abbr: de_month_abbr, date_text: "*****").dates_html(text)[1]).to eq(['18/01/2013'])
|
78
78
|
end
|
79
|
+
|
80
|
+
it 'surrounds the redacted dates in spans and return the redacted dates from a text #004' do
|
81
|
+
text = '16/01/2013'
|
82
|
+
expect(described_class.new(language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr, date_text: "*****").dates_html(text)[1]).to eq(["16/01/2013"])
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'surrounds the redacted dates in spans and return the redacted dates from a text #005' do
|
86
|
+
text = '88966-5.0-ENG'
|
87
|
+
expect(described_class.new(language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr, date_text: "*****").dates_html(text)[1]).to eq([])
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
81
91
|
describe '#numbers' do
|