File Coverage

lib/Sisimai/Reason/Expired.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 8 8 100.0
pod 2 4 50.0
total 39 41 95.1


line stmt bran cond sub pod time code
1             package Sisimai::Reason::Expired;
2 26     26   3013 use v5.26;
  26         101  
3 26     26   135 use strict;
  26         54  
  26         790  
4 26     26   113 use warnings;
  26         56  
  26         1367  
5 26     26   157 use Sisimai::String;
  26         55  
  26         7438  
6              
7 7     7 1 21 sub text { 'expired' }
8 4     4 0 15 sub description { 'Delivery time has expired due to a connection failure' }
9             sub match {
10             # Try to match that the given text and regular expressions
11             # @param [String] argv1 String to be matched with regular expressions
12             # @return [Integer] 0: Did not match
13             # 1: Matched
14             # @since v4.0.0
15 347     347 1 1307 my $class = shift;
16 347   100     1141 my $argv1 = shift // return 0;
17              
18 346         685 state $index = [
19             "connection timed out",
20             "could not find a gateway for",
21             "delivery attempts will continue to be",
22             "failed to deliver to domain ",
23             "have been failing for a long time",
24             "has been delayed",
25             "it has not been collected after",
26             "message could not be delivered for more than",
27             "message expired, ",
28             "message has been in the queue too long",
29             "message timed out",
30             "server did not respond",
31             "unable to deliver message after multiple retries",
32             ];
33 346         590 state $pairs = [
34             ["could not be delivered for", " days"],
35             ["delivery ", "expired"],
36             ["not", "reach", "period"],
37             ];
38              
39 346 100       786 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  4498         8197  
40 261 100       716 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  783         1892  
41 253         700 return 0;
42             }
43              
44             sub true {
45             # Delivery expired due to connection failure or network error
46             # @param [Sisimai::Fact] argvs Object to be detected the reason
47             # @return [Integer] 1: is expired
48             # 0: is not expired
49             # @see http://www.ietf.org/rfc/rfc2822.txt
50 2     2 0 7 return 0;
51             }
52              
53             1;
54             __END__