Skip to content

Commit

Permalink
tweaked asset bundling recipe a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 13, 2012
1 parent 6f52bdc commit 2d07fd2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 174 deletions.
168 changes: 0 additions & 168 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -67,77 +67,12 @@ sub client {
}
);

# DEPRECATED in Leaf Fluttering In Wind!
$args->{timeout} ||= $self->{connect_timeout};

# Connect
$client->connect($args);

return $id;
}

# DEPRECATED in Leaf Fluttering In Wind!
sub connect {
my $self = shift;
$self = $self->singleton unless ref $self;
my $args = ref $_[0] ? $_[0] : {@_};
warn
"Mojo::IOLoop->connect is DEPRECATED in favor of Mojo::IOLoop->client!\n";

my $id;
$id = $self->client(
$args => sub {
my ($self, $err, $stream) = @_;

my $c = $self->{connections}->{$id};
$c->{$_} = delete($args->{"on_$_"}) || $c->{$_}
for qw/close connect error read/;
if ($err) {
$c->{error}->($self, $id, $err) if $c->{error};
return;
}

$stream->on(
close => sub {
my $c = $self->{connections}->{$id};
$c->{close}->($self, $id) if $c->{close};
}
);
$stream->on(
error => sub {
my $c = $self->{connections}->{$id};
$c->{error}->($self, $id, pop) if $c->{error};
}
);
$stream->on(
read => sub {
my $c = $self->{connections}->{$id};
$c->{read}->($self, $id, pop) if $c->{read};
}
);
$c->{connect}->($self, $id) if $c->{connect};
}
);

return $id;
}

# DEPRECATED in Leaf Fluttering In Wind!
sub connect_timeout {
my ($self, $timeout) = @_;
warn <<EOF;
Mojo::IOLoop->connect_timeout is DEPRECATED in favor of the timeout argument!
EOF
if ($timeout) {
$self->{connect_timeout} = $timeout;
return $self;
}
return $self->{connect_timeout};
}

# DEPRECATED in Leaf Fluttering In Wind!
*connection_timeout = \&timeout;

sub delay {
my ($self, $cb) = @_;
$self = $self->singleton unless ref $self;
Expand Down Expand Up @@ -165,74 +100,6 @@ sub is_running {
return $self->{running};
}

# DEPRECATED in Leaf Fluttering In Wind!
sub listen {
my $self = shift;
$self = $self->singleton unless ref $self;
my $args = ref $_[0] ? $_[0] : {@_};
warn
"Mojo::IOLoop->listen is DEPRECATED in favor of Mojo::IOLoop->server!\n";

my $accept = delete $args->{on_accept};
my $close = delete $args->{on_close};
my $error = delete $args->{on_error};
my $read = delete $args->{on_read};
my $id;
$id = $self->server(
$args => sub {
my ($self, $stream, $id) = @_;

my $c = $self->{connections}->{$id};
$c->{close} = $close if $close;
$c->{error} = $error if $error;
$c->{read} = $read if $read;
$stream->on(
close => sub {
my $c = $self->{connections}->{$id};
$c->{close}->($self, $id) if $c->{close};
}
);
$stream->on(
error => sub {
my $c = $self->{connections}->{$id};
$c->{error}->($self, $id, pop) if $c->{error};
}
);
$stream->on(
read => sub {
my $c = $self->{connections}->{$id};
$c->{read}->($self, $id, pop) if $c->{read};
}
);
$self->$accept($id) if $accept;
}
);

return $id;
}

# DEPRECATED in Leaf Fluttering In Wind!
sub on_close { shift->_event(close => @_) }
sub on_error { shift->_event(error => @_) }

# DEPRECATED in Leaf Fluttering In Wind!
sub on_lock {
warn
"Mojo::IOLoop->on_lock is DEPRECATED in favor of Mojo::IOLoop->lock!\n";
shift->lock(@_);
}

# DEPRECATED in Leaf Fluttering In Wind!
sub on_read { shift->_event(read => @_) }

# DEPRECATED in Leaf Fluttering In Wind!
sub on_unlock {
warn <<EOF;
Mojo::IOLoop->on_unlock is DEPRECATED in favor of Mojo::IOLoop->unlock!
EOF
shift->unlock(@_);
}

sub one_tick {
my $self = shift;
$self = $self->singleton unless ref $self;
Expand Down Expand Up @@ -351,39 +218,13 @@ sub stream {
return $id;
}

# DEPRECATED in Leaf Fluttering In Wind!
sub timeout {
warn <<EOF;
Mojo::IOLoop->timeout is DEPRECATED in favor of
Mojo::IOLoop::Stream->timeout!
EOF
my ($self, $id, $timeout) = @_;
$self = $self->singleton unless ref $self;
return unless my $stream = $self->stream($id);
return $stream->timeout unless defined $timeout;
$stream->timeout($timeout);
return $self;
}

sub timer {
my ($self, $after, $cb) = @_;
$self = $self->singleton unless ref $self;
weaken $self;
return $self->iowatcher->timer($after => sub { $self->$cb(pop) });
}

# DEPRECATED in Leaf Fluttering In Wind!
sub write {
my ($self, $id, $chunk, $cb) = @_;
warn <<EOF;
Mojo::IOLoop->write is DEPRECATED in favor of Mojo::IOLoop::Stream->write!
EOF
return unless my $stream = $self->stream($id);
return $stream->write($chunk) unless $cb;
weaken $self;
return $stream->write($chunk, sub { $self->$cb($id) });
}

sub _drop {
my ($self, $id) = @_;

Expand All @@ -401,15 +242,6 @@ sub _drop {
}
}

# DEPRECATED in Leaf Fluttering In Wind!
sub _event {
my ($self, $event, $id, $cb) = @_;
warn "Mojo::IOLoop->on_* methods are DEPRECATED!\n";
return unless my $c = $self->{connections}->{$id};
$c->{$event} = $cb if $cb;
return $self;
}

sub _id {
my $self = shift;
my $id;
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -642,9 +642,9 @@ C<register> is called.
my ($self, $app) = @_;

# Append "templates" and "public" directories
my $home = catdir(dirname(__FILE__), 'AlertAssets');
push @{$app->renderer->paths}, catdir($home, 'templates');
push @{$app->static->paths}, catdir($home, 'public');
my $base = catdir(dirname(__FILE__), 'AlertAssets');
push @{$app->renderer->paths}, catdir($base, 'templates');
push @{$app->static->paths}, catdir($base, 'public');
}

1;
Expand Down
5 changes: 2 additions & 3 deletions t/pod_coverage.t
Expand Up @@ -9,9 +9,8 @@ plan skip_all => 'set TEST_POD to enable this test (developer only!)'

# DEPRECATED in Leaf Fluttering In Wind!
my @leaf = (
qw/comment connect connection_timeout keep_alive_timeout listen/,
qw/max_redirects on_close on_error on_lock on_process on_read on_unlock/,
qw/port prepare_ioloop root timeout version write x_forwarded_for/
qw/comment keep_alive_timeout max_redirects on_process port/,
qw/prepare_ioloop root version x_forwarded_for/
);

# "Marge, I'm going to miss you so much. And it's not just the sex.
Expand Down

0 comments on commit 2d07fd2

Please sign in to comment.