confidential_info_redactor_lite 1.0.6 → 1.0.7

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: e591d6c6ad041c36fd2c70ae92fb92df5ef5b988
4
- data.tar.gz: 392b6e548ca876c04c1a1d747ca6753d82c73433
3
+ metadata.gz: ab6eaa73743d300fc6918935988e050df53c0640
4
+ data.tar.gz: cc2fab161debe0f8eddbd9eb48f836896ef2d399
5
5
  SHA512:
6
- metadata.gz: f4b626fcd913d8a33e542a2b3396c3a137719fbca95e8d151e59b178aef09206d754711dc986c6e5d6a99a7ac42721ea6a111acbe8090ca5dc9045d94bf9a68c
7
- data.tar.gz: 7b270a2fa019c54d4ab9688c6cd2f20c8182506d1c2faea43d95b378e572e52723fecc2d4352ea7a47113c7e2a5b0e77ec67847d15e14331606fef5a07a58623
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/GWbuWXw4t0
7
- YMD_YDM_REGEX = /\d{4}(\/|\.|-)(\d{1,2}(\/|\.|-)){2}/
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
- .gsub(YMD_YDM_REGEX, ' <redacted date> ')
47
- .gsub(DIGIT_ONLY_YEAR_FIRST_REGEX, ' <redacted date> ')
48
- .gsub(DIGIT_ONLY_YEAR_LAST_REGEX, ' <redacted date> ')
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
@@ -1,3 +1,3 @@
1
1
  module ConfidentialInfoRedactorLite
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confidential_info_redactor_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias