PONAPI/CLI/RunServer.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 54 CC 1 SCAR 6.9
CC
1
Cov
0%
run
2.0
_create_dir
2.0
BEGIN
2.0
CRAP 2.0
1 # ABSTRACT: ponapi CLI server runner
2 package PONAPI::CLI::RunServer;
3  
4 use strict;
5 use warnings;
6  
7 use Plack::Runner;
8 use Plack::Middleware::MethodOverride;
9 use PONAPI::Server;
10  
11 use File::Temp qw( tempdir );
12 use Path::Class qw( file );
13  
14 use POSIX ();
15  
16 $SIG{INT} = sub {
17 print "demo server shutting down...\n";
18 $SIG{INT} = sub { POSIX::_exit(0) };
19 exit 0;
20 };
21  
22 sub run {
23 my $port = shift;
24  
25 my $dir = _create_dir();
26  
27 my $app = Plack::Middleware::MethodOverride->wrap(
28 PONAPI::Server->new(
29 'repository.class' => 'Test::PONAPI::Repository::MockDB',
30 'ponapi.config_dir' => $dir
31 )->to_app()
32 );
33  
34 my $runner = Plack::Runner->new;
35 $runner->parse_options( '-port', $port || 5000 );
36 $runner->run($app);
37 }
38  
39 sub _create_dir {
40 my $dir = tempdir( CLEANUP => 1 );
41  
42 my $conf = file( $dir . '/server.yml' );
43 $conf->spew(<<"DEFAULT_CONF");
44 server:
45 spec_version: "1.0"
46 sort_allowed: "true"
47 send_version_header: "true"
48 send_document_self_link: "true"
49 links_type: "relative"
50 respond_to_updates_with_200: "false"
51  
52 repository:
53 class: "Test::PONAPI::Repository::MockDB"
54 args: []
55 DEFAULT_CONF
56  
57 return $dir;
58 }
59  
60 1;
61  
62 __END__
63  
64 =pod
65  
66 =encoding UTF-8
67  
68 =head1 NAME
69  
70 PONAPI::CLI::RunServer - ponapi CLI server runner
71  
72 =head1 VERSION
73  
74 version 0.003002
75  
76 =head1 AUTHORS
77  
78 =over 4
79  
80 =item *
81  
82 Mickey Nasriachi <mickey@cpan.org>
83  
84 =item *
85  
86 Stevan Little <stevan@cpan.org>
87  
88 =item *
89  
90 Brian Fraser <hugmeir@cpan.org>
91  
92 =back
93  
94 =head1 COPYRIGHT AND LICENSE
95  
96 This software is copyright (c) 2017 by Mickey Nasriachi, Stevan Little, Brian Fraser.
97  
98 This is free software; you can redistribute it and/or modify it under
99 the same terms as the Perl 5 programming language system itself.
100  
101 =cut