| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Pod::Readme::Types; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 5 |  |  | 5 |  | 68 | use v5.10.1; | 
|  | 5 |  |  |  |  | 22 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 5 |  |  | 5 |  | 33 | use feature 'state'; | 
|  | 5 |  |  |  |  | 25 |  | 
|  | 5 |  |  |  |  | 569 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 5 |  |  | 5 |  | 44 | use strict; | 
|  | 5 |  |  |  |  | 92 |  | 
|  | 5 |  |  |  |  | 104 |  | 
| 8 | 5 |  |  | 5 |  | 60 | use warnings; | 
|  | 5 |  |  |  |  | 11 |  | 
|  | 5 |  |  |  |  | 219 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our $VERSION = 'v1.2.3'; | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 5 |  |  | 5 |  | 27 | use Exporter qw/ import /; | 
|  | 5 |  |  |  |  | 9 |  | 
|  | 5 |  |  |  |  | 146 |  | 
| 13 | 5 |  |  | 5 |  | 27 | use IO qw/ Handle /; | 
|  | 5 |  |  |  |  | 8 |  | 
|  | 5 |  |  |  |  | 37 |  | 
| 14 | 5 |  |  | 5 |  | 579 | use Path::Tiny; | 
|  | 5 |  |  |  |  | 9 |  | 
|  | 5 |  |  |  |  | 245 |  | 
| 15 | 5 |  |  | 5 |  | 41 | use Scalar::Util qw/ blessed /; | 
|  | 5 |  |  |  |  | 9 |  | 
|  | 5 |  |  |  |  | 267 |  | 
| 16 | 5 |  |  | 5 |  | 29 | use Type::Tiny 1.000000; | 
|  | 5 |  |  |  |  | 88 |  | 
|  | 5 |  |  |  |  | 117 |  | 
| 17 | 5 |  |  | 5 |  | 25 | use Types::Standard qw/ FileHandle Str /; | 
|  | 5 |  |  |  |  | 11 |  | 
|  | 5 |  |  |  |  | 29 |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # RECOMMEND PREREQ: Type::Tiny::XS | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | 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. | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | It is intended for internal use, although some of these may be useful | 
| 43 |  |  |  |  |  |  | for writing plugins (see L). | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =head1 EXPORTS | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | None by default. All functions must be explicitly exported. | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head2 C | 
| 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 |  |  |  |  |  |  | sub Indentation { | 
| 57 |  |  |  |  |  |  | state $type = Type::Tiny->new( | 
| 58 |  |  |  |  |  |  | name       => 'Indentation', | 
| 59 | 11 | 50 |  | 11 |  | 1063 | constraint => sub { $_ =~ /^\d+$/ && $_ >= 2 }, | 
| 60 | 0 |  |  | 0 |  | 0 | message => sub { 'must be an integer >= 2' }, | 
| 61 | 5 |  |  | 5 | 1 | 68 | ); | 
| 62 | 5 |  |  |  |  | 568 | return $type; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =head2 C | 
| 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 |  |  |  |  |  |  | sub HeadingLevel { | 
| 75 |  |  |  |  |  |  | state $type = Type::Tiny->new( | 
| 76 |  |  |  |  |  |  | name       => 'HeadingLevel', | 
| 77 | 4 |  |  | 4 |  | 308 | constraint => sub { $_ =~ /^[123]$/ }, | 
| 78 | 0 |  |  | 0 |  | 0 | message    => sub { 'must be an integer between 1 and 3' }, | 
| 79 | 3 |  |  | 3 | 1 | 45 | ); | 
| 80 | 3 |  |  |  |  | 388 | return $type; | 
| 81 |  |  |  |  |  |  | } | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =head2 C | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | A name of a target, e.g. "readme". | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | =cut | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | sub TargetName { | 
| 90 |  |  |  |  |  |  | state $type = Type::Tiny->new( | 
| 91 |  |  |  |  |  |  | name       => 'TargetName', | 
| 92 | 11 |  |  | 11 |  | 1061 | constraint => sub { $_ =~ /^\w+$/ }, | 
| 93 | 0 |  |  | 0 |  | 0 | message    => sub { 'must be an alphanumeric string' }, | 
| 94 | 5 |  |  | 5 | 1 | 53 | ); | 
| 95 | 5 |  |  |  |  | 459 | return $type; | 
| 96 |  |  |  |  |  |  | } | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head2 C | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | A directory. Can be a string or L object. | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =cut | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | sub Dir { | 
| 105 |  |  |  |  |  |  | state $type = Type::Tiny->new( | 
| 106 |  |  |  |  |  |  | name       => 'Dir', | 
| 107 |  |  |  |  |  |  | constraint => sub { | 
| 108 | 22 | 100 | 66 | 22 |  | 14986 | blessed($_) | 
| 109 |  |  |  |  |  |  | && $_->isa('Path::Tiny') | 
| 110 |  |  |  |  |  |  | && -d $_; | 
| 111 |  |  |  |  |  |  | }, | 
| 112 | 0 |  |  | 0 |  | 0 | message => sub { "$_ must be be a directory" }, | 
| 113 | 16 |  |  | 16 | 1 | 91 | ); | 
| 114 | 16 |  |  | 11 |  | 542 | return $type->plus_coercions( Str, sub { path($_) }, ); | 
|  | 11 |  |  |  |  | 144 |  | 
| 115 |  |  |  |  |  |  | } | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =head2 C | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | A file. Can be a string or L object. | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | =cut | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | sub File { | 
| 124 |  |  |  |  |  |  | state $type = Type::Tiny->new( | 
| 125 |  |  |  |  |  |  | name       => 'File', | 
| 126 |  |  |  |  |  |  | constraint => sub { | 
| 127 | 38 | 100 |  | 38 |  | 22203 | blessed($_) | 
| 128 |  |  |  |  |  |  | && $_->isa('Path::Tiny'); | 
| 129 |  |  |  |  |  |  | }, | 
| 130 | 0 |  |  | 0 |  | 0 | message => sub { "$_ must be be a file" }, | 
| 131 | 36 |  |  | 36 | 1 | 147 | ); | 
| 132 | 36 |  |  | 11 |  | 563 | return $type->plus_coercions( Str, sub { path($_) }, ); | 
|  | 11 |  |  |  |  | 129 |  | 
| 133 |  |  |  |  |  |  | } | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | =head2 C | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | An L or L object. | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | =cut | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | sub IO { | 
| 142 |  |  |  |  |  |  | state $type = Type::Tiny->new( | 
| 143 |  |  |  |  |  |  | name       => 'IO', | 
| 144 |  |  |  |  |  |  | constraint => sub { | 
| 145 | 34 | 100 | 66 | 34 |  | 6264 | blessed($_) | 
| 146 |  |  |  |  |  |  | && ( $_->isa('IO::Handle') || $_->isa('IO::String') ); | 
| 147 |  |  |  |  |  |  | }, | 
| 148 | 0 |  |  | 0 |  | 0 | message => sub { 'must be be an IO::Handle or IO::String' }, | 
| 149 | 10 |  |  | 10 | 1 | 53 | ); | 
| 150 | 10 |  |  |  |  | 450 | return $type; | 
| 151 |  |  |  |  |  |  | } | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | =head2 C | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | =head2 C | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | L types, which coerce filehandles to read/write L, | 
| 158 |  |  |  |  |  |  | respectively. | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | =cut | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | sub ReadIO { | 
| 163 |  |  |  |  |  |  | state $type = IO->plus_coercions(    # | 
| 164 | 2 |  |  | 2 |  | 29 | FileHandle, sub { IO::Handle->new_from_fd( $_, 'r' ) }, | 
| 165 | 9 |  |  | 9 | 1 | 39 | ); | 
| 166 | 9 |  |  |  |  | 2193 | return $type; | 
| 167 |  |  |  |  |  |  | } | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  | sub WriteIO { | 
| 170 |  |  |  |  |  |  | state $type = IO->plus_coercions(    # | 
| 171 | 6 |  |  | 6 |  | 126 | FileHandle, sub { IO::Handle->new_from_fd( $_, 'w' ) }, | 
| 172 | 22 |  |  | 22 | 1 | 60 | ); | 
| 173 | 22 |  |  |  |  | 1784 | return $type; | 
| 174 |  |  |  |  |  |  | } | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | 1; |