confidential_info_redactor_lite 0.0.26 → 0.0.27

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: e5acaf81f53e7390182f433c0904c0046cd6b887
4
- data.tar.gz: 7463858f0d108d8cfb4bfe5c4794ccf9c2dceb03
3
+ metadata.gz: 0ceeb1140b59f594ab6600ed27b362721f7626cb
4
+ data.tar.gz: b8daee381620d1fdd3e3883c1ea9d0702ceb2c6f
5
5
  SHA512:
6
- metadata.gz: b688792d2d55b1b09b13e41b77e0a3b45571632ea78d371373025a2c6f8a805a622f4f322610a4ef1a0ac6a260a6c8630e539220f1b384115b2f24d98e7eb5f2
7
- data.tar.gz: a2b71134454512b86b6388ab1f06cd75dc736fa9c8778501aeca2eee87bdccd95ac1b0646d57674359be9f667533c52cee28f8e91766217e588a86fa0c6eca0b
6
+ metadata.gz: 7c8dbb77b0779043b8fcdc501730624f7827d0e54d1a81cdaaf33e677ef9b2242854c323b0eeb535eb97096cb0e97a3a225ab2642058de2f24c36ac473c983dc
7
+ data.tar.gz: 6b426392130a87db3b65a320a74f77911f2db7491e80f7becf793d216f9a5d538ad76a41c79980e389285d10fa74ee383ba5fb9f381a4f14f5cc29b80a3f5411
@@ -88,10 +88,14 @@ module ConfidentialInfoRedactorLite
88
88
 
89
89
  def redact_hyperlinks_html(txt)
90
90
  redacted_text = redact_hyperlinks(txt).gsub(/\>\s#{Regexp.escape(token_text)}\s\</, ">#{token_text}<").gsub(/\>\s#{Regexp.escape(number_text)}\s\</, ">#{number_text}<").gsub(/\>\s#{Regexp.escape(date_text)}\s\</, ">#{date_text}<").gsub(/\>\s#{Regexp.escape(email_text)}\s\</, ">#{email_text}<").gsub(/\>\s#{Regexp.escape(hyperlink_text)}\s\</, ">#{hyperlink_text}<")
91
- original_sentence_array = txt.split(' ')
92
- redacted_sentence_array = redacted_text.split(' ')
93
- diff = original_sentence_array - redacted_sentence_array
94
- final_hyperlinks_tokens = diff.map { |token| token[-1].eql?('.') ? token[0...-1] : token }.map { |token| token[-1].eql?(')') ? token[0...-1] : token }.map { |token| token[0].eql?('(') ? token[1..token.length] : token }
91
+ if language.eql?('ja')
92
+ final_hyperlinks_tokens = txt.scan(/http[a-zA-Z\/\:\.\-]+|www[a-zA-Z\/\:\.\-]+/)
93
+ else
94
+ original_sentence_array = txt.split(' ')
95
+ redacted_sentence_array = redacted_text.split(' ')
96
+ diff = original_sentence_array - redacted_sentence_array
97
+ final_hyperlinks_tokens = diff.map { |token| token[-1].eql?('.') ? token[0...-1] : token }.map { |token| token[-1].eql?(')') ? token[0...-1] : token }.map { |token| token[0].eql?('(') ? token[1..token.length] : token }
98
+ end
95
99
  [redacted_text.gsub(/(?<=[^\>])#{Regexp.escape(hyperlink_text)}/, "<span class='confidentialHyperlinks'>#{hyperlink_text}</span>"), final_hyperlinks_tokens]
96
100
  end
97
101
 
@@ -1,3 +1,3 @@
1
1
  module ConfidentialInfoRedactorLite
2
- VERSION = "0.0.26"
2
+ VERSION = "0.0.27"
3
3
  end
@@ -239,6 +239,11 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
239
239
  text = 'My Transformation - avoid Trans.'
240
240
  expect(described_class.new(text: text, language: 'en', tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****', hyperlink_text: '*****', email_text: '*****', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).redact).to eq('My Transformation - avoid *****.')
241
241
  end
242
+
243
+ it 'redacts all confidential information from a text #007' do
244
+ text = 'これはjohn@gmail.comかk.light@tuv.eu.usかhttps://www.tm-town.comです.'
245
+ expect(described_class.new(text: text, language: 'ja', tokens: nil, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****', hyperlink_text: '*****', email_text: '*****', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).hyperlinks_html[1]).to eq(["https://www.tm-town.com"])
246
+ end
242
247
  end
243
248
 
244
249
  describe '#redact_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.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias