File Coverage

blib/lib/Mojolicious/Plugin/EDumper.pm
Criterion Covered Total %
statement 3 11 27.2
branch 0 2 0.0
condition 0 2 0.0
subroutine 1 3 33.3
pod 1 1 100.0
total 5 19 26.3


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::EDumper;
2              
3 1     1   66521 use Mojo::Base 'Mojolicious::Plugin';
  1         186658  
  1         8  
4              
5             our $VERSION = '0.00006';
6              
7             =pod
8              
9             =encoding utf8
10              
11              
12             =head1 ¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
13              
14             Доброго всем, соответственно
15              
16             =head1 VERSION
17              
18             0.00006
19              
20             =head1 NAME
21              
22             Mojolicious::Plugin::EDumper - pretty dumps encoded data.
23              
24             =head1 SINOPSYS
25              
26             $app->plugin('EDumper');
27             $app->plugin('EDumper', helper=>'dumper');
28            
29             $c->dumper( +{'Вася' => 'Пупкин'} );
30              
31             =head1 OPTIONS
32              
33             =head2 helper
34              
35             Name of the helper. Default - 'edumper'.
36              
37              
38             =head1 SEE ALSO
39              
40             L
41             L
42             L
43             L
44              
45             Redefine might not work:
46              
47             sub Data::Dumper::qquote {
48             my $s = shift;
49             return "'$s'";
50             }
51              
52              
53             =head1 AUTHOR
54              
55             Михаил Че (Mikhail Che), C<< >>
56              
57             =head1 BUGS / CONTRIBUTING
58              
59             Please report any bugs or feature requests at L. Pull requests also welcome.
60              
61             =head1 COPYRIGHT
62              
63             Copyright 2016+ Mikhail Che.
64              
65             This library is free software; you can redistribute it and/or modify
66             it under the same terms as Perl itself.
67              
68             =cut
69              
70             sub register {
71 0     0 1   my ($self, $app, $conf) = @_;
72             #~ my $enc = delete $conf->{enc} || 'utf8';
73 0   0       my $helper = delete $conf->{helper} || 'edumper';
74             $app->helper($helper => sub {
75 0     0     shift;
76             #~ decode $enc,
77             #~ Data::Dumper->new(Data::Recursive::Encode->encode($enc, \@_),)
78             #~ ->Indent(1)->Sortkeys(1)->Terse(1)->Useqq(0)->Dump;
79            
80 0           my $dump = eval 'qq★'.
81             Data::Dumper->new(\@_)
82             ->Indent(1)->Sortkeys(1)->Terse(1)->Useqq(0)->Dump
83             .'★';
84             #~ =~ s/((?:\\x\{[\da-f]+\})+)/eval '"'.$1.'"'/eigr;
85            
86 0 0         die __PACKAGE__." error: $@"
87             if $@;
88            
89 0           return $dump;
90            
91 0           });
92 0           return $self;
93             }
94              
95             1;