Skip to content

Commit

Permalink
improved version command to detect proxy servers automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 1, 2012
1 parent 69c8d15 commit 2b51d6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,7 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.

2.71 2012-04-01
2.71 2012-04-02
- Improved Hypnotoad error handling.
- Improved version command to detect proxy servers automatically.
- Improved documentation.
- Improved tests.

Expand Down
13 changes: 7 additions & 6 deletions lib/Mojolicious/Command/version.pm
Expand Up @@ -44,19 +44,20 @@ OPTIONAL
EOF

# Latest version
my $latest = my ($current) = $Mojolicious::VERSION =~ /^([^_]+)/;
my $latest;
eval {
my $ua = Mojo::UserAgent->new(max_redirects => 10)->detect_proxy;
$latest =
Mojo::UserAgent->new(max_redirects => 10)
->get('api.metacpan.org/v0/release/Mojolicious')->res->json->{version};
};
$ua->get('api.metacpan.org/v0/release/Mojolicious')
->res->json->{version};
} or return;

# Message
my $message = 'This version is up to date, have fun!';
$message = 'Thanks for testing a development release, you are awesome!'
if $latest < $current;
if $latest < $Mojolicious::VERSION;
$message = "You might want to update your Mojolicious to $latest."
if $latest > $current;
if $latest > $Mojolicious::VERSION;
say $message;
}

Expand Down

0 comments on commit 2b51d6e

Please sign in to comment.