confidential_info_redactor 0.0.7 → 0.0.8
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: 618575745203cab096e0fe7c6589ebbaadb45b69
|
4
|
+
data.tar.gz: 6259ad839c30e5abbe079c3ce7affb109ea17367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22656a12c77e0b18016e1860104e6c287eb29d2cb0fc431d9edcd851e42bcf1ac2488865d0773f784ceaab2e4b161d49729e0d840cd5239a98e6982069f9d823
|
7
|
+
data.tar.gz: a85abad1e3687888d022cc15e9b47f4e515173824185f26bc21b4ab7449b1fdf2c9ee3e1a01ae32d69c4784e10e492a381b34aaf515ba10b8861c974c4d59b89
|
@@ -4,8 +4,8 @@ require 'confidential_info_redactor/hyperlink'
|
|
4
4
|
module ConfidentialInfoRedactor
|
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
|
|
@@ -66,7 +66,7 @@ module ConfidentialInfoRedactor
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def redact_numbers(txt)
|
69
|
-
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}")
|
69
|
+
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}")
|
70
70
|
end
|
71
71
|
|
72
72
|
def redact_emails(txt)
|
@@ -38,6 +38,16 @@ RSpec.describe ConfidentialInfoRedactor::Redactor do
|
|
38
38
|
text = 'It was his 1st time, not yet his 10th, not even his 2nd. The wood was 3/4" thick.'
|
39
39
|
expect(described_class.new(text: text, language: 'en').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.')
|
40
40
|
end
|
41
|
+
|
42
|
+
it 'redacts numbers from a text #004' do
|
43
|
+
text = 'Checking file of %2'
|
44
|
+
expect(described_class.new(text: text, language: 'en').numbers).to eq('Checking file of <redacted number>')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'redacts numbers from a text #005' do
|
48
|
+
text = 'zawiera pliki skompresowane (%2).'
|
49
|
+
expect(described_class.new(text: text, language: 'en').numbers).to eq('zawiera pliki skompresowane (<redacted number>).')
|
50
|
+
end
|
41
51
|
end
|
42
52
|
|
43
53
|
describe '#emails' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confidential_info_redactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin S. Dias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|