File Coverage

blib/lib/Mojolicious/Command/version.pm
Criterion Covered Total %
statement 36 37 97.3
branch 11 22 50.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 56 68 82.3


line stmt bran cond sub pod time code
1             package Mojolicious::Command::version;
2 1     1   9 use Mojo::Base 'Mojolicious::Command';
  1         2  
  1         10  
3              
4 1     1   9 use Mojo::IOLoop::Client;
  1         3  
  1         11  
5 1     1   7 use Mojo::IOLoop::TLS;
  1         2  
  1         10  
6 1     1   5 use Mojo::JSON;
  1         3  
  1         56  
7 1     1   7 use Mojo::Util;
  1         2  
  1         36  
8 1     1   15 use Mojolicious;
  1         3  
  1         14  
9              
10             has description => 'Show versions of available modules';
11             has usage => sub { shift->extract_usage };
12              
13             sub run {
14 1     1 1 3 my $self = shift;
15              
16 1 50       24 my $json = Mojo::JSON->JSON_XS ? $Cpanel::JSON::XS::VERSION : 'n/a';
17 1 50       13 my $cryptx = Mojo::Util->CRYPTX ? $CryptX::VERSION : 'n/a';
18 1 50       3 my $ev = eval { require Mojo::Reactor::EV; 1 } ? $EV::VERSION : 'n/a';
  1         1094  
  0         0  
19 1 50       16 my $socks = Mojo::IOLoop::Client->can_socks ? $IO::Socket::Socks::VERSION : 'n/a';
20 1 50       14 my $tls = Mojo::IOLoop::TLS->can_tls ? $IO::Socket::SSL::VERSION : 'n/a';
21 1 50       8 my $nnr = Mojo::IOLoop::Client->can_nnr ? $Net::DNS::Native::VERSION : 'n/a';
22 1 50       9 my $roles = Mojo::Base->ROLES ? $Role::Tiny::VERSION : 'n/a';
23 1 50       6 my $async = Mojo::Base->ASYNC ? $Future::AsyncAwait::VERSION : 'n/a';
24              
25 1         25 print <
26             CORE
27             Perl ($^V, $^O)
28             Mojolicious ($Mojolicious::VERSION, $Mojolicious::CODENAME)
29              
30             OPTIONAL
31             Cpanel::JSON::XS 4.20+ ($json)
32             CryptX 0.080+ ($cryptx)
33             EV 4.32+ ($ev)
34             IO::Socket::Socks 0.64+ ($socks)
35             IO::Socket::SSL 2.009+ ($tls)
36             Net::DNS::Native 0.15+ ($nnr)
37             Role::Tiny 2.000001+ ($roles)
38             Future::AsyncAwait 0.52+ ($async)
39              
40             EOF
41              
42             # Check latest version on CPAN
43 1 50       4 my $latest = eval {
44             $self->app->ua->max_redirects(10)
45 1     1   5 ->tap(sub { $_->proxy->detect })
46             ->get('fastapi.metacpan.org/v1/release/Mojolicious')
47 1         6 ->result->json->{version};
48             } or return;
49              
50 1         9 my $msg = 'This version is up to date, have fun!';
51 1 50       10 $msg = 'Thanks for testing a development release, you are awesome!' if $latest < $Mojolicious::VERSION;
52 1 50       6 $msg = "You might want to update your Mojolicious to $latest!" if $latest > $Mojolicious::VERSION;
53 1         17 say $msg;
54             }
55              
56             1;
57              
58             =encoding utf8
59              
60             =head1 NAME
61              
62             Mojolicious::Command::version - Version command
63              
64             =head1 SYNOPSIS
65              
66             Usage: APPLICATION version [OPTIONS]
67              
68             mojo version
69              
70             Options:
71             -h, --help Show this summary of available options
72              
73             =head1 DESCRIPTION
74              
75             L shows version information for available core and optional modules.
76              
77             This is a core command, that means it is always enabled and its code a good example for learning to build new commands,
78             you're welcome to fork it.
79              
80             See L for a list of commands that are available by default.
81              
82             =head1 ATTRIBUTES
83              
84             L inherits all attributes from L and implements the following new
85             ones.
86              
87             =head2 description
88              
89             my $description = $v->description;
90             $v = $v->description('Foo');
91              
92             Short description of this command, used for the command list.
93              
94             =head2 usage
95              
96             my $usage = $v->usage;
97             $v = $v->usage('Foo');
98              
99             Usage information for this command, used for the help screen.
100              
101             =head1 METHODS
102              
103             L inherits all methods from L and implements the following new
104             ones.
105              
106             =head2 run
107              
108             $v->run(@ARGV);
109              
110             Run this command.
111              
112             =head1 SEE ALSO
113              
114             L, L, L.
115              
116             =cut