diff --git a/Changes b/Changes index 6958fbf..e12f33a 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,9 @@ Revision history for App-Rak --csv-per-line, which now will assume a header line in the CSV file per default, and will produce hashes per line, keyed to the column name. + - Added some basic --csv-per-line author tests + - Fix issue with --type= information not being authoritative, + spotted by Márton Polgár 0.2.6 2022-11-14T18:15:53+01:00 - Bump dependency on rak to get "is-text" support diff --git a/lib/App/Rak.rakumod b/lib/App/Rak.rakumod index 49f965a..a1caef0 100644 --- a/lib/App/Rak.rakumod +++ b/lib/App/Rak.rakumod @@ -501,7 +501,7 @@ my sub pre-process($pattern) { && $pattern.chars > 2 { non-word(my $target := $pattern.substr(1,*-1).trim) ?? $pattern - !! $target but Type + !! $target but Type # avoid using regex for / foo / } elsif $pattern.starts-with('^') { $pattern.ends-with('$') @@ -515,7 +515,7 @@ my sub pre-process($pattern) { $pattern.substr(1) but Type } else { - $pattern but Type + $pattern # could be some other pattern to interprete } } elsif $type eq 'regex' { @@ -527,7 +527,7 @@ my sub pre-process($pattern) { '{' ~ $pattern ~ '}' } - # some other known type + # some other known type, don't interprete else { $pattern but Type($type) } @@ -536,7 +536,8 @@ my sub pre-process($pattern) { # Convert a string to code if possible, adhering to type my sub codify(Str:D $code) { CATCH { - meh "Could not compile '$code':\n$_.message()"; + meh "Could not compile '$code':\n$_.message()" + unless %rak; } # Return prelude from --repository and --module parameters @@ -554,7 +555,7 @@ my sub codify(Str:D $code) { ?? (prelude() ~ 'my $ := ' ~ $code).EVAL !! $code.starts-with('*') && $code.chars > 1 ?? (prelude() ~ 'my $ := ' ~ $code).EVAL - !! $code + !! $code but Type('contains') } # Pre-process literal strings looking like a regex @@ -3481,7 +3482,6 @@ my sub codify-pattern-matches-only($pattern) { # Prepare the executable needle my sub prepare-needle() { - if $pattern { if $smartcase { $ignorecase.defined @@ -3496,19 +3496,26 @@ my sub prepare-needle() { # multiple patterns if List.ACCEPTS($pattern) { + my $matches-only := %result:delete; + $pattern := $pattern.map(&pre-process).List; - $needle := $pattern.map(%result:delete - ?? &codify-pattern-matches-only - !! &codify-pattern - ).List; + $needle := $pattern.map({ + .can('type') + ?? needleify($_) + !! $matches-only + ?? codify-pattern-matches-only($_) + !! codify-pattern($_) + }).List } # a single pattern else { $pattern := pre-process $pattern; - $needle := %result:delete - ?? codify-pattern-matches-only($pattern) - !! codify-pattern($pattern) + $needle := $pattern.can('type') + ?? needleify($pattern) + !! (%result:delete) + ?? codify-pattern-matches-only($pattern) + !! codify-pattern($pattern) } }