File Coverage

blib/lib/HTML/Barcode/DataMatrix.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 15 15 100.0


line stmt bran cond sub pod time code
1             package HTML::Barcode::DataMatrix;
2 2     2   28012 use Moo;
  2         19100  
  2         8  
3             extends 'HTML::Barcode::2D';
4              
5 2     2   2804 use Barcode::DataMatrix;
  2         58707  
  2         590  
6              
7             our $VERSION = '0.04';
8              
9             has '+module_size' => ( default => '3px' );
10             has 'encoding_mode' => (
11             is => 'ro',
12             isa => sub { my $type = shift; for (qw(ASCII C40 TEXT BASE256 NONE AUTO)) { return 1 if $type eq $_ } return 0; },
13             default => 'AUTO',
14             documentation => 'The encoding mode for the data matrix. Can be one of: ASCII C40 TEXT BASE256 NONE AUTO',
15             );
16             has 'process_tilde' => (
17             is => 'ro',
18             default => 0,
19             documentation => 'Boolean. Set to true to indicate the tilde character "~" is being used to recognize special characters.',
20             );
21             has '_datamatrix' => (
22             is => 'ro',
23             lazy => 1,
24             builder => '_build_datamatrix',
25             );
26             sub _build_datamatrix {
27 1     1   289 my $self = shift;
28 1         9 return Barcode::DataMatrix->new(
29             encoding_mode => $self->encoding_mode,
30             process_tilde => $self->process_tilde,
31             );
32             }
33              
34             sub barcode_data {
35 2     2 1 6978 my ($self) = @_;
36             # Its barcode() methods returns an AoA just like we need it.
37 2         15 return $self->_datamatrix->barcode($self->text);
38             }
39              
40             =head1 NAME
41              
42             HTML::Barcode::DataMatrix - Generate HTML representations of Data Matrix barcodes
43              
44             =head1 SYNOPSIS
45              
46             my $barcode = HTML::Barcode::DataMatrix->new(text => 'http://search.cpan.org');
47             print $code->render;
48              
49             =head1 DESCRIPTION
50              
51             This class allows you to easily create HTML representations of Data Matrix
52             barcodes.
53              
54             =begin html
55              
56            

Here is an example of a barcode rendered with this module:

57              
58            
59              
60             =end html
61              
62             You can read more about Data Matrix barcodes online
63             (e.g. L)
64              
65             =head1 METHODS
66              
67             =head2 new (%attributes)
68              
69             Instantiate a new HTML::Barcode::DataMatrix object. The C<%attributes> hash
70             requires the L attribute, and can take any of the other
71             L listed below.
72              
73             =head2 render
74              
75             This is a convenience routine which returns C<< >> tags
76             and the rendered barcode.
77              
78             If you are printing multiple barcodes or want to ensure your C