Skip to content

Commit

Permalink
documentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 11, 2013
1 parent f0e26bd commit ae7e983
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 39 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,9 +1,10 @@

3.77 2013-01-11
3.77 2013-01-12
- Added support for advanced binary WebSocket message tests to Test::Mojo.
- Added binary and text events to Mojo::Transaction::WebSocket.
- Added json_message_content_is method to Test::Mojo.
- Added j function to Mojo::JSON.
- Improved documentation.
- Improved tests.
- Fixed aliasing bug in Mojo::EventEmitter.
- Fixed WebSocket cookie bug in Mojo::UserAgent.
Expand Down
14 changes: 7 additions & 7 deletions lib/Mojo/Content.pm
Expand Up @@ -397,16 +397,16 @@ Emitted once all data has been written.
=head2 read
$content->on(read => sub {
my ($content, $chunk) = @_;
my ($content, $bytes) = @_;
...
});
Emitted when a new chunk of content arrives.
$content->unsubscribe('read');
$content->on(read => sub {
my ($content, $chunk) = @_;
say "Streaming: $chunk";
my ($content, $bytes) = @_;
say "Streaming: $bytes";
});
=head1 ATTRIBUTES
Expand Down Expand Up @@ -606,16 +606,16 @@ Size of content already received from message in bytes.
=head2 write
$content = $content->write('Hello!');
$content = $content->write('Hello!' => sub {...});
$content = $content->write($bytes);
$content = $content->write($bytes => sub {...});
Write dynamic content non-blocking, the optional drain callback will be
invoked once all data has been written.
=head2 write_chunk
$content = $content->write_chunk('Hello!');
$content = $content->write_chunk('Hello!' => sub {...});
$content = $content->write_chunk($bytes);
$content = $content->write_chunk($bytes => sub {...});
Write dynamic content non-blocking with C<chunked> transfer encoding, the
optional drain callback will be invoked once all data has been written.
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -296,12 +296,12 @@ Mojo::IOLoop - Minimalistic event loop
my ($loop, $stream) = @_;
$stream->on(read => sub {
my ($stream, $chunk) = @_;
my ($stream, $bytes) = @_;
# Process input
say $chunk;
# Process input chunk
say $bytes;
# Got some data, time to write
# Write response
$stream->write('HTTP/1.1 200 OK');
});
});
Expand All @@ -311,10 +311,10 @@ Mojo::IOLoop - Minimalistic event loop
my ($loop, $err, $stream) = @_;
$stream->on(read => sub {
my ($stream, $chunk) = @_;
my ($stream, $bytes) = @_;
# Process input
say "Input: $chunk";
say "Input: $bytes";
});
# Write request
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -169,7 +169,7 @@ Mojo::IOLoop::Stream - Non-blocking I/O stream
# Create stream
my $stream = Mojo::IOLoop::Stream->new($handle);
$stream->on(read => sub {
my ($stream, $chunk) = @_;
my ($stream, $bytes) = @_;
...
});
$stream->on(close => sub {
Expand Down Expand Up @@ -228,7 +228,7 @@ Emitted safely if an error occurs on the stream.
=head2 read
$stream->on(read => sub {
my ($stream, $chunk) = @_;
my ($stream, $bytes) = @_;
...
});
Expand All @@ -247,7 +247,7 @@ closed automatically.
=head2 write
$stream->on(write => sub {
my ($stream, $chunk) = @_;
my ($stream, $bytes) = @_;
...
});
Expand Down Expand Up @@ -330,8 +330,8 @@ Steal handle from stream and prevent it from getting closed automatically.
=head2 write
$stream = $stream->write('Hello!');
$stream = $stream->write('Hello!' => sub {...});
$stream = $stream->write($bytes);
$stream = $stream->write($bytes => sub {...});
Write data to stream, the optional drain callback will be invoked once all
data has been written.
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojo/Message.pm
Expand Up @@ -493,8 +493,8 @@ implements the following new ones.
Access C<content> data or replace all subscribers of the C<read> event.
$msg->body(sub {
my ($msg, $chunk) = @_;
say "Streaming: $chunk";
my ($msg, $bytes) = @_;
say "Streaming: $bytes";
});
=head2 body_params
Expand Down Expand Up @@ -731,16 +731,16 @@ All C<multipart/form-data> file uploads, usually L<Mojo::Upload> objects.
=head2 write
$msg = $msg->write('Hello!');
$msg = $msg->write('Hello!' => sub {...});
$msg = $msg->write($bytes);
$msg = $msg->write($bytes => sub {...});
Write dynamic content non-blocking, the optional drain callback will be
invoked once all data has been written.
=head2 write_chunk
$msg = $msg->write_chunk('Hello!');
$msg = $msg->write_chunk('Hello!' => sub {...});
$msg = $msg->write_chunk($bytes);
$msg = $msg->write_chunk($bytes => sub {...});
Write dynamic content non-blocking with C<chunked> transfer encoding, the
optional drain callback will be invoked once all data has been written.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Transaction.pm
Expand Up @@ -200,7 +200,7 @@ Transaction closed client-side, used to implement user agents.
=head2 client_read
$tx->client_read($chunk);
$tx->client_read($bytes);
Read data client-side, used to implement user agents. Meant to be overloaded
in a subclass.
Expand Down Expand Up @@ -265,7 +265,7 @@ Transaction closed server-side, used to implement web servers.
=head2 server_read
$tx->server_read($chunk);
$tx->server_read($bytes);
Read data server-side, used to implement web servers. Meant to be overloaded
in a subclass.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Transaction/HTTP.pm
Expand Up @@ -249,7 +249,7 @@ implements the following new ones.
=head2 client_read
$tx->client_read($chunk);
$tx->client_read($bytes);
Read data client-side, used to implement user agents.
Expand All @@ -267,7 +267,7 @@ Check if connection can be kept alive.
=head2 server_read
$tx->server_read($chunk);
$tx->server_read($bytes);
Read data server-side, used to implement web servers.
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -944,9 +944,9 @@ to inherit query parameters from the current request.
=head2 write
$c = $c->write;
$c = $c->write('Hello!');
$c = $c->write($bytes);
$c = $c->write(sub {...});
$c = $c->write('Hello!' => sub {...});
$c = $c->write($bytes => sub {...});
Write dynamic content non-blocking, the optional drain callback will be
invoked once all data has been written.
Expand Down Expand Up @@ -976,9 +976,9 @@ timeout, which usually defaults to C<15> seconds.
=head2 write_chunk
$c = $c->write_chunk;
$c = $c->write_chunk('Hello!');
$c = $c->write_chunk($bytes);
$c = $c->write_chunk(sub {...});
$c = $c->write_chunk('Hello!' => sub {...});
$c = $c->write_chunk($bytes => sub {...});
Write dynamic content non-blocking with C<chunked> transfer encoding, the
optional drain callback will be invoked once all data has been written.
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -611,10 +611,10 @@ which can be combined to solve some of hardest problems in web development.
# Make sure we have the right part and replace "read" event
return unless $single->headers->content_disposition =~ /example/;
$single->unsubscribe('read')->on(read => sub {
my ($single, $chunk) = @_;
my ($single, $bytes) = @_;

# Log size of every chunk we receive
$self->app->log->debug(length($chunk) . ' bytes uploaded.');
$self->app->log->debug(length($bytes) . ' bytes uploaded.');
});
});
}) unless $self->req->is_finished;
Expand Down Expand Up @@ -827,8 +827,8 @@ L<Mojo::UserAgent> makes it actually easy.

# Replace "read" events to disable default content parser
$tx->res->content->unsubscribe('read')->on(read => sub {
my ($content, $chunk) = @_;
say "Streaming: $chunk";
my ($content, $bytes) = @_;
say "Streaming: $bytes";
});

# Process transaction
Expand Down
4 changes: 2 additions & 2 deletions lib/Test/Mojo.pm
Expand Up @@ -757,8 +757,8 @@ Reset user agent session.
$t = $t->send_ok({binary => $bytes});
$t = $t->send_ok({text => $bytes});
$t = $t->send_ok([$fin, $rsv1, $rsv2, $rsv3, $op, $payload]);
$t = $t->send_ok('hello');
$t = $t->send_ok('hello', 'sent successfully');
$t = $t->send_ok($chars);
$t = $t->send_ok($chars, 'sent successfully');
Send message or frame via WebSocket.
Expand Down

0 comments on commit ae7e983

Please sign in to comment.