blib/lib/Net/IMAP/Simple/Gmail.pm

filter: Statementstmt 27.4% 14 / 51 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 20.0% 4 / 20 Podpod 83.3% 5 / 6 totaltotal 25.2% 23 / 91 CC 10 SCAR 17.4
CC
10
Cov
22%
__ANON__
12.0
__ANON__
12.0
_label_manip
12.0
CRAP 5.7
↑ Summary
1 package Net::IMAP::Simple::Gmail;
2 1 ▶use Text::ParseWords;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use vars qw[$VERSION];
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $VERSION = (qw$Revision: 0.21 $)[1];
7  
8 1 ▶use base qw[Net::IMAP::Simple::SSL];
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 0 ▶sub run_search {
Subroutine run_search: not called CC=1 SCAR=6.9
Pod documented
12 0 my ( $self, $search_terms ) = @_;
13 0 my @hits;
14  
15 return $self->_process_cmd(
16 cmd => [ SEARCH => qq[X-GM-RAW "$search_terms"] ],
17 0 ▶ final => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 0 return \@hits;
19 },
20 0 ▶ process => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
21 0 ▶ if ( $_[0] =~ /^\* SEARCH (.*)\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /^\* SEARCH (.*)\s*$/) 0 0 0
22 0 @hits = split / /, $1;
23 }
24 },
25 0 );
26 }
27  
28  
29  
30 0 ▶sub get_msgids {
Subroutine get_msgids: not called CC=1 SCAR=6.9
Pod undocumented
31 0 my ( $self, $number ) = @_;
32 0 return $self->_get_gminfo( $number, 'X-GM-MSGID' );
33 }
34  
35 0 ▶sub get_threadids {
Subroutine get_threadids: not called CC=1 SCAR=6.9
Pod documented
36 0 my ( $self, $number ) = @_;
37 0 return $self->_get_gminfo( $number, 'X-GM-THRID' );
38 }
39  
40  
41 0 ▶sub _get_gminfo {
Subroutine _get_gminfo: not called CC=1 SCAR=6.9
42 0 my ( $self, $number, $gm_identifier ) = @_;
43 0 my %threadid;
44  
45 return $self->_process_cmd(
46 cmd => [ FETCH => qq[$number ($gm_identifier)] ],
47 0 ▶ final => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
48 # if range, return hashref, else scalar
49 0 ▶ return ($number =~ /:/) ? \%threadid : $threadid{$number};
Branch: 1 branch
BranchTrueFalseTotal
$number =~ /:/ ? : 0 0 0
50 },
51 0 ▶ process => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
52 0 foreach (@_) {
53 0 ▶ if ( $_ =~ /^\* (\d+) FETCH \($gm_identifier (\d+)\)\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^\* (\d+) FETCH \($gm_identifier (\d+)\)\s*$/) 0 0 0
54 0 my ($num, $label) = ($1, $2);
55 0 $threadid{$1} = $2;
56 }
57 }
58 },
59 0 );
60 }
61  
62 0 ▶sub get_labels {
Subroutine get_labels: not called CC=1 SCAR=6.9
Pod documented
63 0 my ( $self, $number ) = @_;
64 0 my %labels;
65  
66 return $self->_process_cmd(
67 cmd => [ FETCH => qq[$number (X-GM-LABELS)] ],
68 0 ▶ final => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
69 # if range, return hashref else arrayrg
70 0 ▶ return ($number =~ /:/) ? \%labels : $labels{$number};
Branch: 1 branch
BranchTrueFalseTotal
$number =~ /:/ ? : 0 0 0
71 },
72 0 ▶ process => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
73 0 foreach (@_) {
74 0 ▶ if ( $_ =~ /^\* (\d+) FETCH \(X-GM-LABELS \((.+)\)\)\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^\* (\d+) FETCH \(X-GM-LABELS \((.+)\)\)\s*$/) 0 0 0
75 0 my ($num, $label) = ($1, $2);
76 0 my @labels = Text::ParseWords::parse_line(' ', 0, $label);
77 0 $labels{$num} = \@labels;
78 }
79 }
80 },
81 0 );
82 }
83  
84  
85 0 ▶sub add_labels {
Subroutine add_labels: not called CC=1 SCAR=6.9
Pod documented
86 0 my ( $self, $number, @labels ) = @_;
87 0 return $self->_label_manip( $number, '+X-GM-LABELS', @labels );
88 }
89  
90 0 ▶sub remove_labels {
Subroutine remove_labels: not called CC=1 SCAR=6.9
Pod documented
91 0 my ( $self, $number, @labels ) = @_;
92 0 return $self->_label_manip( $number, '-X-GM-LABELS', @labels );
93 }
94  
95  
96 0 ▶sub _label_manip {
Subroutine _label_manip: not called CC=3 SCAR=24.8
97 0 my ( $self, $number, $op, @labels ) = @_;
98 0 ▶ return unless @labels;
Branch: 1 branch
BranchTrueFalseTotal
unless @labels 0 0 0
99  
100 # quote labels with spaces
101 0 ▶ @labels = map { / / ? '"' . $_ . '"' : $_ } @labels;
Branch: 1 branch
BranchTrueFalseTotal
/ / ? : 0 0 0
102 0 my $label_line = join ' ', @labels;
103  
104 return $self->_process_cmd(
105 cmd => [ STORE => qq[$number $op ($label_line)] ],
106 0 ▶ final => sub { },
Subroutine __ANON__: not called CC=1 SCAR=0.0
107 0 ▶ process => sub { },
Subroutine __ANON__: not called CC=1 SCAR=0.0
108 0 );
109  
110 }
111  
112 1 1;
113  
114 __END__
↑ Summary