blib/lib/App/DAVThis.pm

filter: Statementstmt 44.4% 20 / 45 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 39.4% 28 / 71 CC 9 SCAR 30.5
CC
9
Cov
33%
new
42.0
run
20.0
BEGIN
1.0
CRAP 21.1
↑ Summary
1 package App::DAVThis;
2  
3 1 our $DATE = '2017-11-10'; # DATE
4 1 our $VERSION = '0.001'; # VERSION
5  
6 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
15 0 my $class = shift;
16 0 my $self = bless {port => 4242, root => '.'}, $class;
17  
18 0 ▶ GetOptions($self, "help", "man", "port=i",
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions($self, "help", "man", "port=i") or pod2usage(2) 0 0 0
19 ) || pod2usage(2);
20 0 ▶ pod2usage(1) if $self->{help};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"help"} 0 0 0
21 0 ▶ pod2usage(-verbose => 2) if $self->{man};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"man"} 0 0 0
22  
23 0 ▶ if (@ARGV > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@ARGV > 1) { } 0 0 0
elsif (@ARGV) { } 0 0 0
24 0 pod2usage("$0: Too many roots, only single root supported");
25 } elsif (@ARGV) {
26 0 $self->{root} = shift @ARGV;
27 } else {
28 0 $self->{root} = getcwd();
29 }
30  
31 0 return $self;
32 }
33  
34 0 ▶sub run {
Subroutine run: not called CC=4 SCAR=30.0
Pod documented
35 0 require Filesys::Virtual::Plain;
36 0 require HTTP::Daemon;
37 0 require Net::DAV::Server;
38  
39 0 my ($self) = @_;
40  
41 0 my $filesys = Filesys::Virtual::Plain->new({root_path => $self->{root}});
42 0 my $webdav = Net::DAV::Server->new();
43 0 $webdav->filesys($filesys);
44  
45 my $d = HTTP::Daemon->new(
46 LocalAddr => 'localhost',
47 LocalPort => $self->{port},
48 0 ▶ ReuseAddr => 1)
Branch: 1 branch
BranchTrueFalseTotal
my $d = "HTTP::Daemon"->new("LocalAddr", "localhost", "LocalPort", $self->{"port"}, "ReuseAddr", 1) or die qq[Can't start HTTP::Daemon on port $self->{"port"}: $!] 0 0 0
49 or die "Can't start HTTP::Daemon on port $self->{port}: $!";
50  
51 0 print "Please contact me at: ", $d->url, "\n";
52 0 ▶ while (my $c = $d->accept) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = $d->accept) 0 0 0
53 0 ▶ while (my $request = $c->get_request) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $request = $c->get_request) 0 0 0
54 0 my $response = $webdav->run($request);
55 0 $c->send_response ($response);
56 }
57 0 $c->close;
58 0 undef($c);
59 }
60 }
61  
62 1 1;
63 # ABSTRACT: Export the current directory over WebDAV
64  
65 __END__
↑ Summary