File Coverage

blib/lib/HTML/Barcode/DataMatrix.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 23 23 100.0


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

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

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