blib/lib/SVG/Barcode/Code128.pm

filter: Statementstmt 100% 38 / 38 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 92.8% 52 / 56 CC 2 SCAR 1.6
CC
2
Cov
95%
_plot
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package SVG::Barcode::Code128;
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_code128|;
12  
13 2 ▶use Barcode::Code128;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our $VERSION = '0.11';
16  
17 2 use constant DEFAULTS => {
18 lineheight => 30,
19 linewidth => 1,
20 textsize => 10,
21 2 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 2 SVG::Barcode::_param(__PACKAGE__, $_, DEFAULTS->{$_}) for keys DEFAULTS->%*;
24  
25 # functions
26  
27 ▶sub plot_code128 ($text, %params) {
Subroutine plot_code128: called CC=1 SCAR=0.0
Pod documented
28 2 return __PACKAGE__->new(%params)->plot($text);
29 }
30  
31 # internal methods
32  
33 ▶sub _plot ($self, $text) {
Subroutine _plot: called CC=2 SCAR=7.4
34 4 ▶ $self->{plotter} ||= Barcode::Code128->new;
Condition33%1/3
$self->{"plotter"} ||= "Barcode::Code128"->new
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->{"plotter"} ||= "Barcode::Code128"->new
$self->{"plotter"} "Barcode::Code128"->new
Truth table33%1/3
A ||= B
A= $self->{"plotter"}B= "Barcode::Code128"->new
ABresult
1X1
011
000
35  
36 4 my @code = split //, $self->{plotter}->barcode($text);
37 4 $self->_plot_1d(\@code, '#');
38 4 $self->_plot_text($text);
39 }
40  
41 2 1;
42  
43 =encoding utf8
44  
45 =head1 NAME
46  
47 SVG::Barcode::Code128 - Generator for SVG based Code 128 barcodes
48  
49 =head1 SYNOPSIS
50  
51 use SVG::Barcode::Code128;
52  
53 my $code128 = SVG::Barcode::Code128->new;
54 my $svg = $code128->plot('https://perldoc.pl');
55  
56 $code128->linewidth; # 1
57 $code128->lineheight; # 30
58 $code128->textsize; # 10
59 # from SVG::Barcode:
60 $code128->foreground; # black
61 $code128->background; # white
62 $code128->margin; # 2
63 $code128->id;
64 $code128->class;
65 $code128->width;
66 $code128->height;
67 $code128->scale;
68  
69 my %params = (
70 lineheight => 40,
71 textsize => 0,
72 );
73 $code128 = SVG::Barcode::Code128->new(%params);
74  
75 # use as function
76 use SVG::Barcode::Code128 'plot_code128';
77  
78 my $svg = plot_code128('https://perldoc.pl', %params);
79  
80 =head1 DESCRIPTION
81  
82 L<SVG::Barcode::Code128> is a generator for SVG based Code 128 barcodes.
83  
84 =head1 FUNCTIONS
85  
86 =head2 plot_code128
87  
88 use SVG::Barcode::Code128 'plot_code128';
89  
90 $svg = plot_code128($text, %params);
91  
92 Returns a Code 128 barcode using the provided text and parameters.
93  
94 =head1 CONSTRUCTOR
95  
96 =head2 new
97  
98 $code128 = SVG::Barcode::Code128->new; # create with defaults
99 $code128 = SVG::Barcode::Code128->new(\%params);
100  
101 Creates a new Code 128 plotter. Inherited from L<SVG::Barcode|SVG::Barcode/new>.
102  
103 =head1 METHODS
104  
105 =head2 plot
106  
107 Creates a SVG code. Inherited from L<SVG::Barcode|SVG::Barcode/plot>.
108  
109 =head1 PARAMETERS
110  
111 Inherited from L<SVG::Barcode>:
112 L<background|SVG::Barcode/background>,
113 L<class|SVG::Barcode/class>,
114 L<foreground|SVG::Barcode/foreground>,
115 L<height|SVG::Barcode/height>,
116 L<id|SVG::Barcode/id>,
117 L<margin|SVG::Barcode/margin>,
118 L<scale|SVG::Barcode/scale>,
119 L<width|SVG::Barcode/width>.
120  
121 =head2 lineheight
122  
123 $value = $code128->lineheight;
124 $code128 = $code128->lineheight($newvalue);
125 $code128 = $code128->lineheight(''); # 30
126  
127 Getter and setter for the height of a line. Default C<30>.
128  
129 =head2 linewidth
130  
131 $value = $code128->linewidth;
132 $code128 = $code128->linewidth($newvalue);
133 $code128 = $code128->linewidth(''); # 1
134  
135 Getter and setter for the width of a single line. Default C<1>.
136  
137 =head2 textsize
138  
139 $value = $code128->textsize;
140 $code128 = $code128->textsize($newvalue);
141 $code128 = $code128->textsize(''); # 10
142  
143 Getter and setter for the size of the text a the bottom. C<0> hides the text. Default C<10>.
144  
145 =head1 SEE ALSO
146  
147 L<SVG::Barcode>, L<Barcode::Code128>.
148  
149 =head1 AUTHOR & COPYRIGHT
150  
151 © 2019 by Tekki (Rolf Stöckli).
152  
153 This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
154  
155 =cut
↑ Summary