« blib/lib/auto/share/dist/Clustericious/tmpl/1.08/client/lib/APPCLASS/Client.pm
↑ Summary
blib/lib/Clustericious/Plugin/ClustericiousHelpers.pm »
| 1 | package Clustericious; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 78 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 78 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 78 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 78 | ▶ | use File::Spec; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 78 | ▶ | use File::Glob qw( bsd_glob ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 78 | ▶ | use File::Path qw( mkpath ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | # ABSTRACT: (Deprecated) A framework for RESTful processing systems. | ||||||||||||||||||||
| 11 | 78 | our $VERSION = '1.29'; # VERSION | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | sub _testing | ||||||||||||||||||||
| 15 | 158 | ▶ | { | ||||||||||||||||||
|
Subroutine
_testing: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 16 | 158 | state $test = 0; | |||||||||||||||||||
| 17 | 158 | my($class, $new) = @_; | |||||||||||||||||||
| 18 | 158 | ▶ | $test = $new if defined $new; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | 158 | $test; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | sub _config_path | ||||||||||||||||||||
| 23 | 138 | ▶ | { | ||||||||||||||||||
|
Subroutine
_config_path: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 24 | 350 | grep { -d $_ } | |||||||||||||||||||
| 25 | 350 | map { File::Spec->catdir(@$_) } | |||||||||||||||||||
| 26 | 456 | ▶ | grep { defined $_->[0] } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | ( | ||||||||||||||||||||
| 28 | 138 | [ $ENV{CLUSTERICIOUS_CONF_DIR} ], | |||||||||||||||||||
| 29 | (!_testing) ? ( | ||||||||||||||||||||
| 30 | [ bsd_glob('~'), 'etc' ], | ||||||||||||||||||||
| 31 | [ bsd_glob('~/.config/Perl/Clustericious') ], | ||||||||||||||||||||
| 32 | [ '', 'etc' ], | ||||||||||||||||||||
| 33 | ) : (), | ||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | sub _slurp_pid ($) | ||||||||||||||||||||
| 38 | 2 | ▶ | { | ||||||||||||||||||
|
Subroutine
_slurp_pid: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 39 | 78 | ▶ | use autodie; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 40 | 2 | my($fn) = @_; | |||||||||||||||||||
| 41 | 2 | open my $fh, '<', $fn; | |||||||||||||||||||
| 42 | 2 | my $pid = <$fh>; | |||||||||||||||||||
| 43 | 2 | close $fh; | |||||||||||||||||||
| 44 | 2 | chomp $pid; | |||||||||||||||||||
| 45 | 2 | $pid; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | sub _dist_dir | ||||||||||||||||||||
| 49 | 52 | ▶ | { | ||||||||||||||||||
|
Subroutine
_dist_dir: called CC=3 SCAR=11.2
| |||||||||||||||||||||
| 50 | 52 | state $dir; | |||||||||||||||||||
| 51 | 52 | ▶ | $dir //= do { | ||||||||||||||||||
|
Condition66%2/3
$dir //= do {
require Path::Class::Dir;
require File::ShareDir::Dist;
"Path::Class::Dir"->new(File::ShareDir::Dist::dist_share("Clustericious") || die("unable to find share directory"))
}
MC/DC0%0/2
$dir //= do {
require Path::Class::Dir;
require File::ShareDir::Dist;
"Path::Class::Dir"->new(File::ShareDir::Dist::dist_share("Clustericious") || die("unable to find share directory"))
}
$dir
do {
require Path::Class::Dir;
require File::ShareDir::Dist;
"Path::Class::Dir"->new(File::ShareDir::Dist::dist_share("Clustericious") || die("unable to find share directory"))
}
Truth table66%2/3
A //= B
A= $dirB= do {
require Path::Class::Dir;
require File::ShareDir::Dist;
"Path::Class::Dir"->new(File::ShareDir::Dist::dist_share("Clustericious") || die("unable to find share directory"))
}
| |||||||||||||||||||||
| 52 | 46 | require Path::Class::Dir; | |||||||||||||||||||
| 53 | 46 | require File::ShareDir::Dist; | |||||||||||||||||||
| 54 | 46 | ▶ | Path::Class::Dir->new( | ||||||||||||||||||
|
Condition50%1/2
File::ShareDir::Dist::dist_share('Clustericious') || die('unable to find share directory')
MC/DC0%0/1
File::ShareDir::Dist::dist_share('Clustericious') || die('unable to find share directory')
File::ShareDir::Dist::dist_share('Clustericious')
Truth table50%1/2
A
A= File::ShareDir::Dist::dist_share('Clustericious')
| |||||||||||||||||||||
| 55 | File::ShareDir::Dist::dist_share('Clustericious') or die "unable to find share directory", | ||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||
| 57 | }; | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | sub _generate_port | ||||||||||||||||||||
| 61 | 14 | ▶ | { | ||||||||||||||||||
|
Subroutine
_generate_port: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 62 | 14 | require IO::Socket::INET; | |||||||||||||||||||
| 63 | # this code is duplicated in Test::Clustericious::Command, | ||||||||||||||||||||
| 64 | # don't want to move it just FYI | ||||||||||||||||||||
| 65 | 14 | IO::Socket::INET->new(Listen => 5, LocalAddr => "127.0.0.1")->sockport | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | sub _my_dist_data | ||||||||||||||||||||
| 69 | 21 | ▶ | { | ||||||||||||||||||
|
Subroutine
_my_dist_data: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 70 | 21 | my $dir = bsd_glob '~/.local/share/Perl/dist/Clustericious'; | |||||||||||||||||||
| 71 | 21 | mkpath $dir, 0, 0700; | |||||||||||||||||||
| 72 | 21 | $dir; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | sub _default_url | ||||||||||||||||||||
| 76 | 21 | ▶ | { | ||||||||||||||||||
|
Subroutine
_default_url: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 77 | 21 | my(undef, $app_name) = @_; | |||||||||||||||||||
| 78 | 21 | require Path::Class::File; | |||||||||||||||||||
| 79 | 21 | require JSON::MaybeXS; | |||||||||||||||||||
| 80 | 21 | require Mojo::URL; | |||||||||||||||||||
| 81 | 21 | my $file = Path::Class::File->new(_my_dist_data(), 'default_ports.json'); | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 21 | $app_name =~ s{::}{-}; | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 21 | ▶ | my $data = -f $file ? JSON::MaybeXS::decode_json(scalar $file->slurp) : {}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 21 | ▶ | $data->{$app_name} // do { | ||||||||||||||||||
|
Condition66%2/3
$data->{$app_name} // do {
my $url = "Mojo::URL"->new("http://127.0.0.1");
$url->port(__PACKAGE__->_generate_port);
$url = $url->to_string;
$data->{$app_name} = $url;
$file->spew(&JSON::MaybeXS::encode_json($data));
$url
}
MC/DC0%0/2
$data->{$app_name} // do {
my $url = "Mojo::URL"->new("http://127.0.0.1");
$url->port(__PACKAGE__->_generate_port);
$url = $url->to_string;
$data->{$app_name} = $url;
$file->spew(&JSON::MaybeXS::encode_json($data));
$url
}
$data->{$app_name}
do {
my $url = "Mojo::URL"->new("http://127.0.0.1");
$url->port(__PACKAGE__->_generate_port);
$url = $url->to_string;
$data->{$app_name} = $url;
$file->spew(&JSON::MaybeXS::encode_json($data));
$url
}
Truth table66%2/3
A // B
A= $data->{$app_name}B= do {
my $url = "Mojo::URL"->new("http://127.0.0.1");
$url->port(__PACKAGE__->_generate_port);
$url = $url->to_string;
$data->{$app_name} = $url;
$file->spew(&JSON::MaybeXS::encode_json($data));
$url
}
| |||||||||||||||||||||
| 88 | 13 | my $url = Mojo::URL->new('http://127.0.0.1'); | |||||||||||||||||||
| 89 | 13 | $url->port(__PACKAGE__->_generate_port); | |||||||||||||||||||
| 90 | 13 | $url = $url->to_string; | |||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 13 | $data->{$app_name} = $url; | |||||||||||||||||||
| 93 | 13 | $file->spew(JSON::MaybeXS::encode_json($data)); | |||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 13 | $url; | |||||||||||||||||||
| 96 | }; | ||||||||||||||||||||
| 97 | } | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | # Note sub _config_uncache also gets placed | ||||||||||||||||||||
| 100 | # in this package, but it is defined in | ||||||||||||||||||||
| 101 | # Clustericious::Config. | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | 78 | 1; | |||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | __END__ | ||||||||||||||||||||