File Coverage

blib/lib/Devel/IPerl/Plugin/ChartClicker.pm
Criterion Covered Total %
statement 21 34 61.7
branch 0 4 0.0
condition n/a
subroutine 7 10 70.0
pod 0 2 0.0
total 28 50 56.0


line stmt bran cond sub pod time code
1             package Devel::IPerl::Plugin::ChartClicker;
2             # ABSTRACT: IPerl plugin to make Chart::Clicker charts displayable
3             $Devel::IPerl::Plugin::ChartClicker::VERSION = '0.007';
4 1     1   5189520 use strict;
  1         2  
  1         34  
5 1     1   5 use warnings;
  1         2  
  1         32  
6              
7 1     1   4 use Chart::Clicker;
  1         4  
  1         18  
8 1     1   334 use Role::Tiny;
  1         3668  
  1         7  
9              
10             our $IPerl_compat = 1;
11              
12             our $IPerl_format_info = {
13             'SVG' => { suffix => '.svg', displayable => 'Devel::IPerl::Display::SVG' },
14             'PNG' => { suffix => '.png', displayable => 'Devel::IPerl::Display::PNG' },
15             };
16              
17             sub register {
18 0     0 0   Role::Tiny->apply_roles_to_package( 'Chart::Clicker', q(Devel::IPerl::Plugin::ChartClicker::IPerlRole) );
19             }
20              
21             {
22             package
23             Devel::IPerl::Plugin::ChartClicker::IPerlRole;
24              
25 1     1   583 use Moo::Role;
  1         15410  
  1         13  
26 1     1   3344 use Capture::Tiny qw(capture_stderr capture_stdout);
  1         11636  
  1         67  
27 1     1   8 use File::Temp;
  1         3  
  1         186  
28              
29              
30             sub iperl_data_representations {
31 0     0 0   my ($cc) = @_;
32 0 0         return unless $Devel::IPerl::Plugin::ChartClicker::IPerl_compat;
33              
34 0           my $format = uc($cc->format);
35 0           my $format_info = $Devel::IPerl::Plugin::ChartClicker::IPerl_format_info;
36              
37 0 0         return unless exists($format_info->{$format});
38              
39 0           my $suffix = $format_info->{$format}{suffix};
40 0           my $displayable = $format_info->{$format}{displayable};
41              
42 0           my $tmp = File::Temp->new( SUFFIX => $suffix );
43 0           my $tmp_filename = $tmp->filename;
44             capture_stderr( sub {
45 0     0     $cc->write_output( $tmp_filename );
46 0           });
47              
48 0           return $displayable->new( filename => $tmp_filename )->iperl_data_representations;
49             }
50              
51             }
52              
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Devel::IPerl::Plugin::ChartClicker - IPerl plugin to make Chart::Clicker charts displayable
64              
65             =head1 VERSION
66              
67             version 0.007
68              
69             =head1 AUTHORS
70              
71             =over 4
72              
73             =item *
74              
75             Zakariyya Mughal <zmughal@cpan.org>
76              
77             =item *
78              
79             Zhenyi Zhou <zhouzhen1@gmail.com>
80              
81             =back
82              
83             =head1 COPYRIGHT AND LICENSE
84              
85             This software is copyright (c) 2017 by Zakariyya Mughal.
86              
87             This is free software; you can redistribute it and/or modify it under
88             the same terms as the Perl 5 programming language system itself.
89              
90             =cut