blib/lib/App/Addex/AddressBook/LDAP.pm

filter: Statementstmt 58.9% 23 / 39 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 100% 2 / 2 totaltotal 58.9% 33 / 56 CC 3 SCAR 9.6
CC
3
Cov
53%
new
6.0
_entrify
6.0
entries
2.0
CRAP 2.6
↑ Summary
1 1 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package App::Addex::AddressBook::LDAP;
4 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 $App::Addex::AddressBook::LDAP::VERSION = '0.001';
6 }
7  
8 # ABSTRACT: LDAP address book for App::Addex
9  
10 1 ▶use parent 'App::Addex::AddressBook';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use App::Addex::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use App::Addex::Entry::EmailAddress;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Net::LDAP;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
19 0 my ($class, $arg) = @_;
20  
21 0 my $uri = URI->new($arg->{uri});
22  
23 0 my $self = bless {
24 uri => $uri,
25 } => $class;
26  
27 0 ▶ my $ldap = Net::LDAP->new(
Branch: 1 branch
BranchTrueFalseTotal
my $ldap = "Net::LDAP"->new("$uri", "raw", qr/(?i:^jpegPhoto|;binary)/u, "onerror", "die") or confess($@) 0 0 0
28 "$uri",
29 raw => qr/(?i:^jpegPhoto|;binary)/,
30 onerror => 'die'
31 ) or confess $@;
32 0 $ldap->bind();
33 0 $self->{ldap} = $ldap;
34  
35 0 return $self;
36 }
37  
38 0 ▶sub _entrify {
Subroutine _entrify: not called CC=2 SCAR=17.9
39 0 my ($self, $entry) = @_;
40  
41 0 my @emails = map { App::Addex::Entry::EmailAddress->new($_) }
42 $entry->get_value('mail');
43 0 ▶ return unless @emails;
Branch: 1 branch
BranchTrueFalseTotal
unless @emails 0 0 0
44  
45 0 return App::Addex::Entry->new(
46 {
47 name => $entry->get_value('cn'),
48 nick => $entry->get_value('uid'),
49 emails => \@emails,
50 }
51 );
52 }
53  
54 0 ▶sub entries {
Subroutine entries: not called CC=1 SCAR=6.9
Pod documented
55 0 my ($self) = @_;
56  
57 my $mesg = $self->{ldap}->search(
58 base => $self->{uri}->dn,
59 filter => $self->{uri}->filter,
60 scope => $self->{uri}->scope,
61 0 );
62  
63 0 return map { $self->_entrify($_) } $mesg->entries;
64 }
65  
66 1 1;
67  
68  
69 __END__
↑ Summary