Parser/Checkbox.pm

filter: Statementstmt 42.5% 20 / 47 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.8% 7 / 13 Podpod 100% 6 / 6 totaltotal 40.2% 33 / 82 CC 9 SCAR 30.2
CC
9
Cov
32%
as_string
56.0
as_markdown
6.0
as_pod
6.0
CRAP 20.4
« Parser/ListItem.pm ↑ Summary Parser/TableRow.pm »
1 ## -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## Markdown Parser Only - ~/lib/Markdown/Parser/Checkbox.pm
4 ## Version v0.3.0
5 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
6 ## Author: Jacques Deguest <jack@deguest.jp>
7 ## Created 2021/08/23
8 ## Modified 2024/08/30
9 ## All rights reserved
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package Markdown::Parser::Checkbox;
15 BEGIN
16 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ use parent qw( Markdown::Parser::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 our $VERSION = 'v0.3.0';
22 };
23  
24 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 sub init
28 0 ▶{
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
29 0 my $self = shift( @_ );
30 0 $self->{tag_name} = 'checkbox';
31 0 $self->{checked} = 0;
32 0 $self->{disabled} = 0;
33 0 return( $self->SUPER::init( @_ ) );
34 }
35  
36 sub as_markdown
37 0 ▶{
Subroutine as_markdown: not called CC=2 SCAR=17.9
Pod documented
38 0 my $self = shift( @_ );
39 0 my $checked = $self->checked;
40 0 ▶ return( ' [' . ( $checked ? 'X' : ' ' ) . '] ' );
Branch: 1 branch
BranchTrueFalseTotal
$checked ? : 0 0 0
41 }
42  
43 sub as_pod
44 0 ▶{
Subroutine as_pod: not called CC=2 SCAR=17.9
Pod documented
45 0 my $self = shift( @_ );
46 0 my $checked = $self->checked;
47 0 ▶ return( ' [' . ( $checked ? 'X' : ' ' ) . '] ' );
Branch: 1 branch
BranchTrueFalseTotal
$checked ? : 0 0 0
48 }
49  
50 sub as_string
51 0 ▶{
Subroutine as_string: not called CC=7 SCAR=40.3
Pod documented
52 0 my $self = shift( @_ );
53 0 my $arr = $self->new_array( [' <input type="checkbox"'] );
54 0 my $checked = $self->checked;
55 0 my $disabled = $self->disabled;
56 0 my $attr = $self->new_array;
57 0 ▶ $attr->push( $self->format_id ) if( $self->id->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->id->length 0 0 0
58 0 ▶ $attr->push( $self->format_class ) if( $self->class->length );
Branch: 1 branch
BranchTrueFalseTotal
if $self->class->length 0 0 0
59 0 my $attributes = $self->format_attributes;
60 0 ▶ $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attributes->length 0 0 0
61 0 ▶ $arr->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length );
Branch: 1 branch
BranchTrueFalseTotal
if $attr->length 0 0 0
62 0 ▶ $arr->push( 'disabled' ) if( $disabled );
Branch: 1 branch
BranchTrueFalseTotal
if $disabled 0 0 0
63 0 ▶ $arr->push( 'checked' ) if( $checked );
Branch: 1 branch
BranchTrueFalseTotal
if $checked 0 0 0
64 0 $arr->push( '/> ' );
65 0 return( $arr->join( ' ' )->scalar );
66 }
67  
68 0 ▶sub checked { return( shift->_set_get_boolean( 'checked', @_ ) ); }
Subroutine checked: not called CC=1 SCAR=6.9
Pod documented
69  
70 0 ▶sub disabled { return( shift->_set_get_boolean( 'disabled', @_ ) ); }
Subroutine disabled: not called CC=1 SCAR=6.9
Pod documented
71  
72 1 1;
73 # NOTE: POD
74 __END__
« Parser/ListItem.pm ↑ Summary Parser/TableRow.pm »