| 1 | package Test::Smoke::Poster; | ||||||||||||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 5 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 5 | our $VERSION = '0.001'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 5 | ▶ | use Cwd qw/:DEFAULT abs_path/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 5 | ▶ | use File::Spec::Functions qw/:DEFAULT rel2abs/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 5 | ▶ | use Test::Smoke::Poster::Curl; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 5 | ▶ | use Test::Smoke::Poster::HTTP_Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 5 | ▶ | use Test::Smoke::Poster::LWP_UserAgent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | Test::Smoke::Poster - Factory for poster objects. | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | use Test::Smoke::Poster; | ||||||||||||||||||||
| 21 | my $poster = Test::Smoke::Poster->new( | ||||||||||||||||||||
| 22 | 'LWP::UserAgent', | ||||||||||||||||||||
| 23 | ddir => '.', | ||||||||||||||||||||
| 24 | smokedb_url => 'http://perl5.test-smoke.org/report', | ||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||
| 26 | $poster->post(); | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | Returns a instance of the object-class requested. | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 5 | my %CONFIG = ( | |||||||||||||||||||
| 35 | df_poster => 'HTTP::Tiny', | ||||||||||||||||||||
| 36 | df_ddir => undef, | ||||||||||||||||||||
| 37 | df_jsnfile => 'mktest.jsn', | ||||||||||||||||||||
| 38 | df_qfile => undef, | ||||||||||||||||||||
| 39 | df_v => 0, | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | df_smokedb_url => 'https://perl5.test-smoke.org/api/report', | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | df_ua_timeout => undef, | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | df_curlargs => [ ], | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 'LWP::UserAgent' => { | ||||||||||||||||||||
| 48 | allowed => [qw/ua_timeout/], | ||||||||||||||||||||
| 49 | required => [], | ||||||||||||||||||||
| 50 | class => 'Test::Smoke::Poster::LWP_UserAgent', | ||||||||||||||||||||
| 51 | }, | ||||||||||||||||||||
| 52 | 'HTTP::Tiny' => { | ||||||||||||||||||||
| 53 | allowed => [qw/ua_timeout/], | ||||||||||||||||||||
| 54 | required => [], | ||||||||||||||||||||
| 55 | class => 'Test::Smoke::Poster::HTTP_Tiny', | ||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||
| 57 | 'curl' => { | ||||||||||||||||||||
| 58 | allowed => [qw/curlbin curlargs ua_timeout/], | ||||||||||||||||||||
| 59 | required => [qw/curlbin/], | ||||||||||||||||||||
| 60 | class => 'Test::Smoke::Poster::Curl', | ||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | valid_type => { | ||||||||||||||||||||
| 64 | 'LWP::UserAgent' => 1, | ||||||||||||||||||||
| 65 | 'HTTP::Tiny' => 1, | ||||||||||||||||||||
| 66 | }, | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | general_options => [qw/ddir jsnfile qfile v smokedb_url poster/], | ||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =head2 Test::Smoke::Poster->new($poster_type, %arguments) | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | Check arguments and return an instance of $poster_type. | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 12 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.5
Pod
documented
| |||||||||||||||||||||
| 78 | 12 | my $factory = shift; | |||||||||||||||||||
| 79 | 12 | ▶ | my $poster = shift || $CONFIG{df_poster}; | ||||||||||||||||||
|
Condition33%1/3
shift() || $CONFIG{'df_poster'}
MC/DC0%0/2
shift() || $CONFIG{'df_poster'}
shift()
$CONFIG{'df_poster'}
Truth table33%1/3
A || B
A= shift()B= $CONFIG{'df_poster'}
| |||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 0 | ▶ | my %args = ref $_[0] eq 'HASH' ? %{$_[0]} : @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | my %fields = map { | ||||||||||||||||||||
| 84 | 88 | ▶ | my $value = exists $args{$_} ? $args{ $_ } : $CONFIG{ "df_$_" }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | 88 | ( $_ => $value ) | |||||||||||||||||||
| 86 | 12 | } ( @{ $CONFIG{general_options} }, @{ $CONFIG{$poster}{allowed} } ); | |||||||||||||||||||
| 87 | 12 | ▶ | if ( ! file_name_is_absolute( $fields{ddir} ) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | 4 | $fields{ddir} = catdir( abs_path(), $fields{ddir} ); | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | 12 | $fields{ddir} = rel2abs( $fields{ddir}, abs_path() ); | |||||||||||||||||||
| 91 | 12 | $fields{poster} = $poster; | |||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 12 | my @missing; | |||||||||||||||||||
| 94 | 12 | for my $required (@{ $CONFIG{$poster}{required} }) { | |||||||||||||||||||
| 95 | push( | ||||||||||||||||||||
| 96 | @missing, | ||||||||||||||||||||
| 97 | "option '$required' missing for '$CONFIG{$poster}{class}'" | ||||||||||||||||||||
| 98 | 2 | ▶ | ) if !defined $fields{$required}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | 12 | ▶ | if (@missing) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 101 | 0 | croak("Missing option:\n\t", join("\n\t", @missing)); | |||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 12 | my $class = $CONFIG{$poster}{class}; | |||||||||||||||||||
| 105 | 12 | return $class->new(%fields); | |||||||||||||||||||
| 106 | } | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 5 | 1; | |||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | =head1 COPYRIGHT | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | (c) 2002-2013, Abe Timmerman <abeltje@cpan.org> All rights reserved. | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | With contributions from Jarkko Hietaniemi, Merijn Brand, Campo | ||||||||||||||||||||
| 115 | Weijerman, Alan Burlison, Allen Smith, Alain Barbet, Dominic Dunlop, | ||||||||||||||||||||
| 116 | Rich Rauenzahn, David Cantrell. | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 119 | it under the same terms as Perl itself. | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | See: | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | =over 4 | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | =item * L<http://www.perl.com/perl/misc/Artistic.html> | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | =item * L<http://www.gnu.org/copyleft/gpl.html> | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | =back | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||
| 132 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||
| 133 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | =cut | ||||||||||||||||||||