email_reply_trimmer 0.1.7 → 0.1.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: ae957d1af8aa2d31792525c2eeb9e87ee6343813
4
- data.tar.gz: 0c40d729c66e243f8ac86a59bc861909abbeb786
3
+ metadata.gz: 402d5791ea53b316a7ea2d7a972621060fbb632c
4
+ data.tar.gz: c8c406d99a009bbf32b9ebef739cc46eaa361cfa
5
5
  SHA512:
6
- metadata.gz: afe3ca86183de852123dcc52e1ef2303ba947253c35ca41605377582cfb7b21a7c8fae7b6a9240e2fcab7cc14984f545e7a34c814f6a1742f8817a6c45760f3e
7
- data.tar.gz: c0a3aafb8b37d12bb5751ca89fa99dfe5a4b07db23597227b102eca3939dfdb95685cd19629c3d818011a5b350fec68db9224748578b98a93096e1bb3dc2201d
6
+ metadata.gz: 530b38bed9536b989a66146001f7514b54b5b905c6eedce1032d82267cc72f0072bac8483d5ac126d41848ce9963014a5330cfd89f9db4aea62138e7ab5bfc6c
7
+ data.tar.gz: 721fd78143d81634eefa49a6df73b6565f1a5ea9fae598fc57e67509f988efb7b47de654ab4d16f3b5513799d80b686bd50a5721eb8b383630b1024173b02961
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in email_reply_trimmer.gemspec
4
+ gemspec
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ email_reply_trimmer (0.1.7)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.3.0)
10
+ minitest (5.10.3)
11
+ parallel (1.11.2)
12
+ parser (2.4.0.0)
13
+ ast (~> 2.2)
14
+ powerpack (0.1.1)
15
+ rainbow (2.2.2)
16
+ rake
17
+ rake (12.0.0)
18
+ rubocop (0.49.1)
19
+ parallel (~> 1.10)
20
+ parser (>= 2.3.3.1, < 3.0)
21
+ powerpack (~> 0.1)
22
+ rainbow (>= 1.99.1, < 3.0)
23
+ ruby-progressbar (~> 1.7)
24
+ unicode-display_width (~> 1.0, >= 1.0.1)
25
+ ruby-progressbar (1.8.1)
26
+ unicode-display_width (1.3.0)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ email_reply_trimmer!
33
+ minitest (~> 5)
34
+ rake (~> 12)
35
+ rubocop (~> 0)
36
+
37
+ BUNDLED WITH
38
+ 1.16.0.pre.2
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ def version
6
6
  @version ||= File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*['"](?'version'\d+\.\d+\.\d+)['"]/, "version"]
7
7
  end
8
8
 
9
- task :default => :test
9
+ task default: :test
10
10
 
11
11
  require "rake/testtask"
12
12
  Rake::TestTask.new(:test)
@@ -15,6 +15,10 @@ Gem::Specification.new do |s|
15
15
  s.license = "MIT"
16
16
 
17
17
  s.require_paths = ["lib"]
18
- s.files = Dir["**/*"].reject { |path| File.directory?(path) }
18
+ s.files = Dir["**/*"].reject { |path| File.directory?(path) || path =~ /.*\.gem$/ }
19
19
  s.test_files = s.files.select { |path| path =~ /^test\/.+_test\.rb$/ }
20
+
21
+ s.add_development_dependency 'rake', '~> 12'
22
+ s.add_development_dependency 'minitest', '~> 5'
23
+ s.add_development_dependency 'rubocop', '~> 0'
20
24
  end
@@ -6,7 +6,7 @@ require_relative "email_reply_trimmer/email_header_matcher"
6
6
  require_relative "email_reply_trimmer/quote_matcher"
7
7
 
8
8
  class EmailReplyTrimmer
9
- VERSION = "0.1.7"
9
+ VERSION = "0.1.8"
10
10
 
11
11
  DELIMITER = "d"
12
12
  EMBEDDED = "b"
@@ -26,7 +26,7 @@ class EmailReplyTrimmer
26
26
  return TEXT
27
27
  end
28
28
 
29
- def self.trim(text, split=false)
29
+ def self.trim(text, split = false)
30
30
  return if text.nil? || text =~ /\A[[:space:]]*\z/m
31
31
 
32
32
  # do some cleanup
@@ -13,25 +13,25 @@ class EmbeddedEmailMatcher
13
13
  # At 6/16/2016 08:32 PM, you wrote:
14
14
  ON_DATE_SOMEONE_WROTE_REGEXES ||= [
15
15
  # Chinese
16
- /^[[:blank:]<>-]*在 ((?!\b(在|写道)\b)[\s\S])+?写道[[:blank:].:>-]*$/i,
16
+ /^[[:blank:]<>-]*在 (?:(?!\b(?>在|写道)\b).)+?写道[[:blank:].:>-]*$/im,
17
17
  # Dutch
18
- /^[[:blank:]<>-]*Op ((?!\b(Op|het\svolgende\sgeschreven|schreef)\b)[\s\S])+?(het\svolgende\sgeschreven|schreef[^:]+)[[:blank:].:>-]*$/i,
18
+ /^[[:blank:]<>-]*Op (?:(?!\b(?>Op|het\svolgende\sgeschreven|schreef)\b).)+?(het\svolgende\sgeschreven|schreef[^:]+)[[:blank:].:>-]*$/im,
19
19
  # English
20
- /^[[:blank:]<>-]*In message ((?!\b(In message|writes)\b)[\s\S])+?writes[[:blank:].:>-]*$/i,
21
- /^[[:blank:]<>-]*(On|At) ((?!\b(On|wrote|writes|says|said)\b)[\s\S])+?(wrote|writes|says|said)[[:blank:].:>-]*$/i,
20
+ /^[[:blank:]<>-]*In message (?:(?!\b(?>In message|writes)\b).)+?writes[[:blank:].:>-]*$/im,
21
+ /^[[:blank:]<>-]*(On|At) (?:(?!\b(?>On|wrote|writes|says|said)\b).)+?(wrote|writes|says|said)[[:blank:].:>-]*$/im,
22
22
  # French
23
- /^[[:blank:]<>-]*Le ((?!\b(Le|nous\sa\sdit|a\s+écrit)\b)[\s\S])+?(nous\sa\sdit|a\s+écrit)[[:blank:].:>-]*$/i,
23
+ /^[[:blank:]<>-]*Le (?:(?!\b(?>Le|nous\sa\sdit|a\s+écrit)\b).)+?(nous\sa\sdit|a\s+écrit)[[:blank:].:>-]*$/im,
24
24
  # German
25
- /^[[:blank:]<>-]*Am ((?!\b(Am|schrieben\sSie)\b)[\s\S])+?schrieben\sSie[[:blank:].:>-]*$/i,
26
- /^[[:blank:]<>-]*Am ((?!\b(Am|geschrieben)\b)[\s\S])+?(geschrieben|schrieb[^:]+)[[:blank:].:>-]*$/i,
25
+ /^[[:blank:]<>-]*Am (?:(?!\b(?>Am|schrieben\sSie)\b).)+?schrieben\sSie[[:blank:].:>-]*$/im,
26
+ /^[[:blank:]<>-]*Am (?:(?!\b(?>Am|geschrieben)\b).)+?(geschrieben|schrieb[^:]+)[[:blank:].:>-]*$/im,
27
27
  # Italian
28
- /^[[:blank:]<>-]*Il ((?!\b(Il|ha\sscritto)\b)[\s\S])+?ha\sscritto[[:blank:].:>-]*$/i,
28
+ /^[[:blank:]<>-]*Il (?:(?!\b(?>Il|ha\sscritto)\b).)+?ha\sscritto[[:blank:].:>-]*$/im,
29
29
  # Polish
30
- /^[[:blank:]<>-]*(Dnia|Dňa) ((?!\b(Dnia|Dňa|napisał)\b)[\s\S])+?napisał(\(a\))?[[:blank:].:>-]*$/i,
30
+ /^[[:blank:]<>-]*(Dnia|Dňa) (?:(?!\b(?>Dnia|Dňa|napisał)\b).)+?napisał(\(a\))?[[:blank:].:>-]*$/im,
31
31
  # Portuguese
32
- /^[[:blank:]<>-]*Em ((?!\b(Em|escreveu)\b)[\s\S])+?escreveu[[:blank:].:>-]*$/i,
32
+ /^[[:blank:]<>-]*Em (?:(?!\b(?>Em|escreveu)\b).)+?escreveu[[:blank:].:>-]*$/im,
33
33
  # Spanish
34
- /^[[:blank:]<>-]*El ((?!\b(El|escribió)\b)[\s\S])+?escribió[[:blank:].:>-]*$/i,
34
+ /^[[:blank:]<>-]*El (?:(?!\b(?>El|escribió)\b).)+?escribió[[:blank:].:>-]*$/im,
35
35
  ]
36
36
 
37
37
  # Op 10 dec. 2015 18:35 schreef "Arpit Jalan" <info@discourse.org>:
@@ -80,7 +80,6 @@ class EmbeddedEmailMatcher
80
80
  # 2016-03-03 17:21 GMT+01:00 Some One
81
81
  ISO_DATE_SOMEONE_REGEX = /^[[:blank:]>]*20\d\d-\d\d-\d\d \d\d:\d\d GMT\+\d\d:\d\d [\w[:blank:]]+$/
82
82
 
83
-
84
83
  # 2015-10-18 0:17 GMT+03:00 Matt Palmer <info@discourse.org>:
85
84
  # 2013/10/2 camilohollanda <info@discourse.org>
86
85
  # вт, 5 янв. 2016 г. в 23:39, Erlend Sogge Heggen <info@discourse.org>:
@@ -0,0 +1,5 @@
1
+ > am 09.09.2017 um 21:42 sssssss
2
+ ßßßßßßßß fffffff
3
+
4
+ > in message from sssssss
5
+ ßßßßßßßß fffffff
@@ -0,0 +1,15 @@
1
+ require "minitest/autorun"
2
+ require "email_reply_trimmer"
3
+ require "timeout"
4
+
5
+ class TestEmailReplyTrimmer < Minitest::Test
6
+ def test_does_not_hang_when_no_embedded_email_is_found
7
+ Timeout.timeout(5) do
8
+ EmbeddedEmailMatcher.match?(example("does_not_contain_embedded_email.txt"))
9
+ end
10
+ end
11
+
12
+ def example(filename)
13
+ File.read("test/matchers/#{filename}").strip
14
+ end
15
+ end
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_reply_trimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Régis Hanol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: EmailReplyTrimmer is a small library to trim replies from plain text
14
56
  email.
15
57
  email:
@@ -18,6 +60,8 @@ executables: []
18
60
  extensions: []
19
61
  extra_rdoc_files: []
20
62
  files:
63
+ - Gemfile
64
+ - Gemfile.lock
21
65
  - LICENSE
22
66
  - README.md
23
67
  - Rakefile
@@ -159,6 +203,8 @@ files:
159
203
  - test/embedded/embedded_email_german_3.txt
160
204
  - test/embedded/embedded_email_spanish_2.txt
161
205
  - test/embedded/forwarded_message.txt
206
+ - test/matchers/does_not_contain_embedded_email.txt
207
+ - test/test_email_matcher.rb
162
208
  - test/test_email_reply_trimmer.rb
163
209
  - test/trimmed/delimiters.txt
164
210
  - test/trimmed/dual_embedded.txt
@@ -237,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
283
  version: '0'
238
284
  requirements: []
239
285
  rubyforge_project:
240
- rubygems_version: 2.6.11
286
+ rubygems_version: 2.6.13
241
287
  signing_key:
242
288
  specification_version: 4
243
289
  summary: Library to trim replies from plain text email.