| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 31070 | use 5.010; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 2 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 43 |  | 
| 3 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 7 |  | 
|  | 1 |  |  |  |  | 67 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | package Acme::What; | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | BEGIN { | 
| 8 | 1 |  |  | 1 |  | 3 | $Acme::What::AUTHORITY = 'cpan:TOBYINK'; | 
| 9 | 1 |  |  |  |  | 23 | $Acme::What::VERSION   = '0.005'; | 
| 10 |  |  |  |  |  |  | } | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 1 |  |  | 1 |  | 2571 | use Devel::Declare; | 
|  | 1 |  |  |  |  | 21376 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 13 | 1 |  |  | 1 |  | 1479 | use Sub::Util qw/set_subname/; | 
|  | 1 |  |  |  |  | 437 |  | 
|  | 1 |  |  |  |  | 2585 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 1 |  |  | 1 |  | 12 | use base qw/Devel::Declare::Context::Simple/; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 1580 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub import | 
| 18 |  |  |  |  |  |  | { | 
| 19 | 1 |  |  | 1 |  | 24596 | no strict 'refs'; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 538 |  | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 3 |  |  | 3 |  | 4332 | my $caller = caller; | 
| 22 | 3 |  |  |  |  | 46 | my $self   = shift; | 
| 23 | 3 |  | 100 |  |  | 13 | my $method = shift // 'WHAT'; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 3 |  |  |  |  | 7 | my $export = "$caller\::what"; | 
| 26 | 3 | 100 |  |  |  | 10 | unless ( exists &$export ) | 
| 27 |  |  |  |  |  |  | { | 
| 28 | 1 | 50 |  |  |  | 10 | $self = $self->new unless ref $self; | 
| 29 |  |  |  |  |  |  | Devel::Declare->setup_for( | 
| 30 |  |  |  |  |  |  | $caller, | 
| 31 | 5 |  |  | 5 |  | 133 | { what => { const => sub { $self->_parser(@_) } } } | 
| 32 | 1 |  |  |  |  | 17 | ); | 
| 33 | 1 |  |  | 5 |  | 49 | *$export = set_subname($export => sub ($) { $self->_do(@_) }); | 
|  | 5 |  |  | 5 |  | 2033 |  | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 3 | 100 |  |  |  | 145 | $^H{(__PACKAGE__)} = $method =~ m{^\+(.+)$} | 
| 37 |  |  |  |  |  |  | ? $1 | 
| 38 |  |  |  |  |  |  | : sprintf("$caller\::$method"); | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub unimport | 
| 42 |  |  |  |  |  |  | { | 
| 43 | 1 |  |  | 1 |  | 60 | $^H{(__PACKAGE__)} = undef; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub _parser | 
| 47 |  |  |  |  |  |  | { | 
| 48 | 5 |  |  | 5 |  | 8 | my $self = shift; | 
| 49 | 5 |  |  |  |  | 17 | $self->init(@_); | 
| 50 | 5 |  |  |  |  | 61 | $self->skip_declarator; | 
| 51 | 5 |  |  |  |  | 132 | $self->skipspace; | 
| 52 | 5 |  |  |  |  | 44 | my $linestr = $self->get_linestr; | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 5 |  |  |  |  | 32 | my $remaining = substr($linestr, $self->offset); | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 5 | 100 |  |  |  | 33 | if ($remaining =~ /^(.*?);(.*)$/) | 
| 57 |  |  |  |  |  |  | { | 
| 58 |  |  |  |  |  |  | # Found semicolon | 
| 59 | 2 |  |  |  |  | 4 | my $quoted = $self->_quote($1); | 
| 60 | 2 |  |  |  |  | 17 | substr($linestr, $self->offset) = "('$quoted');" . $2; | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  | else | 
| 63 |  |  |  |  |  |  | { | 
| 64 | 3 |  |  |  |  | 5 | chomp $remaining; | 
| 65 | 3 |  |  |  |  | 6 | my $quoted = $self->_quote($remaining); | 
| 66 | 3 |  |  |  |  | 12 | substr($linestr, $self->offset) = "('$quoted');\n"; | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 | 5 |  |  |  |  | 33 | $self->set_linestr($linestr); | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | sub _quote | 
| 73 |  |  |  |  |  |  | { | 
| 74 | 5 |  |  | 5 |  | 10 | my ($self, $str) = @_; | 
| 75 | 5 |  |  |  |  | 8 | $str =~ s{([\\\'])}{\\$1}g; | 
| 76 | 5 |  |  |  |  | 10 | return $str; | 
| 77 |  |  |  |  |  |  | } | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | sub _do | 
| 80 |  |  |  |  |  |  | { | 
| 81 | 1 |  |  | 1 |  | 5 | no strict 'refs'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 128 |  | 
| 82 | 5 |  |  | 5 |  | 12 | my ($self, @args) = @_; | 
| 83 | 5 |  |  |  |  | 21 | my @caller = caller(1); | 
| 84 |  |  |  |  |  |  |  | 
| 85 | 5 |  |  |  |  | 134 | my $meth = $caller[10]{ (__PACKAGE__) }; | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 5 | 100 |  |  |  | 16 | if (not defined $meth) { | 
| 88 | 1 |  |  |  |  | 12 | require Carp; | 
| 89 | 1 |  |  |  |  | 31 | Carp::croak("Acme::What disabled"); | 
| 90 |  |  |  |  |  |  | } | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 4 |  |  |  |  | 21 | return $meth->(@args); | 
| 93 |  |  |  |  |  |  | } | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | __PACKAGE__ | 
| 96 |  |  |  |  |  |  | __END__ |