From dcb860dd4089c635c9d7414a631ba183d80e013b Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Fri, 8 Dec 2023 09:07:36 +0100 Subject: [PATCH] Input downloader: use spew() instead of spurt() --- get | 4 ++-- lib/Y/AoC/UA.pm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/get b/get index 13a39df..0ed2728 100755 --- a/get +++ b/get @@ -46,7 +46,7 @@ if ($sleep) { say "Downloading $url to $dest"; my $data = Y::AoC::UA::request($url, { body => 1 }); -Mojo::File->new($dest)->spurt($data); +Mojo::File->new($dest)->spew($data); say grey('=================================================='); print $data; say grey('=================================================='); @@ -59,5 +59,5 @@ $dest = $task.'test.txt'; my $tst = Y::AoC::UA::request($url, { cache_to => "task-$year-$day.html" }) ->find('main > article > pre > code')->first->all_text; -Mojo::File->new($dest)->spurt($tst); +Mojo::File->new($dest)->spew($tst); say "\n", grey("also downloaded $dest"), "\n"; diff --git a/lib/Y/AoC/UA.pm b/lib/Y/AoC/UA.pm index 7258324..966878a 100644 --- a/lib/Y/AoC/UA.pm +++ b/lib/Y/AoC/UA.pm @@ -5,7 +5,7 @@ use v5.36; use Mojo::Base -signatures; use Mojo::UserAgent; use Mojo::DOM; -use Y::AoC qw(white); +use Y::AoC qw(white red); our $user_agent = 'kas@yenya.net https://www.fi.muni.cz/~kas/git/aoc.git'; our $cache_dir = '/home/kas/aoc/cache'; @@ -55,7 +55,7 @@ sub request($url, $args) { } if ($cache) { - $cache->spurt($res->body); + $cache->spew($res->body); # say "Stored response to $cachefile"; } return $args->{body} ? $res->body : $res->dom; -- 2.43.0