Skip to content

Commit

Permalink
use spurt in Mojo::Asset::Memory
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 16, 2012
1 parent d670f15 commit 51a0787
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
7 changes: 2 additions & 5 deletions lib/Mojo/Asset/File.pm
Expand Up @@ -120,15 +120,12 @@ sub move_to {
my ($self, $to) = @_;

# Windows requires that the handle is closed
close $self->handle;
delete $self->{handle};
close delete $self->{handle};

# Move file and prevent clean up
my $from = $self->path;
move($from, $to) or croak qq{Can't move file "$from" to "$to": $!};
$self->path($to)->cleanup(0);

return $self;
return $self->path($to)->cleanup(0);
}

sub size {
Expand Down
7 changes: 2 additions & 5 deletions lib/Mojo/Asset/Memory.pm
@@ -1,9 +1,8 @@
package Mojo::Asset::Memory;
use Mojo::Base 'Mojo::Asset';

use Carp 'croak';
use IO::Handle;
use Mojo::Asset::File;
use Mojo::Util 'spurt';

has 'auto_upgrade';
has max_memory_size => sub { $ENV{MOJO_MAX_MEMORY_SIZE} || 262144 };
Expand Down Expand Up @@ -48,9 +47,7 @@ sub get_chunk {

sub move_to {
my ($self, $path) = @_;
croak qq{Can't open file "$path": $!} unless open my $file, '>', $path;
croak qq{Can't write to file "$path": $!}
unless defined $file->syswrite($self->{content});
spurt $self->{content}, $path;
return $self;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Content.pm
Expand Up @@ -578,13 +578,13 @@ Parse content chunk.
=head2 C<parse_body>
$content = $content->parse_body("Hi!");
$content = $content->parse_body('Hi!');
Parse body chunk.
=head2 C<parse_body_once>
$content = $content->parse_body_once("Hi!");
$content = $content->parse_body_once('Hi!');
Parse body chunk once.
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojo/Log.pm
Expand Up @@ -96,11 +96,11 @@ Mojo::Log - Simple logger
my $log = Mojo::Log->new(path => '/var/log/mojo.log', level => 'warn');
# Log messages
$log->debug("Why isn't this working?");
$log->info("FYI: it happened again");
$log->warn("This might be a problem");
$log->error("Garden variety error");
$log->fatal("Boom!");
$log->debug('Why isn't this working?');
$log->info('FYI: it happened again');
$log->warn('This might be a problem');
$log->error('Garden variety error');
$log->fatal('Boom!');
=head1 DESCRIPTION
Expand Down
1 change: 0 additions & 1 deletion lib/Mojolicious/Command.pm
Expand Up @@ -6,7 +6,6 @@ use Cwd 'getcwd';
use File::Basename 'dirname';
use File::Path 'mkpath';
use File::Spec::Functions qw(catdir catfile);
use IO::Handle;
use Mojo::Loader;
use Mojo::Server;
use Mojo::Template;
Expand Down

0 comments on commit 51a0787

Please sign in to comment.