autoreply 0.1.4 → 0.1.5

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: 47956b1d37432fb647cdbbacbb6dd281fbe1f48b
4
- data.tar.gz: d2a3923cea5db75c953dc6524fa6214782f64dbb
3
+ metadata.gz: fbcf65375076de7bb3f98a32dac4628616b53ee8
4
+ data.tar.gz: dd05c933c3b911f4a43546a48fa7d6f5d988e168
5
5
  SHA512:
6
- metadata.gz: 1e022aad2ff2980ae5934b1d0b7f02337f6d1ab3f9182b4aad2db1b01f14c6b8c7c740f679355d1742050dc48b62c2618b642e2bfb7b3500cba3f006cec007c4
7
- data.tar.gz: 57e658ae6679a8e3b35da154d61a730bdaec15169cf4c743c8a8346cf333dea781175fb90a563d9a74f539968fc5713283038351d26014558e65236e0f49d4cd
6
+ metadata.gz: 3d3808de756d9be6b844d4dc77294503afc84a31a36947d8b1b4705293ef7aaf11658f00f853c32c30a2c3a21d166a02c8023b716aa70271a9251460fc6d39cf
7
+ data.tar.gz: f1ad39f5f4e5464621f5839973e1857fdd20bd386fcc8c4bf85462ef8073bba250250da5e67b649a246deb8c254b185f37cbd9d7aeef1e60b2594566348ee956
@@ -4,6 +4,7 @@ require "autoreply/scanner/base"
4
4
  require "autoreply/scanner/sender"
5
5
  require "autoreply/scanner/subject"
6
6
  require "autoreply/scanner/headers"
7
+ require "autoreply/scanner/microsoft_outlook"
7
8
  require "autoreply/scanner/headers/base"
8
9
  require "autoreply/scanner/headers/by_existance"
9
10
  require "autoreply/scanner/headers/by_value"
@@ -7,9 +7,10 @@ module Autoreply
7
7
  end
8
8
 
9
9
  def autoreply?
10
- sender_scanner.autoreply? ||
10
+ sender_scanner.autoreply? ||
11
11
  subject_scanner.autoreply? ||
12
- headers_scanner.autoreply?
12
+ headers_scanner.autoreply? ||
13
+ microsoft_outlook_scanner.autoreply?
13
14
  end
14
15
 
15
16
  private
@@ -25,5 +26,9 @@ module Autoreply
25
26
  def headers_scanner
26
27
  Scanner::Headers.new(mail)
27
28
  end
29
+
30
+ def microsoft_outlook_scanner
31
+ Scanner::MicrosoftOutlook.new(mail)
32
+ end
28
33
  end
29
34
  end
@@ -0,0 +1,33 @@
1
+ module Autoreply
2
+ class Scanner::MicrosoftOutlook < Scanner::Base
3
+ OUT_OF_OFFICE_PHRASES_REGEXPS = [
4
+ /(O|o)ut\s(O|o)f(\s(T|t)he)?\s(O|o)ffice/,
5
+ /(F|f)uera(\s(D|d)e)?(\s(L|l)a)?\s(O|o)ficina/
6
+ ]
7
+
8
+ def autoreply?
9
+ outlook_x_mailer_header? && contains_out_of_office_phrase?
10
+ end
11
+
12
+ private
13
+
14
+ def outlook_x_mailer_header?
15
+ return false if x_mailer_header.nil?
16
+
17
+ x_mailer_header.value =~ /((M|m)icrosoft\s)?(O|o)utlook/
18
+ end
19
+
20
+ def contains_out_of_office_phrase?
21
+ result = OUT_OF_OFFICE_PHRASES_REGEXPS.inject([]) do |result, regexp|
22
+ result << regexp if mail.body.to_s =~ regexp
23
+ result
24
+ end
25
+
26
+ !result.empty?
27
+ end
28
+
29
+ def x_mailer_header
30
+ mail.header_fields.detect {|header| header.name == "x-mailer" }
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Autoreply
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoreply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Kishenin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-02-03 00:00:00.000000000 Z
12
+ date: 2017-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -93,6 +93,7 @@ files:
93
93
  - lib/autoreply/scanner/headers/base.rb
94
94
  - lib/autoreply/scanner/headers/by_existance.rb
95
95
  - lib/autoreply/scanner/headers/by_value.rb
96
+ - lib/autoreply/scanner/microsoft_outlook.rb
96
97
  - lib/autoreply/scanner/sender.rb
97
98
  - lib/autoreply/scanner/subject.rb
98
99
  - lib/autoreply/version.rb