confidential_info_redactor_lite 0.0.11 → 0.0.12

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: da81c29742b6a0de3ff4fda8642708463d2e5ff3
4
- data.tar.gz: 08df7243749f2ddf249b7035465fae927becf582
3
+ metadata.gz: ad118f207a2c77d6576afe2450015ffb53362817
4
+ data.tar.gz: 5c62ec610e4ca6361fbf977614eb6a8565424451
5
5
  SHA512:
6
- metadata.gz: 6ec8c4ad9f55ebe4755c8a7024a8b5795be487dbdaaf658f3f3797a9242195fc149b2133085eb4c5f3dde7d08cd051571296b17b0565682e3932d13702f9b842
7
- data.tar.gz: 3bcda0bdef7a7f80484ef462301ad715568f683fc50241fa59be725605cd717f91161dbba713d09c13fb7e650ba5f968218e52cf8b2db2b5969cecaf61d1df73
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/LRRPtDgJOe
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)
@@ -1,3 +1,3 @@
1
1
  module ConfidentialInfoRedactorLite
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -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
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: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias