LDAP/Command/Import.pm

filter: Statementstmt 45.8% 11 / 24 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 37.8% 14 / 37 CC 5 SCAR 23.6
CC
5
Cov
37%
process
20.0
run
6.0
BEGIN
1.0
CRAP 10.6
« LDAP/Command/Add/User.pm ↑ Summary LDAP/Command/Add/Ou.pm »
1 package App::LDAP::Command::Import;
2  
3 1 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 with qw( App::LDAP::Role::Command
8 App::LDAP::Role::Bindable );
9  
10 1 ▶use Net::LDAP::LDIF;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub run {
Subroutine run: not called CC=2 SCAR=17.9
Pod undocumented
13 0 my ($self) = shift;
14  
15 0 shift @ARGV;
16 0 process($_) for @ARGV;
17 }
18  
19 0 ▶sub process {
Subroutine process: not called CC=4 SCAR=30.0
Pod undocumented
20 0 my ($file) = @_;
21  
22 0 ▶ if (-f $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $file) { } 0 0 0
23  
24 0 say "import $file...";
25  
26 0 my $ldif = Net::LDAP::LDIF->new($file, "r", onerror => 'die');
27  
28 0 ▶ while (!$ldif->eof) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ldif->eof) 0 0 0
29 0 my $entry = $ldif->read_entry;
30 0 my $msg = ldap()->add($entry);
31 0 ▶ warn $msg->error() if $msg->code;
Branch: 1 branch
BranchTrueFalseTotal
if $msg->code 0 0 0
32 }
33  
34 } else {
35 0 say "$_ don\'t exist. skip.";
36 0 return;
37 }
38  
39 }
40  
41 1 1;
42  
43 =pod
44  
45 =head1 NAME
46  
47 App::LDAP::Command::Import
48  
49 =head1 SYNOPSIS
50  
51 $ ldap import people.ldif
52  
53 =cut
« LDAP/Command/Add/User.pm ↑ Summary LDAP/Command/Add/Ou.pm »