From 6058b309a43fd5f7f4f3b5bc3005dd6de7b15747 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Sun, 18 Aug 2024 12:42:05 +0200 Subject: [PATCH] 0.3.6 --- Changes | 8 ++++++++ META6.json | 6 +++--- README.md | 5 +++++ doc/App-Rak.rakudoc | 7 +++++++ lib/App/Rak.rakumod | 23 +++++++++++++++++++---- xt/01-simple.rakutest | 10 ++++++++++ 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index 4ee2668..92f4bc3 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,14 @@ Revision history for App-Rak {{$NEXT}} +0.3.6 2024-08-18T12:40:54+02:00 + - Add support for --per-paragraph to produce haystacks + per paragraph, rather than by line or the whole file + - Bump dependency on String::Utils to get "paragraphs" + with :Pair named argument + - Bump dependency on rak to get ":produce-many-pairs" + functionality + 0.3.5 2024-08-17T19:49:18+02:00 - Separate "producer" logic from "action" logic, to allow e.g. --per-file and --modify-files to be combined diff --git a/META6.json b/META6.json index d36434b..b158595 100644 --- a/META6.json +++ b/META6.json @@ -14,8 +14,8 @@ "JSON::Fast::Hyper:ver<0.0.7>:auth", "META::constants:ver<0.0.4>:auth", "Needle::Compile:ver<0.0.7>:auth", - "rak:ver<0.0.59>:auth", - "String::Utils:ver<0.0.25+>:auth" + "rak:ver<0.0.60>:auth", + "String::Utils:ver<0.0.27+>:auth" ], "description": "21st century grep / find / ack / ag / rg on steroids", "license": "Artistic-2.0", @@ -59,5 +59,5 @@ ], "test-depends": [ ], - "version": "0.3.5" + "version": "0.3.6" } diff --git a/README.md b/README.md index 72ea5c7..1b6a1bc 100644 --- a/README.md +++ b/README.md @@ -1392,6 +1392,11 @@ Optionally takes a `Callable` specification: this will be given an `IO::Path` ob $ rak foo --per-line='*.lines.tail(10)' ``` +--per-paragraph +--------------- + +Indicate whether matching should be done per paragraph. It will read lines with the indicated `--encoding`, combine them into paragraphs and present each paragraph to the matcher, with the line number of the start of the paragraphs associated with it. + --progress ---------- diff --git a/doc/App-Rak.rakudoc b/doc/App-Rak.rakudoc index 87fb29c..c4fc647 100644 --- a/doc/App-Rak.rakudoc +++ b/doc/App-Rak.rakudoc @@ -1764,6 +1764,13 @@ $ rak foo --per-line='*.lines.tail(10)' =end code +=head2 --per-paragraph + +Indicate whether matching should be done per paragraph. It will read lines +with the indicated C<--encoding>, combine them into paragraphs and present +each paragraph to the matcher, with the line number of the start of the +paragraphs associated with it. + =head2 --progress Flag. If specified, will produce a progress indicator on STDERR that diff --git a/lib/App/Rak.rakumod b/lib/App/Rak.rakumod index 9fb755e..1de68de 100644 --- a/lib/App/Rak.rakumod +++ b/lib/App/Rak.rakumod @@ -3,7 +3,7 @@ use as-cli-arguments:ver<0.0.8>:auth; # as-cli-arguments use IO::Path::AutoDecompress:ver<0.0.3>:auth; # IOAD use JSON::Fast::Hyper:ver<0.0.7>:auth; # from-json to-json use META::constants:ver<0.0.4>:auth $?DISTRIBUTION; -use rak:ver<0.0.59>:auth; # rak Rak +use rak:ver<0.0.60>:auth; # rak Rak use Backtrace::Files:ver<0.0.4>:auth < backtrace-files @@ -14,7 +14,7 @@ use highlighter:ver<0.0.21>:auth < use Needle::Compile:ver<0.0.7>:auth < compile-needle implicit2explicit StrType Type >; -use String::Utils:ver<0.0.26+>:auth < +use String::Utils:ver<0.0.27+>:auth < after before between has-marks is-sha1 non-word paragraphs regexify >; @@ -31,9 +31,9 @@ my constant BON = "\e[1m"; # BOLD ON my constant BOFF = "\e[22m"; # BOLD OFF #- start of available options -------------------------------------------------- -#- Generated on 2024-08-16T19:20:19+02:00 by tools/makeOPTIONS.raku +#- Generated on 2024-08-17T22:09:15+02:00 by tools/makeOPTIONS.raku #- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE -my str @options = ; +my str @options = ; #- PLEASE DON'T CHANGE ANYTHING ABOVE THIS LINE #- end of available options ---------------------------------------------------- @@ -2088,6 +2088,21 @@ my sub option-per-line($value --> Nil) { } } +my sub option-per-paragraph($value --> Nil) { + if Bool.ACCEPTS($value) { + if $value { + set-producer( + 'per-line', + -> $io { paragraphs($io.lines, 1, :Pair(PairContext)) }, + 'produce-many-pairs' + ); + } + } + else { + meh "Can only specify '--per-paragraph' as a flag"; + } +} + my sub option-progress($value --> Nil) { my $ERR := PROCESS::<$ERR>; diff --git a/xt/01-simple.rakutest b/xt/01-simple.rakutest index 43d4e8e..fcab111 100644 --- a/xt/01-simple.rakutest +++ b/xt/01-simple.rakutest @@ -835,6 +835,16 @@ nine 7:SIX OK +query-ok <--per-paragraph five --and=nine>, :!head, ok => qq:to/OK/; +nine +5:four +{BON}five{BOFF} +SIX +seven +eight +{BON}nine{BOFF} +OK + done-testing; # vim: expandtab shiftwidth=4