TaskPipe/Tool/Command.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 1 totaltotal 92.5% 50 / 54 CC 3 SCAR 4.1
CC
3
Cov
93%
__ANON__
3.2
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« TaskPipe/Template_Plan.pm ↑ Summary TaskPipe/Role/MooseType_ScopeMode.pm »
1 package TaskPipe::Tool::Command;
2  
3 39 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 39 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 39 ▶use TaskPipe::SchemaManager;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 39 ▶use TaskPipe::JobManager;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 39 ▶use TaskPipe::Tool::Options;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 39 ▶use Pod::Term;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 39 with 'MooseX::ConfigCascade';
11  
12 has run_info => (is => 'rw', isa => 'TaskPipe::RunInfo', default => sub{
13 2898 ▶ TaskPipe::RunInfo->new;
Subroutine __ANON__: called CC=1 SCAR=0.0
14 39 });
15  
16  
17 has options => (is => 'rw', isa => 'TaskPipe::Tool::Options', default => sub{
18 2898 ▶ TaskPipe::Tool::Options->new;
Subroutine __ANON__: called CC=1 SCAR=0.0
19 39 });
20  
21  
22 has path_settings => (is => 'ro', isa => 'TaskPipe::PathSettings', default => sub{
23 2898 ▶ TaskPipe::PathSettings->new( scope => 'project' )
Subroutine __ANON__: called CC=1 SCAR=0.0
24 39 });
25  
26  
27 has job_manager => (is => 'ro', isa => 'TaskPipe::JobManager', lazy => 1, default => sub{
28 427 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.6
29
30 427 my $project = '*global';
31 427 ▶ if ( $self->run_info->scope eq 'project' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->run_info->scope eq "project") 427 0 427
32 427 $project = $self->path_settings->project_name;
33 }
34  
35 427 ▶ if (! $project ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($project) 0 427 427
36 0 confess "[B<Attempted to start a project-related job, but no project name could be determined. Did you forget to include the> C<--project> B<parameter on the command line? Alternatively, specify a default project in the TaskPipe::PathSettings::Global section of your config:>
37  
38 project: myprojectname
39  
40 ]";
41 }
42  
43 TaskPipe::JobManager->new(
44 427 name => $_[0]->name,
45 project => $project,
46 shell => 'foreground',
47 created_dt => DateTime->now
48 );
49 39 });
50  
51 882 ▶sub name{ my ($n) = ref($_[0]) =~ /^${\__PACKAGE__}_(\w+)$/; $n; }
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
52  
53 =head1 NAME
54  
55 TaskPipe::Tool::Command - base class for TaskPipe Tool commands
56  
57 =head1 DESCRIPTION
58  
59 See individual <TaskPipe::Tool::Command_...> packages for information on specific commands. You should not use this class directly.
60  
61 You can create a new tool command by inheriting from this class. However, this is not for the faint-hearted and not recommended if you don't fully understand TaskPipe architecture.
62  
63 The inherited package should look like this:
64  
65 package TaskPipe::Tool::Command_NewCommand;
66 use Moose;
67 extends 'TaskPipe::Tool::Command';
68 with 'MooseX::ConfigCascade';
69  
70 has option_specs => (is => 'ro', isa => 'ArrayRef', defaults => sub{[
71
72 # which options are available for your command?
73 # Enter settings attributes like this:
74 {
75 module: (name of module to take settings from)
76 items: [
77 # (arrayref of attributes to take from
78 # the module - or omit to take them all)
79 ],
80 is_config: 1 # Boolean. Are the settings taken
81 from this module available in config
82 or just on command line?
83 },
84  
85 {
86 # ...
87 }
88  
89 ]});
90  
91 sub execute{
92 my ($self) = @_;
93  
94 # execute the command here
95
96
97 }
98  
99 1;
100  
101 See the other C<TaskPipe::Tool::Command_> packages for examples of how to prepare a command.
102  
103 =head1 AUTHOR
104  
105 Tom Gracey <tomgracey@gmail.com>
106  
107 =head1 COPYRIGHT AND LICENSE
108  
109 Copyright (c) Tom Gracey 2018
110  
111 TaskPipe is free software, licensed under
112  
113 The GNU Public License Version 3
114  
115 =cut
116  
117 39 __PACKAGE__->meta->make_immutable;
118 39 1;
« TaskPipe/Template_Plan.pm ↑ Summary TaskPipe/Role/MooseType_ScopeMode.pm »