]> www.fi.muni.cz Git - aoc.git/commitdiff
Input downloader: use spew() instead of spurt()
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 8 Dec 2023 08:07:36 +0000 (09:07 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 8 Dec 2023 08:08:39 +0000 (09:08 +0100)
get
lib/Y/AoC/UA.pm

diff --git a/get b/get
index 13a39df2bfc7fef0fe516323a233ff9fd38c576c..0ed27282bae0c9d080a921ac05130990fd77b368 100755 (executable)
--- 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";
index 725832406839ec5cc230add3ead9b4467d2184a9..966878a535f9b2f3dfc2fd528eb7e900ac89d03a 100644 (file)
@@ -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;