Skip to content

Commit

Permalink
made a few lines with rather dense code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 1, 2012
1 parent 4bbfa21 commit 5af93ee
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@
This file documents the revision history for Perl extension Mojolicious.

2.56 2012-02-29 00:00:00
2.56 2012-03-01 00:00:00
- Removed experimental status from patch function in
Mojolicious::Lite.
- Removed experimental status from patch method in
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Cookie/Response.pm
Expand Up @@ -48,7 +48,8 @@ sub parse {

# Attributes
elsif (my @match = $name =~ $ATTR_RE) {
(my $attr = lc $match[0]) =~ tr/-/_/;
my $attr = lc $match[0];
$attr =~ tr/-/_/;
$cookies[-1]->$attr($attr =~ /(?:Secure|HttpOnly)/i ? 1 : $value);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/IOLoop.pm
Expand Up @@ -143,7 +143,8 @@ sub server {
my $handle = pop;

# Accept
my $id = $self->stream(my $stream = $self->stream_class->new($handle));
my $stream = $self->stream_class->new($handle);
my $id = $self->stream($stream);
$self->$cb($stream, $id);

# Enforce limit
Expand Down
6 changes: 4 additions & 2 deletions lib/Mojo/Message.pm
Expand Up @@ -76,7 +76,8 @@ sub body_params {
# "x-application-urlencoded" and "application/x-www-form-urlencoded"
my $type = $self->headers->content_type || '';
if ($type =~ m#(?:x-application|application/x-www-form)-urlencoded#i) {
return $params if (my $asset = $self->content->asset)->is_file;
my $asset = $self->content->asset;
return $params if $asset->is_file;
$params->parse($asset->slurp);
}

Expand Down Expand Up @@ -480,7 +481,8 @@ sub _parse_formdata {

# Form value
unless (defined $filename) {
next if (my $asset = $part->asset)->is_file;
my $asset = $part->asset;
next if $asset->is_file;
$value = $asset->slurp;
$value = decode($charset, $value) // $value
if $charset && !$part->headers->content_transfer_encoding;
Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -66,7 +66,8 @@ sub run {

# Preload application and configure server
my $daemon = $self->{daemon} = Mojo::Server::Daemon->new;
$self->_config(my $app = $daemon->load_app($ENV{HYPNOTOAD_APP}));
my $app = $daemon->load_app($ENV{HYPNOTOAD_APP});
$self->_config($app);

# Testing
_exit('Everything looks good!') if $ENV{HYPNOTOAD_TEST};
Expand All @@ -92,8 +93,8 @@ sub run {
}

# Start accepting connections
($self->{log} = $app->log)
->info(qq/Hypnotoad server $$ started for "$ENV{HYPNOTOAD_APP}"./);
my $log = $self->{log} = $app->log;
$log->info(qq/Hypnotoad server $$ started for "$ENV{HYPNOTOAD_APP}"./);
$daemon->start;

# Pipe for worker communication
Expand Down
5 changes: 4 additions & 1 deletion lib/Mojo/Server/PSGI.pm
Expand Up @@ -50,7 +50,10 @@ sub run {
}

sub to_psgi_app {
(my $self = shift)->app;
my $self = shift;

# Preload application and wrap it
$self->app;
return sub { $self->run(@_) }
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -296,7 +296,8 @@ sub _connected {
$loop->stream($id)->timeout($self->inactivity_timeout);

# Store connection information in transaction
(my $tx = $self->{connections}->{$id}->{tx})->connection($id);
my $tx = $self->{connections}->{$id}->{tx};
$tx->connection($id);
my $handle = $loop->stream($id)->handle;
$tx->local_address($handle->sockhost)->local_port($handle->sockport);
$tx->remote_address($handle->peerhost)->remote_port($handle->peerport);
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/get.pm
Expand Up @@ -119,7 +119,8 @@ sub run {
# Stream content
$tx->res->body(
sub {
$cb->(my $res = shift);
my $res = shift;
$cb->($res);

# Ignore intermediate content
return if $redirect && $res->is_status_class(300);
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Command/routes.pm
Expand Up @@ -69,7 +69,8 @@ sub _draw {
push @parts, $name . ' ' x ($length[2] - length $name);

# Regex
(my $pattern = $node->[1]->pattern)->match('/');
my $pattern = $node->[1]->pattern;
$pattern->match('/');
my $regex = (regexp_pattern $pattern->regex)[0];
my $format = (regexp_pattern $pattern->format)[0];
my $req = $pattern->reqs->{format};
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Plugin/PODRenderer.pm
Expand Up @@ -72,7 +72,8 @@ sub register {
# Rewrite code sections for syntax highlighting
$dom->find('pre')->each(
sub {
return if (my $e = shift)->all_text =~ /^\s*\$\s+/m;
my $e = shift;
return if $e->all_text =~ /^\s*\$\s+/m;
my $attrs = $e->attrs;
my $class = $attrs->{class};
$attrs->{class} =
Expand Down

0 comments on commit 5af93ee

Please sign in to comment.