| 1 | 2 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | package YAML::Shell; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | our $VERSION = '0.70'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Term::ReadLine; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 0 | ▶ | sub Term::ReadLine::Perl::Tie::FIRSTKEY {undef} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | $Data::Dumper::Indent = 1; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our $prompt = 'ysh > '; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | my $round_trip = 0; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | my $force = 0; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my $log = 0; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | my $yaml_module = 'YAML::Any'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | my $yaml_version; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | my $sh; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | sub run { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=36 SCAR=70.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | set_version($yaml_module); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my @env_args = split /\s+/, ($ENV{YSH_OPT} || ''); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'YSH_OPT'} || ''
MC/DC0%0/1
$ENV{'YSH_OPT'} || ''
$ENV{'YSH_OPT'}
Truth table0%0/2
A
A= $ENV{'YSH_OPT'}
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my @args = (@env_args, @_); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $stream = -t STDIN ? '' : join('', <STDIN>); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | while (my $arg = shift @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | set_version($1), next if $arg =~ /^-M(.*)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | handle_help(), exit if $arg eq '-h'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | handle_version(), exit if $arg eq '-v'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | handle_Version(), exit if $arg eq '-V'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | $YAML::Indent = $1, next if $arg =~ /^-i(\d+)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $YAML::UseFold = 1, next if $arg eq '-uf'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $YAML::UseBlock = 1, next if $arg eq '-ub'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $YAML::UseCode = 1, next if $arg eq '-uc'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $YAML::UseHeader = 0, next if $arg eq '-nh'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $YAML::UseVersion = 0, next if $arg eq '-nv'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $round_trip = 1, next if $arg eq '-r'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | $round_trip = 2, next if $arg eq '-R'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $log = 1, next if $arg eq '-l'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $log = 2, next if $arg eq '-L'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $force = 1, next if $arg eq '-F'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | warn(<<END), exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 44 | Unknown YAML Shell argument: '$arg'. | ||||||||||||||||||||||||||||||||||||||||||
| 45 | For help, try: perldoc ysh | ||||||||||||||||||||||||||||||||||||||||||
| 46 | END | ||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | set_version($yaml_module); | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | check_install() unless $force; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($log) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ($log == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | open LOGFILE, "> ./ysh.log" or die $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | open LOGFILE, ">> ./ysh.log" or die $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $version = ${"${yaml_module}::VERSION"}; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | print LOGFILE "\n$yaml_module Version $version\n"; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | print LOGFILE "Begin logging at ", scalar localtime, "\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if (not length($stream)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | Print(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 68 | Welcome to the YAML Test Shell. Type ':help' for more information. | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | END | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | local @ENV{qw(HOME EDITOR)}; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | local $^W; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $sh = Term::ReadLine::->new('The YAML Shell'); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | sub my_readline { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | print LOGFILE $prompt if $log; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
my_readline: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $input = $sh->readline($prompt); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if (not defined $input) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $input = ':exit'; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | Print("\n"); | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $input .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (length($stream)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my @objects; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | eval { @objects = &{"${yaml_module}::Load"}($stream) }; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | print STDERR $@; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | print STDOUT Data::Dumper::Dumper(@objects); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | exit 0; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | while ($_ = my_readline()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | print LOGFILE $_ if $log; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | next if /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | exec('ysh', @ARGV) if /^\/$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | handle_command($_),next if /^:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | handle_file($1),next if /^<\s*(\S+)\s*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | handle_yaml($_),next if /^--\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | handle_yaml(''),next if /^===$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | handle_perl($_,1),next if /^;/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | handle_perl($_,0),next; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | Print("Unknown command. Type ':help' for instructions.\n"); | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | sub set_version { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my $module = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_version: not called CC=2 SCAR=12.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | eval "require $module"; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $yaml_module = $module; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $yaml_version = ${"${yaml_module}::VERSION"}; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | sub Print { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | print @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Print: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | print LOGFILE @_ if $log; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | local $SIG{__WARN__} = sub { Print @_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | sub handle_file { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my ($file) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_file: not called CC=2 SCAR=13.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my @objects; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | @objects = &{"${yaml_module}::LoadFile"}($file) | |||||||||||||||||||||||||||||||||||||||||
| 140 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | Print $@; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | Print Data::Dumper::Dumper(@objects); | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | sub handle_perl { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | my ($perl, $multi) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_perl: not called CC=12 SCAR=47.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my (@objects, $yaml, $yaml2); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | local $prompt = 'perl> '; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $line = ''; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ($multi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | while ($line !~ /^;$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $line = my_readline(); | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | print LOGFILE $line if $log; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $perl .= $line; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | @objects = eval "no strict;$perl"; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | Print("Bad Perl expression:\n$@"), return if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | eval { $yaml = &{"${yaml_module}::Dump"}(@objects) }; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | $@ =~ s/^ at.*\Z//sm if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | Print("Dump failed:\n$@"), return if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | Print $yaml; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ($round_trip) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | eval { $yaml2 = &{"${yaml_module}::Dump"}(&{"${yaml_module}::Load"}($yaml)) }; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $@ =~ s/^ at.*\Z//sm if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | Print("Load failed:\n$@"), return if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($yaml eq $yaml2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($round_trip > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | Print "\nData roundtripped OK!!!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | Print "================\n"; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | Print "after roundtrip:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | Print "================\n"; | |||||||||||||||||||||||||||||||||||||||||
| 187 | # $yaml2 =~ s/ /_/g; # | ||||||||||||||||||||||||||||||||||||||||||
| 188 | # $yaml2 =~ s/\n/+/g; # | ||||||||||||||||||||||||||||||||||||||||||
| 189 | # Print $yaml2, "\n"; # | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | Print $yaml2; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | Print "=========================\n"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | Print "Data did NOT roundtrip...\n"; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | sub handle_yaml { | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | my $yaml = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_yaml: not called CC=9 SCAR=42.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $line = $yaml; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my (@objects); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | local $prompt = 'yaml> '; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $line = my_readline(); | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | print LOGFILE $line if $log; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $line = '' unless defined $line; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | while ($line !~ /^\.{3}$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $yaml .= $line; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $line = my_readline(); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | print LOGFILE $line if $log; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | last unless defined $line; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $yaml =~ s/\^{2,8}/\t/g; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | eval { @objects = &{"${yaml_module}::Load"}($yaml) }; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $@ =~ s/^ at.*\Z//sm if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | $@ =~ s/^/ /gm if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | Print("YAML Load Failed:\n$@"), return if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | Print Data::Dumper::Dumper(@objects); | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | sub handle_command { | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | my $line = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_command: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my ($cmd, $args); | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ($line =~ /^:(\w+)\s*(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $cmd = $1; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $args = $2; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | exit if $cmd =~ /^(exit|q(uit)?)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | handle_help(),return if $cmd eq 'help'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | print `clear`,return if $cmd =~ /^c(lear)?$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | Print "Invalid command\n"; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | sub handle_help { | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | Print <<END; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_help: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | Welcome to the YAML Test Shell. | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | When you to type in Perl, you get back YAML. And vice versa. | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | By default, every line you type is a one line Perl program, the | ||||||||||||||||||||||||||||||||||||||||||
| 241 | return value of which will be displayed as YAML. | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | To enter multi-line Perl code start the first line with ';' and use | ||||||||||||||||||||||||||||||||||||||||||
| 244 | as many lines as needed. Terminate with a line containing just ';'. | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | To enter YAML text, start with a valid YAML separator/header line | ||||||||||||||||||||||||||||||||||||||||||
| 247 | which is typically '---'. Use '===' to indicate that there is no YAML | ||||||||||||||||||||||||||||||||||||||||||
| 248 | header. Enter as many lines as needed. Terminate with a line | ||||||||||||||||||||||||||||||||||||||||||
| 249 | containing just '...'. | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | Shell Commands: (Begin with ':') | ||||||||||||||||||||||||||||||||||||||||||
| 252 | :exit or :q(uit) - leave the shell | ||||||||||||||||||||||||||||||||||||||||||
| 253 | :help - get this help screen | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | END | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | sub check_install { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if (-f "./YAML.pm" && -f "./pm_to_blib" && | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_install: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 1 branch
Condition0%0/6
-f "./YAML.pm" and -f "./pm_to_blib" and -M "./YAML.pm" < -M "./pm_to_blib"
-f "./YAML.pm" and -f "./pm_to_blib"
MC/DC0%0/3
-f "./YAML.pm" and -f "./pm_to_blib" and -M "./YAML.pm" < -M "./pm_to_blib"
-f "./YAML.pm"
-f "./pm_to_blib"
-M "./YAML.pm" < -M "./pm_to_blib"
Truth table0%0/4
A and B and C
A= -f "./YAML.pm"B= -f "./pm_to_blib"C= -M "./YAML.pm" < -M "./pm_to_blib"
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | -M "./YAML.pm" < -M "./pm_to_blib" | ||||||||||||||||||||||||||||||||||||||||||
| 261 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | die "You need to 'make install'!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | sub handle_version { | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | print STDERR <<END; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | ysh: '$VERSION' | ||||||||||||||||||||||||||||||||||||||||||
| 270 | ${yaml_module}: '$yaml_version' | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | END | ||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | sub handle_Version { | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my $TRP = get_version('Term::ReadLine::Perl'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_Version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $TRG = get_version('Term::ReadLine::Gnu'); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $POE = get_version('POE'); | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $TO = get_version('Time::Object'); | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | print STDERR <<END; | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | ysh: '$VERSION' | ||||||||||||||||||||||||||||||||||||||||||
| 284 | ${yaml_module}: '$yaml_version' | ||||||||||||||||||||||||||||||||||||||||||
| 285 | perl: '$Config::Config{version}' | ||||||||||||||||||||||||||||||||||||||||||
| 286 | Data::Dumper: '$Data::Dumper::VERSION' | ||||||||||||||||||||||||||||||||||||||||||
| 287 | Term::ReadLine::Perl: '$TRP' | ||||||||||||||||||||||||||||||||||||||||||
| 288 | Term::ReadLine::Gnu: '$TRG' | ||||||||||||||||||||||||||||||||||||||||||
| 289 | POE: '$POE' | ||||||||||||||||||||||||||||||||||||||||||
| 290 | Time::Object: '$TO' | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | END | ||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | sub get_version { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my ($module) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_version: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $version; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | eval "no strict; use $module; \$version = \$${module}::VERSION"; | |||||||||||||||||||||||||||||||||||||||||
| 299 | #$version = "$@" if $@; | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | $version = "not installed" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return $version; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||