File Coverage

blib/lib/Beam/Runnable.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Beam::Runnable;
2             our $VERSION = '0.014';
3             # ABSTRACT: Role for runnable objects
4              
5             #pod =head1 SYNOPSIS
6             #pod
7             #pod package My::Runnable;
8             #pod use Moo;
9             #pod with 'Beam::Runnable';
10             #pod sub run { ... }
11             #pod
12             #pod =head1 DESCRIPTION
13             #pod
14             #pod This role declares your object as runnable by the C command.
15             #pod Runnable objects will be listed by the C command, and their
16             #pod documentation displayed by the C command.
17             #pod
18             #pod =head2 The C method
19             #pod
20             #pod The C method is the main function of your object. See below for its
21             #pod arguments and return value.
22             #pod
23             #pod The C method should be as small as possible, ideally only parsing
24             #pod command-line arguments and delegating to other objects to do the real
25             #pod work. Though your runnable object can be used in other code, the API of
26             #pod the C method is a terrible way to do that, and it is better to keep
27             #pod your business logic and other important code in another class.
28             #pod
29             #pod =head2 Documentation
30             #pod
31             #pod The C command will display the documentation of your module:
32             #pod the C (abstract), C, C, C,
33             #pod C, and C sections. This is the same as what
34             #pod L produces by default.
35             #pod
36             #pod The C command, when listing runnable objects, will display
37             #pod either the C attribute or the C POD section (abstract)
38             #pod next to the service name.
39             #pod
40             #pod =head2 Additional Roles
41             #pod
42             #pod Additional roles can add common functionality to your runnable script.
43             #pod Some of these are included in the C distribution:
44             #pod
45             #pod =over
46             #pod
47             #pod =item L
48             #pod
49             #pod This role will add a timeout using Perl's built-in
50             #pod L function. Once the timeout is reached, the
51             #pod program will print a warning and exit with an error code.
52             #pod
53             #pod =back
54             #pod
55             #pod =head1 SEE ALSO
56             #pod
57             #pod L, L
58             #pod
59             #pod =cut
60              
61 6     6   160446 use strict;
  6         13  
  6         152  
62 6     6   25 use warnings;
  6         11  
  6         130  
63 6     6   26 use Moo::Role;
  6         13  
  6         36  
64             with 'Beam::Service';
65 6     6   3776 use Types::Standard qw( Str );
  6         330578  
  6         64  
66              
67             #pod =attr summary
68             #pod
69             #pod A summary of the task to be run. This will be displayed by the C
70             #pod list> command in the list.
71             #pod
72             #pod =cut
73              
74             has summary => (
75             is => 'ro',
76             isa => Str,
77             );
78              
79             #pod =method run
80             #pod
81             #pod my $exit_code = $obj->run( @argv );
82             #pod
83             #pod Execute the runnable object with the given arguments and returning the
84             #pod exit status. C<@argv> is passed-in from the command line and may contain
85             #pod options (which you can parse using L
86             #pod function|Getopt::Long/Parsing options from an arbitrary array>.
87             #pod
88             #pod =cut
89              
90             requires 'run';
91              
92             1;
93              
94             __END__