| 1 | package Test::Shodo::JSONRPC; | ||||||||||
| 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 | 2 | ▶ | use Shodo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use parent qw/Exporter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use JSON qw/from_json/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Test::More; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | our @EXPORT = qw/ | |||||||||
| 11 | shodo_document_root | ||||||||||
| 12 | shodo_test | ||||||||||
| 13 | shodo_params | ||||||||||
| 14 | shodo_req_ok | ||||||||||
| 15 | shodo_res_ok | ||||||||||
| 16 | shodo_doc | ||||||||||
| 17 | shodo_write | ||||||||||
| 18 | /; | ||||||||||
| 19 | |||||||||||
| 20 | 2 | my $shodo = Shodo->new(); | |||||||||
| 21 | 2 | my $suzuri; | |||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | sub shodo_document_root { | ||||||||
|
Subroutine
shodo_document_root: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 24 | 1 | my $dir = shift; | |||||||||
| 25 | 1 | $shodo->document_root($dir); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 2 | ▶ | sub shodo_test { | ||||||||
|
Subroutine
shodo_test: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 29 | 2 | my ($description, $coderef) = @_; | |||||||||
| 30 | 2 | ▶ | $suzuri = $shodo->new_suzuri($description) unless $suzuri; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 2 | my $result = Test::More::subtest($description => $coderef); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 2 | ▶ | sub shodo_params { | ||||||||
|
Subroutine
shodo_params: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 35 | 2 | my %args = @_; | |||||||||
| 36 | 2 | $suzuri->params(%args); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 2 | ▶ | sub shodo_req_ok { | ||||||||
|
Subroutine
shodo_req_ok: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 40 | 2 | my ($req, $note) = @_; | |||||||||
| 41 | 2 | $suzuri->request($req); | |||||||||
| 42 | 2 | ▶ | my $data = try { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 2 | from_json($req->content); | |||||||||
| 44 | 0 | ▶ | }catch{ | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 45 | 0 | warn "$_\n"; | |||||||||
| 46 | 2 | }; | |||||||||
| 47 | 2 | ▶ | return unless $data; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 2 | ▶ | return unless $suzuri->validate($data->{params}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | Test::More::ok($req, $note); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 1 | ▶ | sub shodo_res_ok { | ||||||||
|
Subroutine
shodo_res_ok: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 53 | 1 | my ($res, $code, $note) = @_; | |||||||||
| 54 | 1 | $suzuri->response($res); | |||||||||
| 55 | 1 | my $result = Test::More::is $res->code, 200, $note; | |||||||||
| 56 | 1 | $shodo->stock($suzuri->doc()); | |||||||||
| 57 | 1 | $suzuri = undef; | |||||||||
| 58 | 1 | return $result; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 1 | ▶ | sub shodo_doc { | ||||||||
|
Subroutine
shodo_doc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 62 | 1 | return $shodo->stock(); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1 | ▶ | sub shodo_write { | ||||||||
|
Subroutine
shodo_write: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 66 | 1 | my $filename = shift; | |||||||||
| 67 | 1 | $shodo->write($filename); | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 2 | 1; | |||||||||
| 71 | |||||||||||
| 72 | __END__ | ||||||||||