confidential_info_redactor_lite 0.0.5 → 0.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: cb1d40cc5cb9d1091e2e93069b4c76ef6341e576
4
- data.tar.gz: 761060bda57eaf641b8966fe9c68a2f3606f8e6b
3
+ metadata.gz: ae3ba12bb0731420494dd385bff38b9315ff938d
4
+ data.tar.gz: 5482bf82d5ea1551b205885e6aaec908f328910f
5
5
  SHA512:
6
- metadata.gz: feb564843b2a9ae74d19b350ba27a58c3a26d72b763bc1538e4b00f8f968f35c3f0570ad5222860db291adc548261eeaa3f5c958fe096eaf3c4f3d6970e02552
7
- data.tar.gz: c1e8a49771ab2ac72026e7b9b23261bc2af78764bc3250f21e8220eaf239fd657430227cf5c51a3e7d3d8cfc7656c9728483810523939490a1fbd3e80ff87fe0
6
+ metadata.gz: 187274627b9d905463e45e6c24465cb5d55cf7e8c84207568e3feaa237a6e96d31035e20c21a623e177a3ca8a60c5a157fa25ac878271e853ffcd630bb361164
7
+ data.tar.gz: c96104ef54fc174b547591e7569c6c404d1d8c6d077e2cd4e87db0673817956050df526104b2b38d920c873a8d993294993d897765988b36362760ffe0af20c4
data/README.md CHANGED
@@ -54,7 +54,7 @@ ConfidentialInfoRedactorLite::Redactor.new(text: text, dow: en_dow, dow_abbr: en
54
54
  # => 'Coca-Cola announced a merger with Pepsi that will happen on <redacted date> for $200,000,000,000. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
55
55
 
56
56
  ConfidentialInfoRedactorLite::Redactor.new(text: text, dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).numbers
57
- # => 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for <redacted number>. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
57
+ # => 'Coca-Cola announced a merger with Pepsi that will happen on December <redacted number>, <redacted number> for <redacted number>. Please contact John Smith at j.smith@example.com or visit http://www.super-fake-merger.com.'
58
58
 
59
59
  ConfidentialInfoRedactorLite::Redactor.new(text: text, dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).emails
60
60
  # => 'Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2020 for $200,000,000,000. Please contact John Smith at <redacted> or visit http://www.super-fake-merger.com.'
@@ -26,6 +26,7 @@ module ConfidentialInfoRedactorLite
26
26
  end
27
27
 
28
28
  def replace
29
+ return string unless dow.kind_of?(Array) && dow_abbr.kind_of?(Array) && months.kind_of?(Array) && months_abbr.kind_of?(Array)
29
30
  new_string = string.dup
30
31
  counter = 0
31
32
  dow_abbr.each do |day|
@@ -6,7 +6,8 @@ module ConfidentialInfoRedactorLite
6
6
  class Redactor
7
7
  # Rubular: http://rubular.com/r/LRRPtDgJOe
8
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)/
9
- EMAIL_REGEX = /(?<=\A|\s)[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+(?=\z|\s|\.)/i
9
+ # Rubular: http://rubular.com/r/mxcj2G0Jfa
10
+ EMAIL_REGEX = /(?<=\A|\s|\()[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+(?=\z|\s|\.|\))/i
10
11
 
11
12
  attr_reader :text, :language, :number_text, :date_text, :token_text, :tokens, :ignore_emails, :ignore_dates, :ignore_numbers, :ignore_hyperlinks, :dow, :dow_abbr, :months, :months_abbr
12
13
  def initialize(text:, dow:, dow_abbr:, months:, months_abbr:, **args)
@@ -1,3 +1,3 @@
1
1
  module ConfidentialInfoRedactorLite
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -27,6 +27,21 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
27
27
  text = 'The scavenger hunt ends on Dec. 31st, 2011.'
28
28
  expect(described_class.new(text: text, language: 'en', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).dates).to eq('The scavenger hunt ends on <redacted date>.')
29
29
  end
30
+
31
+ it 'handles nil date objects' do
32
+ text = 'The scavenger hunt ends on Dec. 31st, 2011.'
33
+ expect(described_class.new(text: text, language: 'en', dow: nil, dow_abbr: nil, months: nil, months_abbr: nil).dates).to eq('The scavenger hunt ends on Dec. 31st, 2011.')
34
+ end
35
+
36
+ it 'handles empty string date objects' do
37
+ text = 'The scavenger hunt ends on Dec. 31st, 2011.'
38
+ expect(described_class.new(text: text, language: 'en', dow: '', dow_abbr: '', months: '', months_abbr: '').dates).to eq('The scavenger hunt ends on Dec. 31st, 2011.')
39
+ end
40
+
41
+ it 'handles empty array date objects' do
42
+ text = 'The scavenger hunt ends on Dec. 31st, 2011.'
43
+ expect(described_class.new(text: text, language: 'en', dow: [], dow_abbr: [], months: [], months_abbr: []).dates).to eq('The scavenger hunt ends on Dec. 31st, 2011.')
44
+ end
30
45
  end
31
46
 
32
47
  describe '#numbers' do
@@ -51,6 +66,11 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
51
66
  text = 'His email is john@gmail.com or you can try k.light@tuv.eu.us.'
52
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).emails).to eq('His email is <redacted> or you can try <redacted>.')
53
68
  end
69
+
70
+ it 'redacts email addresses from a text #002' do
71
+ text = 'His email is (john@gmail.com) or you can try (k.light@tuv.eu.us).'
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).emails).to eq('His email is (<redacted>) or you can try (<redacted>).')
73
+ end
54
74
  end
55
75
 
56
76
  describe '#hyperlinks' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confidential_info_redactor_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
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-16 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler