blib/lib/App/DuckPAN/Cmd/Publisher.pm

filter: Statementstmt 52.9% 18 / 34 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 1 totaltotal 43.1% 22 / 51 CC 7 SCAR 35.0
CC
7
Cov
41%
run
56.0
__ANON__
2.0
BEGIN
1.0
CRAP 33.2
« blib/lib/App/DuckPAN/Cmd/Roadrunner.pm ↑ Summary blib/lib/App/DuckPAN/Restart.pm »
1 package App::DuckPAN::Cmd::Publisher;
2 1 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Starting up the publisher test webserver
4 1 $App::DuckPAN::Cmd::Publisher::VERSION = '1021';
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 with qw( App::DuckPAN::Cmd );
7  
8 1 ▶use MooX::Options protect_argv => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Plack::Handler::Starman;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 for (qw( duckduckgo dontbubbleus donttrackus duckduckhack )) {
13 4 option $_ => (
14 is => 'ro',
15 format => 's',
16 predicate => 1,
17 );
18 }
19  
20 0 ▶sub run {
Subroutine run: not called CC=7 SCAR=40.3
Pod undocumented
21 0 my ( $self, @args ) = @_;
22  
23 0 $self->app->emit_info("Checking for Publisher...");
24  
25 0 my $publisher_pm = path('lib','DDG','Publisher.pm');
26 0 ▶ $self->app->emit_and_exit(1, "You must be in the root of the duckduckgo-publisher repository") unless $publisher_pm->exists;
Branch: 1 branch
BranchTrueFalseTotal
unless $publisher_pm->exists 0 0 0
27  
28 0 $self->app->emit_info("Starting up publisher webserver...", "You can stop the webserver with Ctrl-C");
29  
30 0 ▶ my %sites = (
Branch: 4 branches
BranchTrueFalseTotal
$self->has_duckduckgo ? : 0 0 0
$self->has_dontbubbleus ? : 0 0 0
$self->has_donttrackus ? : 0 0 0
$self->has_duckduckhack ? : 0 0 0
31 duckduckgo => {
32 port => 5000,
33 url => $self->has_duckduckgo ? $self->duckduckgo : "http://duckduckgo.com/",
34 },
35 dontbubbleus => {
36 port => 5001,
37 url => $self->has_dontbubbleus ? $self->dontbubbleus : "http://dontbubble.us/",
38 },
39 donttrackus => {
40 port => 5002,
41 url => $self->has_donttrackus ? $self->donttrackus : "http://donttrack.us/",
42 },
43 duckduckhack => {
44 port => 5005,
45 url => $self->has_duckduckhack ? $self->duckduckhack : "http://duckduckhack.com/",
46 },
47 );
48  
49 0 for (sort { $sites{$a}->{port} <=> $sites{$b}->{port} } keys %sites) {
50 0 $self->app->emit_info("Serving on port ".$sites{$_}->{port}.": ".$sites{$_}->{url});
51 }
52  
53 0 require App::DuckPAN::WebPublisher;
54 0 my $web = App::DuckPAN::WebPublisher->new(
55 app => $self->app,
56 sites => \%sites,
57 );
58 0 my @ports = map { $sites{$_}->{port} } keys %sites;
59 0 ▶ exit Plack::Handler::Starman->new(listen => [ map { ":$_" } @ports ])->run(sub { $web->run_psgi(@_) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 }
61  
62 1 1;
63  
64 __END__
« blib/lib/App/DuckPAN/Cmd/Roadrunner.pm ↑ Summary blib/lib/App/DuckPAN/Restart.pm »