Skip to content

Commit

Permalink
0.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Aug 19, 2024
1 parent c07b85c commit 34f847b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Revision history for App-Rak

{{$NEXT}}

0.3.10 2024-08-19T16:01:23+02:00
- Make --per-paragraph and --modify-files work properly
without eating whitespace between paragraphs
- Bump dependency on String::Utils to get "paragraphs" fix
so that --per-paragraph and --modify-files will work
properly

0.3.9 2024-08-19T12:14:12+02:00
- Add support for --also-first to produce the first N lines
Expand Down
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
],
"test-depends": [
],
"version": "0.3.9"
"version": "0.3.10"
}
55 changes: 55 additions & 0 deletions lib/App/Rak.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -3145,6 +3145,61 @@ my sub action-modify-files(--> Nil) {
}
}
# Producing haystacks per line
elsif %rak<produce-many-pairs> {
my @changed-files;
my int $nr-files-seen;
my int $nr-paragraphs-changed;
%rak<passthru-context> := %listing<passthru-context>:delete // True;
%rak<mapper> := -> $io, @matches --> Empty {
++$nr-files-seen;
LAST {
my int $nr-files-changed = @changed-files.elems;
my $fb = "Processed $nr-files-seen file&s($nr-files-seen)";
$fb ~= ", $nr-files-changed file&s($nr-files-changed) changed"
if $nr-files-changed;
$fb ~= ", $nr-paragraphs-changed line&s($nr-paragraphs-changed) changed"
if $nr-paragraphs-changed;
if $verbose {
$fb ~= "\n";
for @changed-files -> ($io, $changed) {
$fb ~= "$io.relative():";
$fb ~= " $changed change&s($changed)" if $changed;
$fb ~= "\n";
}
$fb .= chomp;
$fb ~= no-changes if $dryrun;
}
elsif $dryrun {
$fb ~= no-changes;
}
sayer $fb;
}
my int $paragraphs-changed;
for @matches {
++$paragraphs-changed if .changed;
}
if $paragraphs-changed {
unless $dryrun {
if $backup {
$io.spurt(@matches.map(*.value).join("\n"))
if $io.rename($io.sibling($io.basename ~ $backup));
}
else {
$io.spurt: @matches.map(*.value).join("\n");
}
}
$nr-paragraphs-changed += $paragraphs-changed;
@changed-files.push: ($io, $paragraphs-changed);
}
}
}
# Producing haystacks per line
else {
my @changed-files;
Expand Down

0 comments on commit 34f847b

Please sign in to comment.