Skip to content

Commit

Permalink
document aliases more consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 1, 2012
1 parent e4560bb commit 2ff4ca8
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 147 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@

3.18 2012-08-02
- Improved documentation.
- Improved tests.

3.17 2012-08-01
- Improved documentation.
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojo/Asset/File.pm
Expand Up @@ -102,14 +102,12 @@ sub get_chunk {

# Range support
my $buffer;
my $size = $ENV{MOJO_CHUNK_SIZE} || 131072;
if (defined(my $end = $self->end_range)) {
my $chunk = $end + 1 - $start;
return '' if $chunk <= 0;
$chunk = $size if $chunk > $size;
$handle->sysread($buffer, $chunk);
$handle->sysread($buffer, $chunk > 131072 ? 131072 : $chunk);
}
else { $handle->sysread($buffer, $size) }
else { $handle->sysread($buffer, 131072) }

return $buffer;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Asset/Memory.pm
Expand Up @@ -37,7 +37,7 @@ sub get_chunk {
my ($self, $start) = @_;

$start += $self->start_range;
my $size = $ENV{MOJO_CHUNK_SIZE} || 131072;
my $size = 131072;
if (my $end = $self->end_range) {
$size = $end + 1 - $start if ($start + $size) > $end;
}
Expand Down
50 changes: 25 additions & 25 deletions lib/Mojo/ByteStream.pm
Expand Up @@ -129,22 +129,22 @@ Construct a new L<Mojo::ByteStream> object.
$stream = $stream->b64_decode;
Alias for L<Mojo::Util/"b64_decode">.
Manipulate bytestream with L<Mojo::Util/"b64_decode">.
=head2 C<b64_encode>
$stream = $stream->b64_encode;
$stream = $stream->b64_encode("\n");
Alias for L<Mojo::Util/"b64_encode">.
Manipulate bytestream with L<Mojo::Util/"b64_encode">.
b('foo bar baz')->b64_encode('')->say;
=head2 C<camelize>
$stream = $stream->camelize;
Alias for L<Mojo::Util/"camelize">.
Manipulate bytestream with L<Mojo::Util/"camelize">.
=head2 C<clone>
Expand All @@ -156,14 +156,14 @@ Clone bytestream.
$stream = $stream->decamelize;
Alias for L<Mojo::Util/"decamelize">.
Manipulate bytestream with L<Mojo::Util/"decamelize">.
=head2 C<decode>
$stream = $stream->decode;
$stream = $stream->decode('iso-8859-1');
Alias for L<Mojo::Util/"decode">, defaults to C<UTF-8>.
Manipulate bytestream with L<Mojo::Util/"decode">, defaults to C<UTF-8>.
$stream->decode('UTF-16LE')->unquote->trim->say;
Expand All @@ -172,21 +172,21 @@ Alias for L<Mojo::Util/"decode">, defaults to C<UTF-8>.
$stream = $stream->encode;
$stream = $stream->encode('iso-8859-1');
Alias for L<Mojo::Util/"encode">, defaults to C<UTF-8>.
Manipulate bytestream with L<Mojo::Util/"encode">, defaults to C<UTF-8>.
$stream->trim->quote->encode->say;
=head2 C<hmac_md5_sum>
$stream = $stream->hmac_md5_sum('passw0rd');
Alias for L<Mojo::Util/"hmac_md5_sum">.
Manipulate bytestream with L<Mojo::Util/"hmac_md5_sum">.
=head2 C<hmac_sha1_sum>
$stream = $stream->hmac_sha1_sum('passw0rd');
Alias for L<Mojo::Util/"hmac_sha1_sum">.
Manipulate bytestream with L<Mojo::Util/"hmac_sha1_sum">.
b('foo bar baz')->hmac_sha1_sum('secr3t')->quote->say;
Expand All @@ -195,47 +195,47 @@ Alias for L<Mojo::Util/"hmac_sha1_sum">.
$stream = $stream->html_escape;
$stream = $stream->html_escape('^\n\r\t !#$%(-;=?-~');
Alias for L<Mojo::Util/"html_escape">.
Manipulate bytestream with L<Mojo::Util/"html_escape">.
b('<html>')->html_escape->say;
=head2 C<html_unescape>
$stream = $stream->html_unescape;
Alias for L<Mojo::Util/"html_unescape">.
Manipulate bytestream with L<Mojo::Util/"html_unescape">.
b('&lt;html&gt;')->html_unescape->url_escape->say;
=head2 C<md5_bytes>
$stream = $stream->md5_bytes;
Alias for L<Mojo::Util/"md5_bytes">.
Manipulate bytestream with L<Mojo::Util/"md5_bytes">.
=head2 C<md5_sum>
$stream = $stream->md5_sum;
Alias for L<Mojo::Util/"md5_sum">.
Manipulate bytestream with L<Mojo::Util/"md5_sum">.
=head2 C<punycode_decode>
$stream = $stream->punycode_decode;
Alias for L<Mojo::Util/"punycode_decode">.
Manipulate bytestream with L<Mojo::Util/"punycode_decode">.
=head2 C<punycode_encode>
$stream = $stream->punycode_encode;
Alias for L<Mojo::Util/"punycode_encode">.
Manipulate bytestream with L<Mojo::Util/"punycode_encode">.
=head2 C<quote>
$stream = $stream->quote;
Alias for L<Mojo::Util/"quote">.
Manipulate bytestream with L<Mojo::Util/"quote">.
=head2 C<say>
Expand All @@ -248,21 +248,21 @@ Print bytestream to handle or STDOUT and append a newline.
my $success = $stream->secure_compare($string);
Alias for L<Mojo::Util/"secure_compare">.
Check bytestream with L<Mojo::Util/"secure_compare">.
say 'Match!' if b('foo')->secure_compare('foo');
=head2 C<sha1_bytes>
$stream = $stream->sha1_bytes;
Alias for L<Mojo::Util/"sha1_bytes">.
Manipulate bytestream with L<Mojo::Util/"sha1_bytes">.
=head2 C<sha1_sum>
$stream = $stream->sha1_sum;
Alias for L<Mojo::Util/"sha1_sum">.
Manipulate bytestream with L<Mojo::Util/"sha1_sum">.
=head2 C<size>
Expand All @@ -274,15 +274,15 @@ Size of bytestream.
$stream = $stream->slurp;
Alias for L<Mojo::Util/"slurp">.
Manipulate bytestream with L<Mojo::Util/"slurp">.
b('/home/sri/myapp.pl')->slurp->split("\n")->shuffle->join("\n")->say;
=head2 C<spurt>
$stream = $stream->spurt('/home/sri/myapp.pl');
Alias for L<Mojo::Util/"spurt">.
Write bytestream to file with L<Mojo::Util/"spurt">.
b('/home/sri/foo.html')->slurp->html_unescape->spurt('/home/sri/bar.html');
Expand All @@ -305,36 +305,36 @@ Stringify bytestream.
$stream = $stream->trim;
Alias for L<Mojo::Util/"trim">.
Manipulate bytestream with L<Mojo::Util/"trim">.
=head2 C<unquote>
$stream = $stream->unquote;
Alias for L<Mojo::Util/"unquote">.
Manipulate bytestream with L<Mojo::Util/"unquote">.
=head2 C<url_escape>
$stream = $stream->url_escape;
$stream = $stream->url_escape('^A-Za-z0-9\-._~');
Alias for L<Mojo::Util/"url_escape">.
Manipulate bytestream with L<Mojo::Util/"url_escape">.
b('foo bar baz')->url_escape->say;
=head2 C<url_unescape>
$stream = $stream->url_unescape;
Alias for L<Mojo::Util/"url_unescape">.
Manipulate bytestream with L<Mojo::Util/"url_unescape">.
b('%3Chtml%3E')->url_unescape->html_escape->say;
=head2 C<xml_escape>
$stream = $stream->xml_escape;
Alias for L<Mojo::Util/"xml_escape">.
Manipulate bytestream with L<Mojo::Util/"xml_escape">.
=head1 SEE ALSO
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Content.pm
Expand Up @@ -65,8 +65,7 @@ sub get_header_chunk {
= $headers ? "$headers\x0d\x0a\x0d\x0a" : "\x0d\x0a";
}

return substr $self->{header_buffer}, $offset,
$ENV{MOJO_CHUNK_SIZE} || 131072;
return substr $self->{header_buffer}, $offset, 131072;
}

sub has_leftovers { !!length(shift->{buffer} || '') }
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/DOM.pm
Expand Up @@ -532,7 +532,7 @@ Element attributes.
my $charset = $dom->charset;
$dom = $dom->charset('UTF-8');
Alias for L<Mojo::DOM::HTML/"charset">.
Access charset with L<Mojo::DOM::HTML/"charset">.
=head2 C<children>
Expand Down Expand Up @@ -590,7 +590,7 @@ Parent of element.
$dom = $dom->parse('<foo bar="baz">test</foo>');
Alias for L<Mojo::DOM::HTML/"parse">.
Parse HTML5/XML document with L<Mojo::DOM::HTML/"parse">.
# Parse UTF-8 encoded XML
my $dom = Mojo::DOM->new->charset('UTF-8')->xml(1)->parse($xml);
Expand Down Expand Up @@ -710,7 +710,7 @@ if a C<charset> has been defined.
my $tree = $dom->tree;
$dom = $dom->tree(['root', [qw(text lalala)]]);
Alias for L<Mojo::DOM::HTML/"tree">.
Access Document Object Model with L<Mojo::DOM::HTML/"tree">.
=head2 C<type>
Expand All @@ -727,7 +727,7 @@ Element type.
my $xml = $dom->xml;
$dom = $dom->xml(1);
Alias for L<Mojo::DOM::HTML/"xml">.
Change parser semantics with L<Mojo::DOM::HTML/"xml">.
=head1 CHILD ELEMENTS
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Headers.pm
Expand Up @@ -206,7 +206,7 @@ L<Mojo::Headers> implements the following attributes.
my $size = $headers->max_line_size;
$headers = $headers->max_line_size(1024);
Maximum line size in bytes, defaults to the value of the
Maximum header line size in bytes, defaults to the value of the
C<MOJO_MAX_LINE_SIZE> environment variable or C<10240>.
=head1 METHODS
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -87,8 +87,7 @@ sub _read {
my $self = shift;

# Read
my $read
= $self->{handle}->sysread(my $buffer, $ENV{MOJO_CHUNK_SIZE} || 131072, 0);
my $read = $self->{handle}->sysread(my $buffer, 131072, 0);

# Error
unless (defined $read) {
Expand Down

0 comments on commit 2ff4ca8

Please sign in to comment.