File Coverage

blib/lib/HTML/Barcode/QRCode.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package HTML::Barcode::QRCode;
2 1     1   21542 use Moo;
  1         11325  
  1         4  
3             extends 'HTML::Barcode::2D';
4 1     1   1266 use Text::QRCode;
  0            
  0            
5              
6             our $VERSION = '0.12';
7              
8             has '+module_size' => ( default => '3px' );
9             has '_qrcode' => (
10             is => 'ro',
11             default => sub { Text::QRCode->new },
12             );
13              
14             sub barcode_data {
15             my ($self) = @_;
16             my $data = $self->_qrcode->plot($self->text);
17              
18             return [ map { [ map { $_ eq '*' ? 1 : 0 } @$_ ] } @$data ];
19             }
20              
21             =head1 NAME
22              
23             HTML::Barcode::QRCode - Generate HTML representations of QR codes
24              
25             =head1 SYNOPSIS
26              
27             L and libqrencode are required by this class, so please install
28             them first.
29              
30             my $code = HTML::Barcode::QRCode->new(text => 'http://search.cpan.org');
31             print $code->render;
32              
33             =head1 DESCRIPTION
34              
35             This class allows you to easily create HTML representations of QR codes. These
36             are two-dimensional scan codes commonly used to allow people to quickly input
37             a URL into their phone or other mobile device.
38              
39             =begin html
40              
41            

Here is an example of a QR code rendered with this module:

42              
43            
44              
45             =end html
46              
47             This B L.
48              
49             You can read more about QR codes online (e.g. L).
50              
51             =head1 METHODS
52              
53             =head2 new (%attributes)
54              
55             Instantiate a new HTML::Barcode::QRCode object. The C<%attributes> hash
56             requires the L attribute, and can take any of the other
57             L listed below.
58              
59             =head2 render
60              
61             This is a convenience routine which returns C<< >> tags
62             and the rendered QR code.
63              
64             If you are printing multiple QR codes or want to ensure your C