| 1 | package Sisimai::Fact::YAML; | ||||||||||||||||||||
| 2 | 80 | ▶ | use v5.26; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 80 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 80 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 704 | ▶ | sub dump { | ||||||||||||||||||
|
Subroutine
dump: called CC=7 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||
| 7 | # Data dumper(YAML) | ||||||||||||||||||||
| 8 | # @param [Sisimai::Fact] argvs Object | ||||||||||||||||||||
| 9 | # @return [String] Dumped data or an empty string if the argument is missing | ||||||||||||||||||||
| 10 | 704 | my $class = shift; | |||||||||||||||||||
| 11 | 704 | ▶ | my $argvs = shift // return ""; return "" if ref $argvs ne 'Sisimai::Fact'; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift() // (return "")
MC/DC0%0/1
shift() // (return "")
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||
| 12 | 704 | my $damneddata = undef; | |||||||||||||||||||
| 13 | 704 | my $modulename = undef; | |||||||||||||||||||
| 14 | 704 | my $yamlstring = ""; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 704 | eval { | |||||||||||||||||||
| 17 | 704 | require YAML; | |||||||||||||||||||
| 18 | 704 | $modulename = 'YAML'; | |||||||||||||||||||
| 19 | }; | ||||||||||||||||||||
| 20 | 704 | ▶ | if( $@ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | # Try to load YAML::Syck | ||||||||||||||||||||
| 22 | 0 | eval { | |||||||||||||||||||
| 23 | 0 | require YAML::Syck; | |||||||||||||||||||
| 24 | 0 | $modulename = 'YAML::Syck'; | |||||||||||||||||||
| 25 | }; | ||||||||||||||||||||
| 26 | 0 | ▶ | die ' ***error: Neither "YAML" nor "YAML::Syck" module is installed' if $@; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 704 | $damneddata = $argvs->damn; | |||||||||||||||||||
| 30 | 704 | ▶ | if( $modulename eq 'YAML' ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | # Use YAML module | ||||||||||||||||||||
| 32 | 704 | local $YAML::SortKeys = 1; | |||||||||||||||||||
| 33 | 704 | local $YAML::Stringify = 0; | |||||||||||||||||||
| 34 | 704 | local $YAML::UseHeader = 1; | |||||||||||||||||||
| 35 | 704 | local $YAML::UseBlock = 0; | |||||||||||||||||||
| 36 | 704 | local $YAML::CompressSeries = 0; | |||||||||||||||||||
| 37 | 704 | $yamlstring = YAML::Dump($damneddata); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | } elsif( $modulename eq 'YAML::Syck' ) { | ||||||||||||||||||||
| 40 | # Use YAML::Syck module instead of YAML module. | ||||||||||||||||||||
| 41 | 0 | local $YAML::Syck::ImplicitTyping = 1; | |||||||||||||||||||
| 42 | 0 | local $YAML::Syck::Headless = 0; | |||||||||||||||||||
| 43 | 0 | local $YAML::Syck::ImplicitUnicode = 1; | |||||||||||||||||||
| 44 | 0 | local $YAML::Syck::SingleQuote = 0; | |||||||||||||||||||
| 45 | 0 | local $YAML::Syck::SortKeys = 1; | |||||||||||||||||||
| 46 | 0 | $yamlstring = YAML::Syck::Dump($damneddata); | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 704 | return $yamlstring; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 80 | 1; | |||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||