Skip to content

Commit

Permalink
better synopsis examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 27, 2012
1 parent d773b22 commit dc9f883
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

3.14 2012-07-26
3.14 2012-07-27
- Improved documentation.

3.13 2012-07-24
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/ByteStream.pm
Expand Up @@ -94,7 +94,7 @@ Mojo::ByteStream - ByteStream
# Chain methods
my $stream = Mojo::ByteStream->new('foo bar baz')->quote;
$stream = $stream->unquote->encode('UTF-8')->b64_encode('');
say $stream;
say "$stream";
# Use the alternative constructor
use Mojo::ByteStream 'b';
Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/Content/Single.pm
Expand Up @@ -74,6 +74,7 @@ Mojo::Content::Single - HTTP 1.1 content container
my $single = Mojo::Content::Single->new;
$single->parse("Content-Length: 12\r\n\r\nHello World!");
say $single->headers->content_length;
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Cookie/Request.pm
Expand Up @@ -42,7 +42,7 @@ Mojo::Cookie::Request - HTTP 1.1 request cookie container
my $cookie = Mojo::Cookie::Request->new;
$cookie->name('foo');
$cookie->value('bar');
say $cookie;
say "$cookie";
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Cookie/Response.pm
Expand Up @@ -96,7 +96,7 @@ Mojo::Cookie::Response - HTTP 1.1 response cookie container
my $cookie = Mojo::Cookie::Response->new;
$cookie->name('foo');
$cookie->value('bar');
say $cookie;
say "$cookie";
=head1 DESCRIPTION
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Exception.pm
Expand Up @@ -155,7 +155,8 @@ Mojo::Exception - Exceptions with context
use Mojo::Exception;
my $e = Mojo::Exception->new;
my $e = Mojo::Exception->new('Not again!');
$e->throw;
=head1 DESCRIPTION
Expand Down
8 changes: 7 additions & 1 deletion lib/Mojo/Headers.pm
Expand Up @@ -183,9 +183,15 @@ Mojo::Headers - Headers
use Mojo::Headers;
# Parse
my $headers = Mojo::Headers->new;
$headers->content_type('text/plain');
$headers->parse("Content-Type: text/html\n\n");
say $headers->content_type;
# Build
my $headers = Mojo::Headers->new;
$headers->content_length(9001);
say $headers->to_string;
=head1 DESCRIPTION
Expand Down
6 changes: 6 additions & 0 deletions lib/Mojo/Parameters.pm
Expand Up @@ -205,7 +205,13 @@ Mojo::Parameters - Parameter container
use Mojo::Parameters;
# Parse
my $p = Mojo::Parameters->new('foo=bar&baz=23');
say $p->param('baz');
# Build
my $p = Mojo::Parameters->new(foo => 'bar', baz => 23);
say "$p";
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Path.pm
Expand Up @@ -122,7 +122,7 @@ Mojo::Path - Path
my $path = Mojo::Path->new('/foo%2Fbar%3B/baz.html');
shift @{$path->parts};
say $path;
say "$path";
=head1 DESCRIPTION
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojo/Server.pm
Expand Up @@ -8,13 +8,13 @@ use Scalar::Util 'blessed';

has app => sub {

# Try to detect application
return $ENV{MOJO_APP} if ref $ENV{MOJO_APP};
# Already initialized application
my $app = $ENV{MOJO_APP} || 'Mojo::HelloWorld';
return $app if ref $app;

# Load and initialize application
my $class = $ENV{MOJO_APP} ||= 'Mojo::HelloWorld';
if (my $e = Mojo::Loader->new->load($class)) { die $e if ref $e }
return $ENV{MOJO_APP} = $class->new;
if (my $e = Mojo::Loader->new->load($app)) { die $e if ref $e }
return $ENV{MOJO_APP} = $app->new;
};

sub new {
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/URL.pm
Expand Up @@ -264,7 +264,7 @@ Mojo::URL - Uniform Resource Locator
$url->path('baz');
$url->query->param(foo => 'bar');
$url->fragment(23);
say $url;
say "$url";
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/psgi.pm
Expand Up @@ -21,7 +21,7 @@ Mojolicious::Command::psgi - PSGI command
use Mojolicious::Command::psgi;
my $psgi = Mojolicious::Command::psgi->new;
my $app = $psgi->run;
my $app = $psgi->run;
=head1 DESCRIPTION
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojolicious/Lite.pm
Expand Up @@ -28,8 +28,7 @@ sub import {
my $routes = $app->routes->namespace('');

# Default static and template class
$app->static->classes->[0] = $caller;
$app->renderer->classes->[0] = $caller;
$app->static->classes->[0] = $app->renderer->classes->[0] = $caller;

# Export
no warnings 'redefine';
Expand Down
1 change: 0 additions & 1 deletion lib/Mojolicious/Plugins.pm
Expand Up @@ -77,7 +77,6 @@ Mojolicious::Plugins - Plugin manager
use Mojolicious::Plugins;
my $plugins = Mojolicious::Plugin->new;
$plugins->load_plugin('Config');
=head1 DESCRIPTION
Expand Down

0 comments on commit dc9f883

Please sign in to comment.