Skip to content

Commit

Permalink
better pluck examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 7, 2012
1 parent 58e196d commit e6c0ff8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,4 +1,7 @@

3.05 2012-07-07
- Improved documentation.

3.04 2012-07-07
- Improved Mojo::IOLoop performance by reducing stream timeout precision
from 0.025 to 0.5 seconds.
Expand Down
2 changes: 1 addition & 1 deletion examples/microhttpd.pl
Expand Up @@ -41,7 +41,7 @@
print <<'EOF';
Starting server on port 3000.
Try something like "ab -c 30 -n 100000 -k http://127.0.0.1:3000/" for testing.
On a MacBook Pro 13" this results in about 15k req/s.
On a MacBook Pro 13" this results in about 16k req/s.
EOF

# Start loop
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/DOM.pm
Expand Up @@ -564,7 +564,7 @@ selectors from L<Mojo::DOM::CSS> are supported.
my $id = $dom->find('div')->[23]{id};
# Extract information from multiple elements
my @headers = $dom->find('h1, h2, h3')->map(sub { shift->text })->each;
my @headers = $dom->find('h1, h2, h3')->pluck('text')->each;
=head2 C<namespace>
Expand Down Expand Up @@ -725,7 +725,7 @@ L<Mojo::Collection> object, depending on number of children.
say $dom->p->text;
say $dom->div->[23]->text;
$dom->div->each(sub { say $_->text });
say $dom->div->pluck('text');
=head1 ELEMENT ATTRIBUTES
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -56,7 +56,7 @@ sub start {
$self->{timer} ||= $reactor->recurring(
0.5 => sub {
return unless $self && (my $t = $self->timeout);
$self->emit_safe('timeout')->close if (time - ($self->{active})) >= $t;
$self->emit_safe('timeout')->close if (time - $self->{active}) >= $t;
}
);

Expand Down
2 changes: 2 additions & 0 deletions lib/Mojo/Loader.pm
Expand Up @@ -130,6 +130,8 @@ following new ones.
Extract embedded file from the C<DATA> section of a class.
say for keys %{$loader->data('Foo::Bar')};
=head2 C<load>
my $e = $loader->load('Foo::Bar');
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Message.pm
Expand Up @@ -632,11 +632,11 @@ Turns message body into a L<Mojo::DOM> object and takes an optional selector
to perform a C<find> on it right away, which returns a collection.
# Perform "find" right away
$message->dom('h1, h2, h3')->pluck('text')->join("\n")->say;
say $message->dom('h1, h2, h3')->pluck('text');
# Use everything else Mojo::DOM has to offer
say $message->dom->at('title')->text;
$message->dom->html->body->children->pluck('type')->join("\n")->say;
say $message->dom->html->body->children->pluck('type')->uniq;
=head2 C<error>
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -548,8 +548,8 @@ Mojo::UserAgent - Non-blocking I/O HTTP 1.1 and WebSocket user agent
say $ua->get('mojolicio.us')->res->dom->html->head->title->text;
# Scrape the latest headlines from a news site
$ua->max_redirects(5)->get('www.reddit.com/r/perl/')
->res->dom('p.title > a.title')->pluck('text')->join("\n")->say;
say $ua->max_redirects(5)->get('www.reddit.com/r/perl/')
->res->dom('p.title > a.title')->pluck('text')->shuffle;
# IPv6 PUT request with content
my $tx
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -34,7 +34,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Rainbow';
our $VERSION = '3.04';
our $VERSION = '3.05';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down

0 comments on commit e6c0ff8

Please sign in to comment.