Skip to content

Commit

Permalink
more consistent oneliner examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 2, 2012
1 parent 5bdcf94 commit 6f16107
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/Mojo/DOM.pm
Expand Up @@ -33,8 +33,7 @@ sub DESTROY { }
sub new {
my $class = shift;
my $self = bless [Mojo::DOM::HTML->new], ref $class || $class;
$self->parse(@_) if @_;
return $self;
return @_ ? $self->parse(@_) : $self;
}

sub all_text {
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -977,12 +977,12 @@ This can be an invaluable tool for testing your applications.

$ ./myapp.pl get /welcome 'head > title'

=head2 Oneliner
=head2 Oneliners

For quick hacks and especially testing, L<ojo> oneliners are also a great
choice.

$ perl -Mojo -E'say g("mojolicio.us")->dom->html->head->title->text'
$ perl -Mojo -E 'say g("mojolicio.us")->dom->html->head->title->text'

=head1 HACKS

Expand Down Expand Up @@ -1117,16 +1117,16 @@ rendering kicks in even if no actual code gets executed by the router. The
renderer just picks up the C<text> value from the stash and generates a
response.

=head2 Hello World oneliner
=head2 Hello World oneliners

The C<Hello World> example above can get even a little bit shorter in an
L<ojo> oneliner.

$ perl -Mojo -E'a({text => "Hello World!"})->start' daemon
$ perl -Mojo -E 'a({text => "Hello World!"})->start' daemon

And you can use all the commands from L<Mojolicious::Commands>.

$ perl -Mojo -E'a({text => "Hello World!"})->start' get -v /
$ perl -Mojo -E 'a({text => "Hello World!"})->start' get -v /

=head1 MORE

Expand Down
3 changes: 1 addition & 2 deletions lib/Test/Mojo.pm
Expand Up @@ -17,8 +17,7 @@ $ENV{MOJO_LOG_LEVEL} ||= $ENV{HARNESS_IS_VERBOSE} ? 'debug' : 'fatal';
# How come you guys can go to the moon but can't make my shoes smell good?"
sub new {
my $self = shift->SUPER::new;
$self->app(shift) if @_;
return $self;
return @_ ? $self->app(shift) : $self;
}

sub app {
Expand Down

0 comments on commit 6f16107

Please sign in to comment.