blib/lib/SVG/Barcode/DataMatrix.pm

filter: Statementstmt 100% 36 / 36 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 92.5% 50 / 54 CC 2 SCAR 1.8
CC
2
Cov
95%
_plot
2.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package SVG::Barcode::DataMatrix;
2 2 ▶use parent 'SVG::Barcode';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 our @EXPORT_OK = qw|plot_datamatrix|;
12  
13 2 ▶use Barcode::DataMatrix;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our $VERSION = '0.12';
16  
17 2 use constant DEFAULTS => {
18 dotsize => 1,
19 encoding_mode => 'AUTO',
20 process_tilde => 0,
21 size => 'AUTO',
22 2 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 SVG::Barcode::_param(__PACKAGE__, $_, DEFAULTS->{$_}) for keys DEFAULTS->%*;
25  
26 # functions
27  
28 ▶sub plot_datamatrix ($text, %params) {
Subroutine plot_datamatrix: called CC=1 SCAR=0.0
Pod documented
29 2 return __PACKAGE__->new(%params)->plot($text);
30 }
31  
32 # internal methods
33  
34 ▶sub _plot ($self, $text) {
Subroutine _plot: called CC=2 SCAR=8.1
35 $self->{plotter}
36 4 ▶ ||= Barcode::DataMatrix->new($self->%{qw|encoding_mode process_tilde size|});
Condition33%1/3
$self->{"plotter"} ||= "Barcode::DataMatrix"->new(%$self{"encoding_mode", "process_tilde", "size"})
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->{"plotter"} ||= "Barcode::DataMatrix"->new(%$self{"encoding_mode", "process_tilde", "size"})
$self->{"plotter"} "Barcode::DataMatrix"->new(%$self{"encoding_mode", "process_tilde", "size"})
Truth table33%1/3
A ||= B
A= $self->{"plotter"}B= "Barcode::DataMatrix"->new(%$self{"encoding_mode", "process_tilde", "size"})
ABresult
1X1
011
000
37 4 $self->_plot_2d($self->{plotter}->barcode($text), 1);
38 }
39  
40 2 1;
41  
42 =encoding utf8
43  
44 =head1 NAME
45  
46 SVG::Barcode::DataMatrix - Generator for SVG based Data Matrix barcodes
47  
48 =head1 SYNOPSIS
49  
50 use SVG::Barcode::DataMatrix;
51  
52 my $datamatrix = SVG::Barcode::DataMatrix->new;
53 my $svg = $datamatrix->plot('https://perldoc.pl');
54  
55 $datamatrix->dotsize; # 1
56 $datamatrix->encoding_mode; # AUTO
57 $datamatrix->process_tilde; # 0
58 $datamatrix->size; # AUTO
59 # from SVG::Barcode:
60 $datamatrix->foreground; # black
61 $datamatrix->background; # white
62 $datamatrix->margin; # 2
63 $datamatrix->id;
64 $datamatrix->class;
65 $datamatrix->width;
66 $datamatrix->height;
67  
68 my %params = (
69 level => 'H',
70 margin => 4,
71 );
72 $datamatrix = SVG::Barcode::DataMatrix->new(%params);
73  
74 # use as function
75 use SVG::Barcode::DataMatrix 'plot_datamatrix';
76  
77 $svg = plot_datamatrix('https://perldoc.pl', %params);
78  
79 =head1 DESCRIPTION
80  
81 L<SVG::Barcode::DataMatrix> is a generator for SVG based Data Matrix barcodes.
82  
83 =head1 FUNCTIONS
84  
85 =head2 plot_datamatrix
86  
87 use SVG::Barcode::DataMatrix 'plot_datamatrix';
88  
89 $svg = plot_datamatrix($text, %params);
90  
91 Returns a Data Matrix using the provided text and parameters.
92  
93 =head1 CONSTRUCTOR
94  
95 =head2 new
96  
97 $datamatrix = SVG::Barcode::DataMatrix->new; # create with defaults
98 $datamatrix = SVG::Barcode::DataMatrix->new(%params);
99  
100 Creates a new Data Matrix plotter. Inherited from L<SVG::Barcode|SVG::Barcode/new>.
101  
102 =head1 METHODS
103  
104 =head2 plot
105  
106 $svg = $datamatrix->plot($text);
107  
108 Creates a SVG code. Inherited from L<SVG::Barcode|SVG::Barcode/plot>.
109  
110 =head1 PARAMETERS
111  
112 Inherited from L<SVG::Barcode>:
113 L<background|SVG::Barcode/background>,
114 L<class|SVG::Barcode/class>,
115 L<foreground|SVG::Barcode/foreground>,
116 L<height|SVG::Barcode/height>,
117 L<id|SVG::Barcode/id>,
118 L<margin|SVG::Barcode/margin>,
119 L<width|SVG::Barcode/width>.
120  
121 =head2 dotsize
122  
123 $value = $datamatrix->dotsize;
124 $datamatrix = $datamatrix->dotsize($newvalue);
125 $datamatrix = $datamatrix->dotsize(''); # 1
126  
127 Getter and setter for the size of the dots. Default C<1>.
128  
129 =head2 encoding_mode
130  
131 $value = $datamatrix->encoding_mode;
132 $datamatrix = $datamatrix->encoding_mode($newvalue);
133 $datamatrix = $datamatrix->encoding_mode(''); # AUTO
134  
135 Getter and setter for the encoding mode.
136 One of C<AUTO>, C<ASCII>, C<C40>, C<TEXT>, C<BASE256>, or C<NONE>. Default C<AUTO>.
137  
138 =head2 process_tilde
139  
140 $value = $datamatrix->process_tilde;
141 $datamatrix = $datamatrix->process_tilde($newvalue);
142 $datamatrix = $datamatrix->process_tilde(''); # 0
143  
144 Getter and setter for the tilde flag.
145 If set to C<1> the tilde character C<~> is being used to recognize special characters.
146 Default C<0>.
147  
148 =head2 size
149  
150 $value = $datamatrix->size;
151 $datamatrix = $datamatrix->size($newvalue);
152 $datamatrix = $datamatrix->size(''); # AUTO
153  
154 Getter and setter for the module size of the matrix.
155 C<height x width>, one of C<AUTO>, C<10x10>, C<12x12>, C<14x14>, C<16x16>, C<18x18>, C<20x20>, C<22x22>, C<24x24>, C<26x26>, C<32x32>, C<36x36>, C<40x40>, C<44x44>, C<48x48>, C<52x52>, C<64x64>, C<72x72>, C<80x80>, C<88x88>, C<96x96>, C<104x104>, C<120x120>, C<132x132>, C<144x144>, C<8x18>, C<8x32>, C<12x26>, C<12x36>, C<16x36>, C<16x48>.
156 Default C<AUTO>.
157  
158 =head1 SEE ALSO
159  
160 L<SVG::Barcode>, L<Barcode::DataMatrix>.
161  
162 =head1 AUTHOR & COPYRIGHT
163  
164 © 2019 by Tekki (Rolf Stöckli).
165  
166 This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
167  
168 =cut
↑ Summary