File Coverage

blib/lib/HackaMol/Roles/PathRole.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             $HackaMol::Roles::PathRole::VERSION = '0.052';
2             #ABSTRACT:
3             use 5.008;
4 11     11   7779 use Moose::Role;
  11         51  
5 11     11   63 use MooseX::Types::Path::Tiny qw/Path Paths AbsPath AbsPaths/;
  11         21  
  11         95  
6 11     11   60890  
  11         4685634  
  11         124  
7             has 'in_fn' => (
8             is => 'rw',
9             isa => Path,
10             coerce => 1,
11             predicate => 'has_in_fn',
12             );
13            
14             has 'out_fn' => (
15             is => 'rw',
16             isa => Path,
17             coerce => 1,
18             predicate => 'has_out_fn',
19             );
20              
21             has 'err_fn' => (
22             is => 'rw',
23             isa => Path,
24             coerce => 1,
25             predicate => 'has_err_fn',
26             );
27              
28             has 'log_fn' => (
29             is => 'rw',
30             isa => Path,
31             coerce => 1,
32             predicate => 'has_log_fn',
33             );
34              
35             has 'forts' => (
36             is => 'ro',
37             isa => Paths,
38             coerce => 1,
39             predicate => 'has_forts',
40             );
41              
42             has 'homedir' => (
43             is => 'ro',
44             isa => AbsPath,
45             coerce => 1,
46             default => '.',
47             );
48            
49             has 'scratch' => (
50             is => 'ro',
51             isa => AbsPath,
52             coerce => 1,
53             predicate => 'has_scratch',
54             );
55              
56             has 'data' => (
57             is => 'ro',
58             isa => AbsPath,
59             coerce => 1,
60             predicate => 'has_data',
61             );
62              
63             has 'dirs' => (
64             is => 'ro',
65             isa => AbsPaths,
66             coerce => 1,
67             predicate => 'has_dirs',
68             );
69              
70             no Moose::Role;
71 11     11   35288  
  11         32  
  11         95  
72             1;
73              
74              
75             =pod
76              
77             =head1 NAME
78              
79             HackaMol::Roles::PathRole -
80              
81             =head1 VERSION
82              
83             version 0.052
84              
85             =head1 DESCRIPTION
86              
87             This role adds some file and directory attributes to a class. This is still
88             a work in progress, and it will probably change (suggestions welcome). The
89             goal is to reduce the amount code required for manipulating file and directory
90             paths used for work, and to allow scripts to be more platform independent.
91             MooseX::Types::Path::Tiny is used to coerce the attributes into Path::Tiny
92             objects. See Path::Tiny for associated methods. The actual construction of
93             directories is left to scripts and extensions.
94              
95             =head1 ATTRIBUTES
96              
97             =head2 scratch homedir data
98              
99             isa Path::Tiny coerced via AbsPath that is 'ro'
100              
101             the absolute path to the directory is constructed
102              
103             =head2 log_fn in_fn out_fn err_fn
104              
105             isa Path::Tiny coerced via Path that is 'rw'
106              
107             =head2 dirs
108              
109             isa ArrayRef[Path::Tiny] coerced via AbsPaths that is 'ro'
110              
111             fill your object with all the directories you wish
112              
113             my $obj = SomeClass->new(dirs = [qw/. .. data tmp \/var ~\/bin/]
114              
115             =head2 forts
116              
117             isa ArrayRef[Path::Tiny] coerced via Paths that is 'ro'
118              
119             a place for those extra files
120              
121             =head1 AUTHOR
122              
123             Demian Riccardi <demianriccardi@gmail.com>
124              
125             =head1 COPYRIGHT AND LICENSE
126              
127             This software is copyright (c) 2017 by Demian Riccardi.
128              
129             This is free software; you can redistribute it and/or modify it under
130             the same terms as the Perl 5 programming language system itself.
131              
132             =cut