Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
increased Perl version requirement to 5.10.1
  • Loading branch information
kraih committed Oct 1, 2011
1 parent d5cf2a1 commit 998a12d
Show file tree
Hide file tree
Showing 75 changed files with 210 additions and 331 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,7 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.

2.0 2011-10-01 00:00:00
2.0 2011-10-02 00:00:00
- Code name "Leaf Fluttering In Wind", this is a major release.
- Increased Perl version requirement to 5.10.1.
- Disabled some more tests on Windows with older Perl versions.
- Improved message parser performance slightly.
- Fixed small formatting bug in Mojo::Headers.
Expand Down
23 changes: 3 additions & 20 deletions Makefile.PL
@@ -1,6 +1,6 @@
#!/usr/bin/env perl

use 5.008007;
use 5.010001;

use strict;
use warnings;
Expand All @@ -12,7 +12,7 @@ use ExtUtils::MakeMaker;
my ($mm) = $ExtUtils::MakeMaker::VERSION =~ /^([^_]+)/;

# We only use core modules, so you shouldn't have to install anything besides
# Perl 5.8.7!
# Perl 5.10.1!
WriteMakefile(
NAME => 'Mojolicious',
VERSION_FROM => 'lib/Mojolicious.pm',
Expand All @@ -25,7 +25,7 @@ WriteMakefile(
? ()
: (
META_MERGE => {
requires => {perl => '5.008007'},
requires => {perl => '5.010001'},
resources => {
homepage => 'http://mojolicio.us',
license => 'http://dev.perl.org/licenses/',
Expand Down Expand Up @@ -83,20 +83,3 @@ WriteMakefile(
},
test => {TESTS => 't/*.t t/*/*.t'}
);

# Using Perl 5.8.x is a bad idea though
warn <<'EOF' unless $] >= 5.010;
*******************************************************************************
You are using Perl 5.8, a version that has reached the end of its life a few
years ago and which is no longer getting updated by the community.
It contains very serious flaws, especially around the regular expression
engine, that will never get fixed and are likely to put your applications at
risk.
While your operating system vendor might keep it compiling on their platform,
they will not fix these issues.
Therefore we highly recommend that you upgrade as soon as possible!
*******************************************************************************
EOF
2 changes: 1 addition & 1 deletion README.pod
Expand Up @@ -29,7 +29,7 @@ I18N, first class unicode support and much more for you to discover.
=item *

Very clean, portable and Object Oriented pure Perl API without any hidden
magic and no requirements besides Perl 5.8.7 (although 5.12+ is recommended,
magic and no requirements besides Perl 5.10.1 (although 5.12+ is recommended,
and optional CPAN modules will be used to provide advanced functionality if
they are installed).

Expand Down
4 changes: 2 additions & 2 deletions examples/connect-proxy.pl
Expand Up @@ -19,7 +19,7 @@
if (my $server = $c->{$client}->{connection}) {
return $loop->write($server, $chunk);
}
$c->{$client}->{client} = '' unless defined $c->{$client}->{client};
$c->{$client}->{client} //= '';
$c->{$client}->{client} .= $chunk if defined $chunk;
if ($c->{$client}->{client} =~ /\x0d?\x0a\x0d?\x0a$/) {
my $buffer = $c->{$client}->{client};
Expand All @@ -32,7 +32,7 @@
port => $port,
on_connect => sub {
my ($loop, $server) = @_;
print "Forwarding to $address:$port.\n";
say "Forwarding to $address:$port.";
$c->{$client}->{connection} = $server;
$loop->write($client,
"HTTP/1.1 200 OK\x0d\x0a"
Expand Down
2 changes: 1 addition & 1 deletion examples/flash-policy-server.pl
Expand Up @@ -34,7 +34,7 @@
}
) or die "Couldn't create listen socket!\n";

print "Starting server on port 843.\n";
say 'Starting server on port 843.';

# Start loop
Mojo::IOLoop->start;
Expand Down
10 changes: 4 additions & 6 deletions lib/Mojo/Asset/File.pm
@@ -1,8 +1,6 @@
package Mojo::Asset::File;
use Mojo::Base 'Mojo::Asset';

# We can't use File::Temp because there is no seek support in the version
# shipped with Perl 5.8
use Carp 'croak';
use Errno;
use Fcntl;
Expand Down Expand Up @@ -65,7 +63,7 @@ sub add_chunk {
$self->handle->sysseek(0, SEEK_END);

# Append to file
$chunk = '' unless defined $chunk;
$chunk //= '';
$self->handle->syswrite($chunk, length $chunk);

return $self;
Expand All @@ -76,7 +74,7 @@ sub contains {

# Seek to start
$self->handle->sysseek($self->start_range, SEEK_SET);
my $end = defined $self->end_range ? $self->end_range : $self->size;
my $end = $self->end_range // $self->size;
my $window_size = length($pattern) * 2;
$window_size = $end - $self->start_range
if $window_size > $end - $self->start_range;
Expand Down Expand Up @@ -184,10 +182,10 @@ Mojo::Asset::File - File asset
my $asset = Mojo::Asset::File->new;
$asset->add_chunk('foo bar baz');
print $asset->slurp;
say $asset->slurp;
my $asset = Mojo::Asset::File->new(path => '/foo/bar/baz.txt');
print $asset->slurp;
say $asset->slurp;
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Asset/Memory.pm
Expand Up @@ -68,7 +68,7 @@ Mojo::Asset::Memory - In-memory asset
my $asset = Mojo::Asset::Memory->new;
$asset->add_chunk('foo bar baz');
print $asset->slurp;
say $asset->slurp;
=head1 DESCRIPTION
Expand Down
12 changes: 5 additions & 7 deletions lib/Mojo/Base.pm
Expand Up @@ -4,7 +4,7 @@ use strict;
use warnings;

# Mojo modules are modern!
require feature if $] >= 5.010;
require feature;

# No imports because we get subclassed, a lot!
require Carp;
Expand Down Expand Up @@ -44,9 +44,7 @@ sub import {
# Mojo modules are strict!
strict->import;
warnings->import;

# Mojo modules are modern!
feature->import(':5.10') if $] >= 5.010;
feature->import(':5.10');
}

sub new {
Expand Down Expand Up @@ -154,11 +152,11 @@ Mojo::Base - Minimal base class for Mojo projects
package main;
my $mew = Cat->new(mouse => 'Mickey');
print $mew->paws;
print $mew->paws(5)->paws;
say $mew->paws;
say $mew->paws(5)->paws;
my $rawr = Tiger->new(stripes => 23);
print $rawr->ears * $rawr->stripes;
say $rawr->ears * $rawr->stripes;
=head1 DESCRIPTION
Expand Down
9 changes: 3 additions & 6 deletions lib/Mojo/ByteStream.pm
Expand Up @@ -139,7 +139,7 @@ sub quote {
sub say {
my ($self, $handle) = @_;
$handle ||= \*STDOUT;
print $handle "$$self\n";
say $handle $$self;
}

sub secure_compare {
Expand Down Expand Up @@ -210,12 +210,12 @@ Mojo::ByteStream - ByteStream
# Manipulate bytestreams
use Mojo::ByteStream;
my $stream = Mojo::ByteStream->new('foo_bar_baz');
print $stream->camelize;
say $stream->camelize;
# Chain methods
my $stream = Mojo::ByteStream->new('foo bar baz')->quote;
$stream = $stream->unquote->encode('UTF-8')->b64_encode;
print "$stream";
say $stream;
# Use the alternative constructor
use Mojo::ByteStream 'b';
Expand Down Expand Up @@ -303,7 +303,6 @@ Turn bytestream into HMAC-MD5 checksum of old content.
$stream = $stream->hmac_sha1_sum($secret);
Turn bytestream into HMAC-SHA1 checksum of old content.
Note that Perl 5.10 or L<Digest::SHA> are required for C<SHA1> support.
=head2 C<html_escape>
Expand Down Expand Up @@ -377,14 +376,12 @@ Constant time comparison algorithm to prevent timing attacks.
$stream = $stream->sha1_bytes;
Turn bytestream into binary SHA1 checksum of old content.
Note that Perl 5.10 or L<Digest::SHA> are required for C<SHA1> support.
=head2 C<sha1_sum>
$stream = $stream->sha1_sum;
Turn bytestream into SHA1 checksum of old content.
Note that Perl 5.10 or L<Digest::SHA> are required for C<SHA1> support.
=head2 C<size>
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Collection.pm
Expand Up @@ -86,7 +86,7 @@ Mojo::Collection - Collection
my $collection = Mojo::Collection->new(qw/just works/);
$collection->map(sub { ucfirst })->each(sub {
my ($word, $count) = @_;
print "$count: $word\n";
say "$count: $word";
});
# Use the alternative constructor
Expand Down Expand Up @@ -118,7 +118,7 @@ Evaluate closure for each element in collection.
$collection->each(sub {
my ($e, $count) = @_;
print "$count: $e\n";
say "$count: $e";
});
=head2 C<first>
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/Command.pm
Expand Up @@ -39,7 +39,7 @@ sub chmod_file {
my ($self, $path, $mod) = @_;
chmod $mod, $path or croak qq/Can't chmod path "$path": $!/;
$mod = sprintf '%lo', $mod;
print " [chmod] $path $mod\n" unless $self->quiet;
say " [chmod] $path $mod" unless $self->quiet;
return $self;
}

Expand Down Expand Up @@ -67,13 +67,13 @@ sub create_dir {

# Exists
if (-d $path) {
print " [exist] $path\n" unless $self->quiet;
say " [exist] $path" unless $self->quiet;
return $self;
}

# Create
File::Path::mkpath($path) or croak qq/Can't make directory "$path": $!/;
print " [mkdir] $path\n" unless $self->quiet;
say " [mkdir] $path" unless $self->quiet;
return $self;
}

Expand Down Expand Up @@ -280,7 +280,7 @@ sub write_file {
croak qq/Can't open file "$path": $!/
unless my $file = IO::File->new("> $path");
$file->syswrite($data);
print " [write] $path\n" unless $self->quiet;
say " [write] $path" unless $self->quiet;

return $self;
}
Expand Down
17 changes: 7 additions & 10 deletions lib/Mojo/Content.pm
Expand Up @@ -81,8 +81,7 @@ sub generate_body_chunk {
}

# Get chunk
my $chunk = $self->{body_buffer};
$chunk = '' unless defined $chunk;
my $chunk = $self->{body_buffer} // '';
$self->{body_buffer} = '';

# EOF or delay
Expand Down Expand Up @@ -169,8 +168,7 @@ sub parse {
if ($self->auto_relax) {
my $headers = $self->headers;
my $connection = $headers->connection || '';
my $len = $headers->content_length;
$len = '' unless defined $len;
my $len = $headers->content_length // '';
$self->relaxed(1)
if !length $len
&& ($connection =~ /close/i || $headers->content_type);
Expand All @@ -195,8 +193,7 @@ sub parse {

# Chunked or relaxed content
if ($self->is_chunked || $self->relaxed) {
$self->{buffer} = '' unless defined $self->{buffer};
$self->$cb($self->{buffer});
$self->$cb($self->{buffer} //= '');
$self->{buffer} = '';
}

Expand Down Expand Up @@ -243,8 +240,8 @@ sub parse_until_body {
my ($self, $chunk) = @_;

# Prepare first buffer
$self->{pre_buffer} = '' unless defined $self->{pre_buffer};
$self->{raw_size} = 0 unless exists $self->{raw_size};
$self->{pre_buffer} //= '';
$self->{raw_size} //= 0;

# Add chunk
if (defined $chunk) {
Expand Down Expand Up @@ -281,7 +278,7 @@ sub write {

# Add chunk
if (defined $chunk) {
$self->{body_buffer} = '' unless defined $self->{body_buffer};
$self->{body_buffer} //= '';
$self->{body_buffer} .= $chunk;
}

Expand Down Expand Up @@ -457,7 +454,7 @@ Callback to be invoked when new content arrives.
$content = $content->on_read(sub {
my ($self, $chunk) = @_;
print $chunk;
say $chunk;
});
=head2 C<relaxed>
Expand Down
5 changes: 1 addition & 4 deletions lib/Mojo/Content/MultiPart.pm
Expand Up @@ -151,10 +151,7 @@ sub _parse_multipart {

# Parse
my $boundary = $self->is_multipart;
while (1) {

# Done
last if $self->is_done;
while (!$self->is_done) {

# Preamble
if (($self->{multi_state} || '') eq 'multipart_preamble') {
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojo/Cookie/Request.pm
Expand Up @@ -26,8 +26,7 @@ sub parse {
else {
push @cookies, Mojo::Cookie::Request->new;
$cookies[-1]->name($name);
$value = '' unless defined $value;
$cookies[-1]->value($value);
$cookies[-1]->value($value //= '');
$cookies[-1]->version($version);
}
}
Expand Down Expand Up @@ -80,7 +79,7 @@ Mojo::Cookie::Request - HTTP 1.1 request cookie container
$cookie->name('foo');
$cookie->value('bar');
print "$cookie";
say $cookie;
=head1 DESCRIPTION
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojo/Cookie/Response.pm
Expand Up @@ -44,8 +44,7 @@ sub parse {
if (not $i) {
push @cookies, Mojo::Cookie::Response->new;
$cookies[-1]->name($name);
$value = '' unless defined $value;
$cookies[-1]->value($value);
$cookies[-1]->value($value //= '');
next;
}

Expand Down Expand Up @@ -120,7 +119,7 @@ Mojo::Cookie::Response - HTTP 1.1 response cookie container
$cookie->name('foo');
$cookie->value('bar');
print "$cookie";
say $cookie;
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/CookieJar.pm
Expand Up @@ -28,7 +28,7 @@ sub add {

# Check cookie size
my $value = $cookie->value;
next if length(defined $value ? $value : '') > $self->max_cookie_size;
next if length($value //= '') > $self->max_cookie_size;

# Check if we already have a similar cookie
$domain =~ s/^\.//;
Expand Down

0 comments on commit 998a12d

Please sign in to comment.