| 1 | package Pod::Readme::Types; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use v5.10.1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | our $VERSION = 'v1.2.3'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Exporter qw/ import /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use IO qw/ Handle /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use Scalar::Util qw/ blessed /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use Type::Tiny 1.000000; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use Types::Standard qw/ FileHandle Str /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # RECOMMEND PREREQ: Type::Tiny::XS | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | our @EXPORT_OK = | |||||||||||||||||||||||||||||||||||||||||
| 22 | qw/ Dir File Indentation IO ReadIO WriteIO HeadingLevel TargetName DistZilla /; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | Pod::Readme::Types - Types used by Pod::Readme | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | use Pod::Readme::Types qw/ Indentation /; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | has verbatim_indent => ( | ||||||||||||||||||||||||||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => Indentation, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | default => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | This module provides types for use with the modules in L<Pod::Readme>. | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | It is intended for internal use, although some of these may be useful | ||||||||||||||||||||||||||||||||||||||||||
| 43 | for writing plugins (see L<Pod::Readme::Plugin>). | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 EXPORTS | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | None by default. All functions must be explicitly exported. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | =head2 C<Indentation> | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | The indentation level used for verbatim text. Must be an integer | ||||||||||||||||||||||||||||||||||||||||||
| 52 | greater than or equal to 2. | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | sub Indentation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Indentation: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | state $type = Type::Tiny->new( | ||||||||||||||||||||||||||||||||||||||||||
| 58 | name => 'Indentation', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 11 | ▶ | constraint => sub { $_ =~ /^\d+$/ && $_ >= 2 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | message => sub { 'must be an integer >= 2' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | return $type; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | =head2 C<HeadingLevel> | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | A heading level, used for plugin headings. | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | Must be either 1, 2 or 3. (Note that C<=head4> is not allowed, since | ||||||||||||||||||||||||||||||||||||||||||
| 70 | some plugins use subheadings.) | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | sub HeadingLevel { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HeadingLevel: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | state $type = Type::Tiny->new( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | name => 'HeadingLevel', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | constraint => sub { $_ =~ /^[123]$/ }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | message => sub { 'must be an integer between 1 and 3' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | return $type; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =head2 C<TargetName> | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | A name of a target, e.g. "readme". | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | ▶ | sub TargetName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TargetName: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | state $type = Type::Tiny->new( | ||||||||||||||||||||||||||||||||||||||||||
| 91 | name => 'TargetName', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 11 | ▶ | constraint => sub { $_ =~ /^\w+$/ }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | message => sub { 'must be an alphanumeric string' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 5 | return $type; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | =head2 C<Dir> | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | A directory. Can be a string or L<Path::Tiny> object. | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 16 | ▶ | sub Dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Dir: called CC=1 SCAR=0.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | state $type = Type::Tiny->new( | ||||||||||||||||||||||||||||||||||||||||||
| 106 | name => 'Dir', | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 22 | ▶ | constraint => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 22 | ▶ | blessed($_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($_) and $_->isa("Path::Tiny")
MC/DC50%1/2
builtin::blessed($_) and $_->isa("Path::Tiny")
builtin::blessed($_)
$_->isa("Path::Tiny")
Truth table66%2/3
A and B
A= builtin::blessed($_)B= $_->isa("Path::Tiny")
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | && $_->isa('Path::Tiny') | ||||||||||||||||||||||||||||||||||||||||||
| 110 | && -d $_; | ||||||||||||||||||||||||||||||||||||||||||
| 111 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | message => sub { "$_ must be be a directory" }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 16 | ); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 16 | ▶ | return $type->plus_coercions( Str, sub { path($_) }, ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | =head2 C<File> | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | A file. Can be a string or L<Path::Tiny> object. | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 36 | ▶ | sub File { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
File: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | state $type = Type::Tiny->new( | ||||||||||||||||||||||||||||||||||||||||||
| 125 | name => 'File', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 38 | ▶ | constraint => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 38 | ▶ | blessed($_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | && $_->isa('Path::Tiny'); | ||||||||||||||||||||||||||||||||||||||||||
| 129 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | message => sub { "$_ must be be a file" }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 36 | ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 36 | ▶ | return $type->plus_coercions( Str, sub { path($_) }, ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | =head2 C<IO> | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | An L<IO::Handle> or L<IO::String> object. | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 10 | ▶ | sub IO { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IO: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | state $type = Type::Tiny->new( | ||||||||||||||||||||||||||||||||||||||||||
| 143 | name => 'IO', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 34 | ▶ | constraint => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 34 | ▶ | blessed($_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
builtin::blessed($_) && ($_->isa('IO::Handle') || $_->isa('IO::String'))
$_->isa("IO::Handle") or $_->isa("IO::String")
MC/DC33%1/3
builtin::blessed($_) && ($_->isa('IO::Handle') || $_->isa('IO::String'))
builtin::blessed($_)
$_->isa("IO::Handle")
$_->isa("IO::String")
Truth table75%3/4
A && B or C
A= builtin::blessed($_)B= $_->isa("IO::Handle")C= $_->isa("IO::String")
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | && ( $_->isa('IO::Handle') || $_->isa('IO::String') ); | ||||||||||||||||||||||||||||||||||||||||||
| 147 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | message => sub { 'must be be an IO::Handle or IO::String' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 10 | ); | |||||||||||||||||||||||||||||||||||||||||
| 150 | 10 | return $type; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | =head2 C<ReadIO> | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | =head2 C<WriteIO> | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | L</IO> types, which coerce filehandles to read/write L<IO:Handles>, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | respectively. | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 9 | ▶ | sub ReadIO { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReadIO: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | state $type = IO->plus_coercions( # | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | ▶ | FileHandle, sub { IO::Handle->new_from_fd( $_, 'r' ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 9 | return $type; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 22 | ▶ | sub WriteIO { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
WriteIO: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | state $type = IO->plus_coercions( # | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 6 | ▶ | FileHandle, sub { IO::Handle->new_from_fd( $_, 'w' ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 22 | ); | |||||||||||||||||||||||||||||||||||||||||
| 173 | 22 | return $type; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||