File Coverage

blib/lib/Beam/Runner/Command/help.pm
Criterion Covered Total %
statement 32 32 100.0
branch 6 6 100.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 0 1 0.0
total 48 49 97.9


line stmt bran cond sub pod time code
1             package Beam::Runner::Command::help;
2             our $VERSION = '0.015';
3             # ABSTRACT: Get help for the given service(s)
4              
5             #pod =head1 SYNOPSIS
6             #pod
7             #pod beam help
8             #pod
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod Show the documentation for the given service from the given container.
12             #pod
13             #pod =head1 SEE ALSO
14             #pod
15             #pod L, L, L
16             #pod
17             #pod =cut
18              
19 1     1   111044 use strict;
  1         12  
  1         29  
20 1     1   6 use warnings;
  1         2  
  1         26  
21 1     1   463 use Beam::Runner::Util qw( find_container_path );
  1         4  
  1         57  
22 1     1   639 use Pod::Usage qw( pod2usage );
  1         48741  
  1         89  
23 1     1   9 use Pod::Find qw( pod_where );
  1         2  
  1         54  
24 1     1   722 use Beam::Wire;
  1         510796  
  1         262  
25              
26             sub run {
27 6     6 0 30089 my ( $class, $container, $service_name ) = @_;
28              
29 6 100 100     42 if ( !$container || !$service_name ) {
30 2         782 return pod2usage(
31             -message => 'ERROR: and are required',
32             -input => pod_where( { -inc => 1 }, __PACKAGE__ ),
33             -verbose => 0,
34             -exitval => 1,
35             );
36             }
37              
38 4         19 my $path = find_container_path( $container );
39 3         96 my $wire = Beam::Wire->new(
40             file => $path,
41             );
42 3         77538 my $service_conf = $wire->get_config( $service_name );
43 3 100       95 die sprintf qq{Could not find service "%s" in container "%s"\n},
44             $service_name, $path
45             unless $service_conf;
46              
47 2         5 my %service_conf = %{ $wire->normalize_config( $service_conf ) };
  2         8  
48 2         147 %service_conf = $wire->merge_config( %service_conf );
49 2         1490 my $pod_path = pod_where( { -inc => 1 }, $service_conf{class} );
50 2 100       14 if ( !$pod_path ) {
51 1         13 die "Could not find documentation for class '$service_conf{class}'\n";
52             }
53             pod2usage(
54 1         8 -input => $pod_path,
55             -verbose => 2,
56             -exitval => 0,
57             );
58             }
59              
60             1;
61              
62             __END__