File Coverage

blib/lib/Imager/QRCode.pm
Criterion Covered Total %
statement 34 41 82.9
branch 4 12 33.3
condition 0 5 0.0
subroutine 10 11 90.9
pod 3 3 100.0
total 51 72 70.8


line stmt bran cond sub pod time code
1             package Imager::QRCode;
2              
3 2     2   66455 use warnings;
  2         6  
  2         72  
4 2     2   11 use strict;
  2         6  
  2         129  
5 2     2   12 use base qw(Exporter);
  2         8  
  2         247  
6 2     2   11 use vars qw(@ISA $VERSION @EXPORT_OK);
  2         2  
  2         202  
7              
8             @EXPORT_OK = qw(plot_qrcode);
9              
10 2     2   12 use Carp qw(croak);
  2         3  
  2         151  
11 2     2   2891 use Imager 0.55;
  2         150146  
  2         18  
12              
13             BEGIN {
14 2     2   367 $VERSION = '0.034';
15             eval {
16 2         26 require XSLoader;
17 2         1449 XSLoader::load('Imager::QRCode', $VERSION);
18 2         546 1;
19 2 50       4 } or do {
20 0         0 require DynaLoader;
21 0         0 push @ISA, 'DynaLoader';
22 0         0 bootstrap Imager::QRCode $VERSION;
23             };
24             }
25              
26             sub new {
27 4     4 1 2353 my $class = shift;
28 4 50       32 my $params = scalar ref $_[0] eq 'HASH' ? $_[0] : { @_ };
29 4         22 return bless { params => $params }, $class;
30             }
31              
32             sub plot {
33 4     4 1 19861 my ( $self, $text ) = @_;
34 4 50       14 $text or croak 'Not enough arguments for plot()';
35 4         7455 return _imager( _plot($text, $self->{params}) );
36             }
37              
38             sub plot_qrcode {
39 0     0 1 0 my ( $text, $params ) = @_;
40 0 0       0 $text or croak 'Not enough arguments for plot()';
41 0 0 0     0 $params ||= {} if !$params || ref $params ne 'HASH';
      0        
42 0         0 return _imager( _plot( $text, $params ) );
43             }
44              
45             sub _imager {
46 3     3   7 my $raw = shift;
47 3 50       20 ref $raw eq 'Imager::ImgRaw' or croak "_imager() argument must be Imager::ImgRaw";
48 3         23 my $img = Imager->new;
49 3         78 $img->{IMG} = $raw;
50 3         21 return $img;
51             }
52              
53             1; # Magic true value required at end of module
54             __END__