confidential_info_redactor 0.0.2 → 0.0.3

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: 4d338f87e494bb5344afb17beddcad0925a9e27a
4
- data.tar.gz: a693a3ced90f8832a9d790801c0ab12b5a038728
3
+ metadata.gz: 53df3b59f337fc1c1975f4cc37701bce82867bea
4
+ data.tar.gz: 48619c48b24dcc0fdfc6b407f911045f4c5286c7
5
5
  SHA512:
6
- metadata.gz: 7f7b9244576de26921a65711ea4acf86febb618fdf4fede08a08969553561caaff8e01ac680e79ac73da39a29bcedc69de1a0fb3165063d9b1212773d92481f7
7
- data.tar.gz: 1fbbfa9fb2c81ef8acc55ad01c342faba03d64913daae0b9775905d56737ea0327a411d5b579711f0adb5f196d3d709eb985976568526a599f3a7f99efe7dae9
6
+ metadata.gz: b63e2e817891fe6fe20664f7b0dd279193015ad6b491303914593f2955c1941e1277e3f58b4eff7e9d166378f7b4455cb8143b0df51413bdbe068a01df295d9f
7
+ data.tar.gz: 66af11baec2a927039becc83da9366d5beea1c8fcb263ec15c78af4b6f3ac5558566fb18e624e4f9e0a530598d4834d47998ab8ee97bb18f52b4ff6327ec7ac6
data/README.md CHANGED
@@ -74,7 +74,8 @@ ConfidentialInfoRedactor::Redactor.new(text: text, language: 'de', tokens: token
74
74
  # => 'Viele Mitarbeiter der <redacted> suchen eine andere Arbeitsstelle.'
75
75
 
76
76
  # It is also possible to change the redaction text
77
- tokens = ['Coca-Cola', 'Pepsi']
77
+ text = 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
78
+ tokens = ['Coca-Cola', 'Pepsi', 'John Smith']
78
79
  ConfidentialInfoRedactor::Redactor.new(text: text, tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****').redact
79
80
  # => '***** announced a merger with ***** that will happen on ^^redacted date^^ for **redacted number**. Please contact ***** at ***** or visit *****.'
80
81
  ```
@@ -62,7 +62,7 @@ module ConfidentialInfoRedactor
62
62
  end
63
63
 
64
64
  def redact_dates(txt)
65
- ConfidentialInfoRedactor::Date.new(string: txt, language: language).replace.gsub(/\s*#{Regexp.escape(date_text)}\s*/, " #{date_text} ").gsub(/\A\s*#{Regexp.escape(date_text)}\s*/, "#{date_text} ").gsub(/#{Regexp.escape(date_text)}\s{1}\.{1}/, "#{date_text}.")
65
+ ConfidentialInfoRedactor::Date.new(string: txt, language: language).replace.gsub(/<redacted date>/, "#{date_text}").gsub(/\s*#{Regexp.escape(date_text)}\s*/, " #{date_text} ").gsub(/\A\s*#{Regexp.escape(date_text)}\s*/, "#{date_text} ").gsub(/#{Regexp.escape(date_text)}\s{1}\.{1}/, "#{date_text}.")
66
66
  end
67
67
 
68
68
  def redact_numbers(txt)
@@ -1,3 +1,3 @@
1
1
  module ConfidentialInfoRedactor
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -148,5 +148,11 @@ RSpec.describe ConfidentialInfoRedactor::Redactor do
148
148
  text = 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
149
149
  expect(described_class.new(text: text, language: 'en', tokens: tokens, ignore_numbers: true).redact).to eq('<redacted> announced a merger with <redacted> that will happen on <redacted date> for $200,000,000,000. Please contact <redacted> at <redacted> or visit <redacted>.')
150
150
  end
151
+
152
+ it 'redacts all confidential information from a text #005' do
153
+ tokens = ['Coca-Cola', 'Pepsi', 'John Smith']
154
+ text = 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
155
+ expect(described_class.new(text: text, language: 'en', tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****').redact).to eq('***** announced a merger with ***** that will happen on ^^redacted date^^ for **redacted number**. Please contact ***** at ***** or visit *****.')
156
+ end
151
157
  end
152
158
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confidential_info_redactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias