Skip to content

Commit

Permalink
Merge pull request #149 from okurz/fix/spew
Browse files Browse the repository at this point in the history
Adapt to deprecation of spurt in upstream Mojolicious
  • Loading branch information
kraih authored Jun 20, 2024
2 parents 1aa3eef + f74ba26 commit ed42ad0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ WriteMakefile(
ABSTRACT_FROM => 'lib/Mojolicious/Plugin/AssetPack.pm',
VERSION_FROM => 'lib/Mojolicious/Plugin/AssetPack.pm',
TEST_REQUIRES => {'Test::More' => '0.88'},
PREREQ_PM => {'File::Which' => '1.21', 'IPC::Run3' => '0.048', 'Mojolicious' => '9.0'},
PREREQ_PM => {'File::Which' => '1.21', 'IPC::Run3' => '0.048', 'Mojolicious' => '9.34'},
META_MERGE => {
'dynamic_config' => 0,
'meta-spec' => {version => 2},
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugin/AssetPack/Pipe/RollupJs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ has _rollupjs => sub {
$self->{_rollupjs_src} = tempfile(SUFFIX => '.js');
}

$self->{_rollupjs_src}->spurt($bin);
$self->{_rollupjs_src}->spew($bin);

return [$self->_find_app([qw(nodejs node)]), $self->{_rollupjs_src}->realpath];
};
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Plugin/AssetPack/Store.pm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ sub save {

return $self->asset_class->new(%$attrs, content => $$ref) unless -w $dir;

$path->spurt($$ref);
$path->spew($$ref);
$self->_db_set(%$attrs);
return $self->asset_class->new(%$attrs, path => $path);
}
Expand Down Expand Up @@ -288,7 +288,7 @@ sub _download {
$path = path($self->paths->[0], $self->_url2path($attrs{url}, $attrs{format}));
$self->_log->info(qq(Caching "$url" to "$path".));
$path->dirname->make_path unless -d $path->dirname;
$path->spurt($tx->res->body);
$path->spew($tx->res->body);
}

$attrs{url} = "$attrs{url}";
Expand Down
6 changes: 3 additions & 3 deletions t/Helper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ END { cleanup() }
my %CREATED_FILES;

unless ($ENV{TEST_KEEP_FILES}) {
my $spurt = \&Mojo::File::spurt;
my $spew = \&Mojo::File::spew;
Mojo::Util::monkey_patch(
'Mojo::File' => spurt => sub {
'Mojo::File' => spew => sub {
$CREATED_FILES{$_[0]} = 1 unless -e $_[0];
goto $spurt;
goto $spew;
}
);
}
Expand Down
6 changes: 3 additions & 3 deletions t/recreate.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ my $t = t::Helper->t(pipes => [qw(Css Combine)]);
my @assets = qw(one.css recreate.css);
my $recreate = path(qw(t assets recreate.css));

$recreate->spurt(".recreate { color: #aaa }\n");
$recreate->spew(".recreate { color: #aaa }\n");

$t->app->asset->process('app.css' => @assets);

Expand All @@ -28,15 +28,15 @@ $t->get_ok('/')->status_is(200);
is $t->tx->res->dom->at('link')->{href}, $link, 'same link href';

# recreate
$recreate->spurt(".recreate { color: #bbb }\n");
$recreate->spew(".recreate { color: #bbb }\n");
my $tr = t::Helper->t(pipes => [qw(Css Combine)]);
$tr->app->asset->process('app.css' => @assets);
$tr->get_ok('/')->status_is(200);
isnt $tr->tx->res->dom->at('link')->{href}, $link, 'changed link href';
$tr->get_ok($tr->tx->res->dom->at('link')->{href})->status_is(200)->content_like(qr{color:\#bbb});

# reset asset
$recreate->spurt(".recreate { color: #aaa }\n");
$recreate->spew(".recreate { color: #aaa }\n");

done_testing;
__DATA__
Expand Down

0 comments on commit ed42ad0

Please sign in to comment.