my $root_link = base_path('link'); #### my $magic = crossover_magic( big => ['Horror']); my $magic = crossover_magic( big => ['Westerns in Crisis']); #### #!/usr/bin/env perl use 5.028_001; use warnings; use Test::More; my @cross_files = @{_get_cross_files()}; my @expected_textified = @{_get_expected_textified()}; plan tests => @cross_files * 7; for (my $i = 0; $i <= $#cross_files; ++$i) { my $got_textified = textify($cross_files[$i]); is($got_textified, $expected_textified[$i], "Test '$cross_files[$i]' --> '$expected_textified[$i]'" ); { my $class = cutdown_crossover_magic($cross_files[$i]); is($class, 'svg_group right', "Test cross_file '$cross_files[$i]' with no 'big' key"); } { my $class = cutdown_crossover_magic($expected_textified[$i]); is($class, 'svg_group right', "Test expected_textified '$expected_textified[$i]' with no 'big' key"); } { my $class = cutdown_crossover_magic($got_textified); is($class, 'svg_group right', "Test got_textified '$got_textified' with no 'big' key"); } { my $class = cutdown_crossover_magic($cross_files[$i], big => [$cross_files[$i]]); is($class, 'svg_group', "Test cross_file '$cross_files[$i]' using 'big' key"); } { my $class = cutdown_crossover_magic($expected_textified[$i], big => [$expected_textified[$i]]); is($class, 'svg_group', "Test expected_textified '$expected_textified[$i]' using 'big' key"); } { my $class = cutdown_crossover_magic($got_textified, big => [$got_textified]); is($class, 'svg_group', "Test got_textified '$got_textified' using 'big' key"); } } sub cutdown_crossover_magic { my ($cross_file, %opt) = @_; my $class = 'svg_group'; my @big_images = $opt{big} ? @{$opt{big}} : (); my $text = textify($cross_file); $class .= ' right' unless grep(/$text/i, @big_images); return $class; } sub _get_cross_files { [ 'key.svg', 'Spy_Machete.svg', 'Two_Half_Bang.svg', 'McHale_UNCLE_Smart.svg', 'Howling_Gremlins.svg', 'Dragnet.svg', 'View_Scream.svg', 'blank_spinoff.svg', 'Westphall.png', 'Westerns_in_Crisis.svg', 'Mary_Tyler_Moore.svg', 'Better_Fast.svg', 'Terminator_Abyss.svg', 'Frozen_Hatchet.svg', 'Babylon_5_Cases.svg', 'Columbo.svg', 'crossover_archive.zip', 'Burkes_Law.svg', 'temp.svg', 'Westphall.svg', 'Arriving_to_Westphall.svg', 'key-big.svg', 'Departing_from_Westphall.svg', 'MCU.svg', 'Horror.svg', 'Alices_Hazzard.svg' ]; } sub _get_expected_textified { [ 'key', 'Spy Machete', 'Two Half Bang', 'McHale UNCLE Smart', 'Howling Gremlins', 'Dragnet', 'View Scream', 'blank spinoff', 'Westphall', 'Westerns in Crisis', 'Mary Tyler Moore', 'Better Fast', 'Terminator Abyss', 'Frozen Hatchet', 'Babylon 5 Cases', 'Columbo', 'crossover archive', 'Burkes Law', 'temp', 'Westphall', 'Arriving to Westphall', 'key-big', 'Departing from Westphall', 'MCU', 'Horror', 'Alices Hazzard' ]; } # Exactly as posted EXCEPT both '$root_link' lines have been commented out sub textify { my ($text, $opt) = @_; #my $root_link = base_path('link'); #$text =~ s/$root_link\///; # removes the $root_link $text =~ s/_/ /g; # removes undersores $text =~ s/ (Mr|Mrs|Ms|Dr) / $1. /g; # adds a period for Mr, Mrs, Ms, and Dr; I may need to add more $text =~ s/\s&\s/ & /g; # converts ' & ' to & $text =~ s/\.{3}/…/g; # converts '...' to … $text =~ s/(\w|\b|\s|^)'(\w|\b|\s|$)/$1ʼ$2/g; # converts "'" to ʼ # The following takes out html tags unless I tell it not to $text =~ s/<.+?>//g unless ($opt->{'html'} && $opt->{'html'} =~ /^[ytk1]/); # The following takes out parenthes unless I tell it not to $text =~ s/\s\(.*?\)$// unless ($opt->{'parens'} && $opt->{'parens'} =~ /^[ytk1]/); # The following removes file extensions except .com, .net, and .org $text =~ s/\.\w{2,5}?$// unless $text =~ /\.(?:com|net|org)$/; # $text =~ s/(?