Aline/Manager.pm untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 97 CC 8 SCAR 20.3
CC
8
Cov
0%
dir_project_setup
20.0
dir_workflow_aline_setup
12.0
_postinit
6.0
CRAP 7.6
1 package Workflow::Aline::Manager;
2
3 use Class::Maker qw(:all);
4 use Class::Maker::Exception;
5 use IO::Extended qw(:all);
6 use File::Box;
7 use Regexp::Box;
8
9
10 our $VERSION = '0.02';
11
12 our $DEBUG = { basic => 0, robots => 0 };
13
14 use strict;
15
16 use warnings;
17
18 use File::Box;
19
20 Class::Maker::class
21 {
22 public =>
23 {
24 string => [qw( name dir_home )],
25
26 obj => [qw( file_box )],
27 },
28 };
29
30 sub _preinit : method
31 {
32 my $this = shift;
33
34 $this->file_box( File::Box->new( mother_file => __FILE__ ) );
35 }
36
37 sub _postinit : method
38 {
39 my $this = shift;
40
41 $this->dir_home( Path::Class::Dir->new( '.aline' ) ) unless ref( $this->dir_home );
42 }
43
44 sub _path_class_always
45 {
46 my $where = shift;
47
48 $where = Path::Class::Dir->new( $where ) unless ref( $where );
49
50 return $where;
51 }
52
53 sub dir_project_setup : method
54 {
55 my $this = shift;
56
57 my $dir_new_project = _path_class_always( shift );
58
59 my $skeleton_project = shift || 'project_skeleton';
60
61 if( my $dir_skeleton = $this->dir_home->subdir( $skeleton_project ) )
62 {
63 my $dir_new = $this->dir_home->subdir( 'projects')->subdir( $dir_new_project );
64
65 unless( -e $dir_skeleton )
66 {
67 warnfln "$this->dir_project_setup: Did not find project skeleton %S ..will do nothing.", $dir_skeleton;
68 }
69 else
70 {
71 if( -e $dir_new )
72 {
73 warnfln "$this->dir_project_setup: Existing project with name %S found ..will do nothing.", $dir_new;
74 }
75 else
76 {
77 print qx{cp -r $dir_skeleton $dir_new};
78
79 warnfln "$this->dir_project_setup: Project new %S created ..ok.", $dir_new_project;
80 }
81 }
82
83 print qx{find $dir_new};
84 }
85 else
86 {
87 diefln "Cannot find work_aline_projects via File::Box";
88 }
89 }
90
91 sub dir_workflow_aline_setup : method
92 {
93 my $this = shift;
94
95 my $where = $this->dir_home;
96
97 if( my $d = $this->file_box->request( $this->dir_home ) )
98 {
99 unless( -e $where )
100 {
101 # warnfln "$this->dir_project_create: Did not find %S ..making dir.", $where;
102 # $where->mkpath;
103
104 print qx{cp -r $d $where};
105 }
106 else
107 {
108 warnfln "$this->dir_project_create: Project dir %S exists ..skipping setup.", $where;
109 }
110
111 print qx{find $where};
112 }
113 else
114 {
115 diefln "Cannot find work_aline_projects via File::Box";
116 }
117 }
118
119 sub close : method
120 {
121 }
122
123 1;