File Coverage

lib/ChordPro/Chords/Appearance.pm
Criterion Covered Total %
statement 17 27 62.9
branch n/a
condition n/a
subroutine 7 10 70.0
pod 0 4 0.0
total 24 41 58.5


line stmt bran cond sub pod time code
1             #! perl
2              
3 90     90   1360 use v5.26;
  90         411  
4 90     90   632 use Object::Pad;
  90         253  
  90         945  
5 90     90   13900 use utf8;
  90         244  
  90         537  
6 90     90   3730 use Carp;
  90         191  
  90         24898  
7              
8             class ChordPro::Chords::Appearance :strict(params);
9              
10             =begin md
11              
12             key The bare chord name, e.g., "Am7".
13             Also index in chordinfo.
14             Transposed/transcoded if applicable.
15              
16             info The chord info (chord props, diagram props, etc.)
17             This should be chordsinfo->{key}
18              
19             orig The chord as it appeared in the song, e.g. "(Am7)"
20              
21             format The format for the chord, e.g. "%{root}%{qual}%{ext}",
22             but more likely something like "(%{formatted})".
23             %{formatted} will be replaced by the result of applying the
24             global config.chord-format.
25              
26             raw ????
27             Key with parens if (%{formatted}).
28              
29             =cut
30              
31             field $key :mutator :param = undef;
32 1526     1526 0 4721 field $format :mutator :param = undef;
  1526         9056  
33 58     58 0 254 field $info :mutator :param = undef;
  58         319  
34 1879     1879 0 5295 field $orig :mutator :param = undef;
  1879         6179  
35              
36             # For convenience.
37 0     0 0   method chord_display {
  0            
38              
39             unless ( $info
40             && UNIVERSAL::isa( $info, 'ChordPro::Chord::Base' ) ) {
41             $Carp::Internal{ (__PACKAGE__) }++;
42             local $Carp::RefArgFormatter =
43 0     0     sub { my $t = $_[0];
44 0           $t =~ s/^(ChordPro::.*)=HASH.*/<<$1>>/;
45 0           $t };
46             my $m = Carp::longmess();
47             die("Missing info for $key$m");
48             }
49              
50             local $info->{chordformat} = $format;
51             $info->chord_display;
52             }
53              
54             method raw {
55             return $key unless defined $format;
56             if ( $format eq '(%{formatted})' ) {
57             return '(' . $key . ')';
58             }
59             $key;
60             }
61              
62             method CARP_TRACE {
63             "<>";
64             }
65              
66 0     0     method _data_printer($ddp) {
  0            
  0            
  0            
67 0           "$key (" . __CLASS__ . ")";
68             }
69              
70             1;