Hello community, here is the log from the commit of package perl-Mojolicious for openSUSE:Factory checked in at 2017-12-08 21:46:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Mojolicious (Old) and /work/SRC/openSUSE:Factory/.perl-Mojolicious.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojolicious" Fri Dec 8 21:46:11 2017 rev:83 rq:548019 version:7.58 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Mojolicious/perl-Mojolicious.changes 2017-11-21 15:21:05.593738566 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Mojolicious.new/perl-Mojolicious.changes 2017-12-08 21:47:21.379151377 +0100 @@ -1,0 +2,9 @@ +Mon Dec 4 06:40:50 UTC 2017 - [email protected] + +- updated to 7.58 + see /usr/share/doc/packages/perl-Mojolicious/Changes + + 7.58 2017-12-02 + - Added websocket_p method to Mojo::UserAgent. + +------------------------------------------------------------------- Old: ---- Mojolicious-7.57.tar.gz New: ---- Mojolicious-7.58.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Mojolicious.spec ++++++ --- /var/tmp/diff_new_pack.j6Um88/_old 2017-12-08 21:47:21.903128838 +0100 +++ /var/tmp/diff_new_pack.j6Um88/_new 2017-12-08 21:47:21.907128666 +0100 @@ -17,7 +17,7 @@ Name: perl-Mojolicious -Version: 7.57 +Version: 7.58 Release: 0 %define cpan_name Mojolicious Summary: Real-time web framework ++++++ Mojolicious-7.57.tar.gz -> Mojolicious-7.58.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/Changes new/Mojolicious-7.58/Changes --- old/Mojolicious-7.57/Changes 2017-11-18 17:05:36.000000000 +0100 +++ new/Mojolicious-7.58/Changes 2017-12-02 21:02:52.000000000 +0100 @@ -1,4 +1,7 @@ +7.58 2017-12-02 + - Added websocket_p method to Mojo::UserAgent. + 7.57 2017-11-18 - Fixed installation problems with some versions of Perl on Windows. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/META.json new/Mojolicious-7.58/META.json --- old/Mojolicious-7.57/META.json 2017-11-18 17:10:05.000000000 +0100 +++ new/Mojolicious-7.58/META.json 2017-12-03 23:14:26.000000000 +0100 @@ -58,6 +58,6 @@ }, "x_IRC" : "irc://irc.perl.org/#mojo" }, - "version" : "7.57", - "x_serialization_backend" : "JSON::PP version 2.94" + "version" : "7.58", + "x_serialization_backend" : "JSON::PP version 2.97000" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/META.yml new/Mojolicious-7.58/META.yml --- old/Mojolicious-7.57/META.yml 2017-11-18 17:10:05.000000000 +0100 +++ new/Mojolicious-7.58/META.yml 2017-12-03 23:14:26.000000000 +0100 @@ -31,5 +31,5 @@ homepage: http://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/kraih/mojo.git -version: '7.57' +version: '7.58' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/README.md new/Mojolicious-7.58/README.md --- old/Mojolicious-7.57/README.md 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/README.md 2017-12-03 03:34:54.000000000 +0100 @@ -22,8 +22,8 @@ applications, independently of the web framework. * Full stack HTTP and WebSocket client/server implementation with IPv6, TLS, SNI, IDNA, HTTP/SOCKS5 proxy, UNIX domain socket, Comet (long polling), - keep-alive, connection pooling, timeout, cookie, multipart, and gzip - compression support. + Promises/A+, keep-alive, connection pooling, timeout, cookie, multipart, + and gzip compression support. * Built-in non-blocking I/O web server, supporting multiple event loops as well as optional pre-forking and hot deployment, perfect for building highly scalable web services. @@ -33,6 +33,10 @@ can be used too, but may require additional CPAN modules to be installed) * Fresh code based upon years of experience developing [Catalyst](http://www.catalystframework.org), free and open source. + * Hundreds of 3rd party + [extensions](https://metacpan.org/requires/distribution/Mojolicious) and + high quality spin-off projects like the + [Minion](https://metacpan.org/pod/Minion) job queue. ## Installation @@ -66,14 +70,17 @@ ## Duct tape for the HTML5 web Use all the latest Perl and HTML features in beautiful single file - prototypes like this one, and grow them easily into well-structured - applications. + prototypes like this one, and + [grow](http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Differences) + them easily into well-structured **Model-View-Controller** web applications. ```perl use Mojolicious::Lite -signatures; # Render template "index.html.ep" from the DATA section -get '/' => {template => 'index'}; +get '/' => sub ($c) { + $c->render(template => 'index'); +}; # WebSocket service used by the template to extract the title from a website websocket '/title' => sub ($c) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojo/Content.pm new/Mojolicious-7.58/lib/Mojo/Content.pm --- old/Mojolicious-7.57/lib/Mojo/Content.pm 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojo/Content.pm 2017-11-23 11:26:07.000000000 +0100 @@ -342,7 +342,7 @@ Emitted when a new chunk of content arrives. - $content->unsubscribe('read')->on(read => sub { + $content->on(read => sub { my ($content, $bytes) = @_; say "Streaming: $bytes"; }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojo/Log.pm new/Mojolicious-7.58/lib/Mojo/Log.pm --- old/Mojolicious-7.57/lib/Mojo/Log.pm 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojo/Log.pm 2017-11-23 11:24:21.000000000 +0100 @@ -112,7 +112,7 @@ Emitted when a new message gets logged. - $log->unsubscribe('message')->on(message => sub { + $log->on(message => sub { my ($log, $level, @lines) = @_; say "$level: ", @lines; }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojo/Promise.pm new/Mojolicious-7.58/lib/Mojo/Promise.pm --- old/Mojolicious-7.57/lib/Mojo/Promise.pm 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojo/Promise.pm 2017-12-02 18:05:35.000000000 +0100 @@ -142,6 +142,19 @@ return $promise; } + # Perform non-blocking operations sequentially + get('http://mojolicious.org')->then(sub { + my $mojo = shift; + say $mojo->res->code; + return get('http://metacpan.org'); + })->then(sub { + my $cpan = shift; + say $cpan->res->code; + })->catch(sub { + my $err = shift; + warn "Something went wrong: $err"; + })->wait; + # Synchronize non-blocking operations (all) my $mojo = get('http://mojolicious.org'); my $cpan = get('http://metacpan.org'); @@ -268,26 +281,30 @@ L<Mojo::Promise> object resolving to the return value of the called handler. # Pass along the fulfillment value or rejection reason - $promise->then(sub { - my @value = @_; - say "The result is $value[0]"; - return @value; - }, - sub { - my @reason = @_; - warn "Something went wrong: $reason[0]"; - return @reason; - }); + $promise->then( + sub { + my @value = @_; + say "The result is $value[0]"; + return @value; + }, + sub { + my @reason = @_; + warn "Something went wrong: $reason[0]"; + return @reason; + } + ); # Change the fulfillment value or rejection reason - $promise->then(sub { - my @value = @_; - return "This is good: $value[0]"; - }, - sub { - my @reason = @_; - return "This is bad: $reason[0]"; - }); + $promise->then( + sub { + my @value = @_; + return "This is good: $value[0]"; + }, + sub { + my @reason = @_; + return "This is bad: $reason[0]"; + } + ); =head2 wait diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojo/Server.pm new/Mojolicious-7.58/lib/Mojo/Server.pm --- old/Mojolicious-7.57/lib/Mojo/Server.pm 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojo/Server.pm 2017-11-23 11:27:49.000000000 +0100 @@ -115,7 +115,7 @@ Emitted when a request is ready and needs to be handled. - $server->unsubscribe('request')->on(request => sub { + $server->on(request => sub { my ($server, $tx) = @_; $tx->res->code(200); $tx->res->headers->content_type('text/plain'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojo/UserAgent.pm new/Mojolicious-7.58/lib/Mojo/UserAgent.pm --- old/Mojolicious-7.57/lib/Mojo/UserAgent.pm 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojo/UserAgent.pm 2017-12-03 14:49:57.000000000 +0100 @@ -74,8 +74,10 @@ $tx => sub { my ($self, $tx) = @_; my $err = $tx->error; - $promise->resolve($tx) if !$err || $err->{code}; - $promise->reject($err->{message}); + return $promise->reject($err->{message}) if $err && !$err->{code}; + return $promise->reject('WebSocket handshake failed') + if $tx->req->is_handshake && !$tx->is_websocket; + $promise->resolve($tx); } ); @@ -87,6 +89,11 @@ $self->start($self->build_websocket_tx(@_), $cb); } +sub websocket_p { + my $self = shift; + return $self->start_p($self->build_websocket_tx(@_)); +} + sub _cleanup { my $self = shift; delete $self->{pid}; @@ -450,8 +457,8 @@ L<Mojo::UserAgent> is a full featured non-blocking I/O HTTP and WebSocket user agent, with IPv6, TLS, SNI, IDNA, HTTP/SOCKS5 proxy, UNIX domain socket, Comet -(long polling), keep-alive, connection pooling, timeout, cookie, multipart, gzip -compression and multiple event loop support. +(long polling), Promises/A+, keep-alive, connection pooling, timeout, cookie, +multipart, gzip compression and multiple event loop support. All connections will be reset automatically if a new process has been forked, this allows multiple processes to share the same L<Mojo::UserAgent> object @@ -1054,6 +1061,29 @@ 'Sec-WebSocket-Extensions' => 'permessage-deflate' } => sub {...}); +=head2 websocket_p + + my $promise = $ua->websocket_p('ws://example.com'); + +Same as L</"websocket">, but returns a L<Mojo::Promise> object instead of +accepting a callback. + + $ua->websocket_p('wss://example.com/echo')->then(sub { + my $tx = shift; + my $promise = Mojo::Promise->new; + $tx->on(finish => sub { $promise->resolve }); + $tx->on(message => sub { + my ($tx, $msg) = @_; + say "WebSocket message: $msg"; + $tx->finish; + }); + $tx->send('Hi!'); + return $promise; + })->catch(sub { + my $err = shift; + warn "WebSocket error: $err"; + })->wait; + =head1 DEBUGGING You can set the C<MOJO_USERAGENT_DEBUG> environment variable to get some diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojolicious/Command/get.pm new/Mojolicious-7.58/lib/Mojolicious/Command/get.pm --- old/Mojolicious-7.57/lib/Mojolicious/Command/get.pm 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojolicious/Command/get.pm 2017-11-19 14:06:39.000000000 +0100 @@ -16,7 +16,7 @@ my ($self, @args) = @_; # Data from STDIN - vec(my $r, fileno(STDIN), 1) = 1; + vec(my $r = '', fileno(STDIN), 1) = 1; my $in = !-t STDIN && select($r, undef, undef, 0) ? join '', <STDIN> : undef; my $ua = Mojo::UserAgent->new(ioloop => Mojo::IOLoop->singleton); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojolicious/Controller.pm new/Mojolicious-7.58/lib/Mojolicious/Controller.pm --- old/Mojolicious-7.57/lib/Mojolicious/Controller.pm 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojolicious/Controller.pm 2017-12-02 13:12:26.000000000 +0100 @@ -904,6 +904,18 @@ Generate a portable L<Mojo::URL> object with base for a path, URL or route. + # Rebuild URL for the current route + $c->url_for; + + # Rebuild URL for the current route, but replace the "name" placeholder value + $c->url_for(name => 'sebastian'); + + # Absolute URL for the current route + $c->url_for->to_abs; + + # Build URL for route "test" with two placeholder values + $c->url_for('test', name => 'sebastian', foo => 'bar'); + # "http://127.0.0.1:3000/index.html" if application was started with Morbo $c->url_for('/index.html')->to_abs; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojolicious/Guides/Cookbook.pod new/Mojolicious-7.58/lib/Mojolicious/Guides/Cookbook.pod --- old/Mojolicious-7.57/lib/Mojolicious/Guides/Cookbook.pod 2017-11-17 20:00:12.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojolicious/Guides/Cookbook.pod 2017-12-03 22:20:43.000000000 +0100 @@ -1336,7 +1336,7 @@ =head2 WebSockets WebSockets are not just for the server-side, you can use -L<Mojo::UserAgent/"websocket"> to open new connections, which are always +L<Mojo::UserAgent/"websocket_p"> to open new connections, which are always non-blocking. The WebSocket handshake uses HTTP, and is a normal C<GET> request with a few additional headers. It can even contain cookies, and is followed by a C<101> response from the server, notifying our user agent that the connection @@ -1344,20 +1344,21 @@ protocol. use Mojo::UserAgent; - use Mojo::IOLoop; + use Mojo::Promise; # Open WebSocket to echo service my $ua = Mojo::UserAgent->new; - $ua->websocket('ws://echo.websocket.org' => sub { - my ($ua, $tx) = @_; + $ua->websocket_p('ws://echo.websocket.org')->then(sub { + my $tx = shift; - # Check if WebSocket handshake was successful - say 'WebSocket handshake failed!' and return unless $tx->is_websocket; + # Prepare a followup promise so we can wait for messages + my $promise = Mojo::Promise->new; # Wait for WebSocket to be closed $tx->on(finish => sub { my ($tx, $code, $reason) = @_; say "WebSocket closed with status $code."; + $promise->resolve; }); # Close WebSocket after receiving one message @@ -1369,10 +1370,15 @@ # Send a message to the server $tx->send('Hi!'); - }); - # Start event loop if necessary - Mojo::IOLoop->start unless Mojo::IOLoop->is_running; + # Insert a new promise into the promise chain + return $promise; + })->catch(sub { + my $err = shift; + + # Handle failed WebSocket handshakes and other exceptions + warn "WebSocket error: $err"; + })->wait; =head2 UNIX domain sockets @@ -1383,7 +1389,7 @@ (C</> becomes C<%2F>) instead of a hostname. use Mojo::UserAgent; - use Mojo::IOLoop; + use Mojo::Promise; # GET request via UNIX domain socket "/tmp/foo.sock" my $ua = Mojo::UserAgent->new; @@ -1394,20 +1400,24 @@ say $tx->result->body; # WebSocket connection via UNIX domain socket "/tmp/baz.sock" - $ua->websocket('ws+unix://%2Ftmp%2Fbaz.sock/echo' => sub { - my ($ua, $tx) = @_; + $ua->websocket_p('ws+unix://%2Ftmp%2Fbaz.sock/echo')->then(sub { + my $tx = shift; - say 'WebSocket handshake failed!' and return unless $tx->is_websocket; + my $promise = Mojo::Promise->new; + $tx->on(finish => sub { $promise->resolve }); $tx->on(message => sub { my ($tx, $msg) = @_; say "WebSocket message: $msg"; $tx->finish; }); - $tx->send('Hi!'); - }); - Mojo::IOLoop->start unless Mojo::IOLoop->is_running; + + return $promise; + })->catch(sub { + my $err = shift; + warn "WebSocket error: $err"; + })->wait; You can set the C<Host> header manually to pass along a hostname. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojolicious/Guides/Growing.pod new/Mojolicious-7.58/lib/Mojolicious/Guides/Growing.pod --- old/Mojolicious-7.57/lib/Mojolicious/Guides/Growing.pod 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojolicious/Guides/Growing.pod 2017-12-03 03:42:30.000000000 +0100 @@ -150,6 +150,7 @@ | +- MyApp # Application namespace | +- Controller # Controller namespace | +- Example.pm # Controller class + |- my_app.conf # Configuration file |- t # Test directory | +- basic.t # Random test |- log # Log directory @@ -356,13 +357,15 @@ # Test login with valid credentials $t->post_ok('/' => form => {user => 'sebastian', pass => 'secr3t'}) - ->status_is(200)->text_like('html body' => qr/Welcome sebastian/); + ->status_is(200) + ->text_like('html body' => qr/Welcome sebastian/); # Test accessing a protected page $t->get_ok('/protected')->status_is(200)->text_like('a' => qr/Logout/); # Test if HTML login form shows up again after logout - $t->get_ok('/logout')->status_is(200) + $t->get_ok('/logout') + ->status_is(200) ->element_exists('form input[name="user"]') ->element_exists('form input[name="pass"]') ->element_exists('form input[type="submit"]'); @@ -778,11 +781,13 @@ ->element_exists('form input[type="submit"]'); $t->post_ok('/' => form => {user => 'sebastian', pass => 'secr3t'}) - ->status_is(200)->text_like('html body' => qr/Welcome sebastian/); + ->status_is(200) + ->text_like('html body' => qr/Welcome sebastian/); $t->get_ok('/protected')->status_is(200)->text_like('a' => qr/Logout/); - $t->get_ok('/logout')->status_is(200) + $t->get_ok('/logout') + ->status_is(200) ->element_exists('form input[name="user"]') ->element_exists('form input[name="pass"]') ->element_exists('form input[type="submit"]'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojolicious/Guides/Routing.pod new/Mojolicious-7.58/lib/Mojolicious/Guides/Routing.pod --- old/Mojolicious-7.57/lib/Mojolicious/Guides/Routing.pod 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojolicious/Guides/Routing.pod 2017-12-01 23:34:25.000000000 +0100 @@ -1024,6 +1024,11 @@ 1; +The host application will only share very little information with the embedded +application through the stash. So you cannot currently use route placeholders in +routes leading to embedded applications, since that would cause problems with +L<Mojolicious::Controller/"url_for">. + =head2 Application plugins You can even package applications as self-contained reusable plugins. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojolicious/resources/templates/mojo/menubar.html.ep new/Mojolicious-7.58/lib/Mojolicious/resources/templates/mojo/menubar.html.ep --- old/Mojolicious-7.57/lib/Mojolicious/resources/templates/mojo/menubar.html.ep 2017-11-18 17:05:03.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojolicious/resources/templates/mojo/menubar.html.ep 2017-11-24 22:34:55.000000000 +0100 @@ -64,7 +64,6 @@ %= link_to GitHub => 'https://github.com/kraih/mojo' %= link_to CPAN => 'https://metacpan.org/release/Mojolicious/' %= link_to MailingList => 'https://groups.google.com/group/mojolicious' - %= link_to Blog => 'http://blog.mojolicious.org' %= link_to Twitter => 'https://twitter.com/kraih' %= form_for 'https://www.google.com/cse' => (target => '_blank') => begin %= hidden_field cx => '014527573091551588235:pwfplkjpgbi' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/lib/Mojolicious.pm new/Mojolicious-7.58/lib/Mojolicious.pm --- old/Mojolicious-7.57/lib/Mojolicious.pm 2017-11-16 14:33:08.000000000 +0100 +++ new/Mojolicious-7.58/lib/Mojolicious.pm 2017-12-03 23:13:07.000000000 +0100 @@ -58,7 +58,7 @@ has validator => sub { Mojolicious::Validator->new }; our $CODENAME = 'Doughnut'; -our $VERSION = '7.57'; +our $VERSION = '7.58'; sub AUTOLOAD { my $self = shift; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.57/t/mojo/websocket.t new/Mojolicious-7.58/t/mojo/websocket.t --- old/Mojolicious-7.57/t/mojo/websocket.t 2017-11-06 18:19:39.000000000 +0100 +++ new/Mojolicious-7.58/t/mojo/websocket.t 2017-12-02 23:54:26.000000000 +0100 @@ -5,6 +5,7 @@ use Test::More; use Mojo::ByteStream 'b'; use Mojo::IOLoop; +use Mojo::Promise; use Mojo::Transaction::WebSocket; use Mojo::UserAgent; use Mojolicious::Lite; @@ -333,6 +334,28 @@ Mojo::IOLoop->start; is $result, 'foo bar', 'right result'; +# Promises +$result = undef; +$ua->websocket_p('/trim')->then( + sub { + my $tx = shift; + my $promise = Mojo::Promise->new; + $tx->on(finish => sub { $promise->resolve }); + $tx->on(message => sub { shift->finish; $result = pop }); + $tx->send(' also works! '); + return $promise; + } +)->wait; +is $result, 'also works!', 'right result'; +$result = undef; +$ua->websocket_p('/foo')->then(sub { $result = 'test failed' }) + ->catch(sub { $result = shift })->wait; +is $result, 'WebSocket handshake failed', 'right result'; +$result = undef; +$ua->websocket_p($ua->server->url->to_abs->scheme('wsss')) + ->then(sub { $result = 'test failed' })->catch(sub { $result = shift })->wait; +is $result, 'Unsupported protocol: wsss', 'right result'; + # Dies ($ws, $code, $msg) = (); my $finished;
