| 1 | 2 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | package BenchmarkAnything::Reporter; | ||||||||||||||||||||||||||||
| 5 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | $BenchmarkAnything::Reporter::AUTHORITY = 'cpan:SCHWIGON'; | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | # ABSTRACT: Handle result reporting to a BenchmarkAnything HTTP/REST API | ||||||||||||||||||||||||||||
| 9 | 2 | $BenchmarkAnything::Reporter::VERSION = '0.003'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub new | ||||||||||||||||||||||||||||
| 12 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 14 | 2 | my $self = bless { @_ }, $class; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | require BenchmarkAnything::Config; | |||||||||||||||||||||||||||
| 17 | 2 | ▶ | $self->{config} = BenchmarkAnything::Config->new unless $self->{config}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | return $self; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | sub report | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
report: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # --- validate --- | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if (not $data) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||
| 30 | 0 | die "benchmarkanything: no input data provided.\n"; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my $ua = $self->_get_user_agent; | |||||||||||||||||||||||||||
| 34 | 0 | my $url = $self->_get_base_url."/api/v1/add"; | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | print "Report data...\n" if $self->{verbose} or $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"verbose"} or $self->{"debug"}
MC/DC0%0/2
$self->{"verbose"} or $self->{"debug"}
$self->{"verbose"}
$self->{"debug"}
Truth table0%0/3
A or B
A= $self->{"verbose"}B= $self->{"debug"}
| |||||||||||||||||||||||||||||
| 36 | 0 | my $res = $ua->post($url => json => $data)->res; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | print "Done.\n" if $self->{verbose} or $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"verbose"} or $self->{"debug"}
MC/DC0%0/2
$self->{"verbose"} or $self->{"debug"}
$self->{"verbose"}
$self->{"debug"}
Truth table0%0/3
A or B
A= $self->{"verbose"}B= $self->{"debug"}
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | die "benchmarkanything: ".$res->error->{message}." ($url)\n" if $res->error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | return $self; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub _get_user_agent | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_get_user_agent: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 46 | 0 | require Mojo::UserAgent; | |||||||||||||||||||||||||||
| 47 | 0 | return Mojo::UserAgent->new; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub _get_base_url | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_get_base_url: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 52 | 0 | $_[0]->{config}{benchmarkanything}{backends}{http}{base_url}; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | 1; | |||||||||||||||||||||||||||
| 56 | 2 | 3 | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||