| 1 | # | ||||||||||||
| 2 | # Copyright (c) 2014-2021 Christian Jaeger, copying@christianjaeger.ch | ||||||||||||
| 3 | # | ||||||||||||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||||||||||||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||||||||||||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||||||||||||
| 7 | # bundled with this file. | ||||||||||||
| 8 | # | ||||||||||||
| 9 | |||||||||||||
| 10 | =head1 NAME | ||||||||||||
| 11 | |||||||||||||
| 12 | FP::url_ | ||||||||||||
| 13 | |||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||
| 15 | |||||||||||||
| 16 | 1 | ▶ | use FP::url_; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | my $u = url_ path => "index.html", fragment => "foo#bar"; | ||||||||||||
| 18 | # $u is an URI object | ||||||||||||
| 19 | is "$u", 'index.html#foo%23bar'; | ||||||||||||
| 20 | |||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||
| 22 | |||||||||||||
| 23 | |||||||||||||
| 24 | =head1 NOTE | ||||||||||||
| 25 | |||||||||||||
| 26 | This is alpha software! Read the status section in the package README | ||||||||||||
| 27 | or on the L<website|http://functional-perl.org/>. | ||||||||||||
| 28 | |||||||||||||
| 29 | =cut | ||||||||||||
| 30 | |||||||||||||
| 31 | package FP::url_; | ||||||||||||
| 32 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 33 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 34 | 2 | ▶ | use warnings FATAL => 'uninitialized'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 35 | 2 | ▶ | use Exporter "import"; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 36 | |||||||||||||
| 37 | 2 | our @EXPORT = qw(url_); | |||||||||||
| 38 | 2 | our @EXPORT_OK = qw(); | |||||||||||
| 39 | 2 | our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]); | |||||||||||
| 40 | |||||||||||||
| 41 | 2 | ▶ | use URI; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 42 | |||||||||||||
| 43 | 2 | our @keys = qw(scheme path fragment); | |||||||||||
| 44 | |||||||||||||
| 45 | 2 | our %keys = map { $_ => $_ } @keys; | |||||||||||
| 46 | |||||||||||||
| 47 | 1 | ▶ | sub url_ { | ||||||||||
|
Subroutine
url_: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||
| 48 | 1 | my $u = URI->new; | |||||||||||
| 49 | 1 | ▶ | while (@_) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 50 | 2 | my $k = shift; | |||||||||||
| 51 | 2 | ▶ | @_ or die "url_: uneven number of arguments"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | 2 | my $v = shift; | |||||||||||
| 53 | 2 | ▶ | my $m = $keys{$k} // die "url_: unknown key '$k'"; | ||||||||||
|
Condition50%1/2
$FP::url_::keys{$k} // die("url_: unknown key '${k}'")
MC/DC0%0/1
$FP::url_::keys{$k} // die("url_: unknown key '${k}'")
$FP::url_::keys{$k}
Truth table50%1/2
A
A= $FP::url_::keys{$k}
| |||||||||||||
| 54 | 2 | $u->$m($v); | |||||||||||
| 55 | } | ||||||||||||
| 56 | $u | ||||||||||||
| 57 | 1 | } | |||||||||||
| 58 | |||||||||||||
| 59 | 2 | 1 | |||||||||||