File Coverage

blib/lib/Proc/tored/Flag.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 22 100.0


line stmt bran cond sub pod time code
1             package Proc::tored::Flag;
2             # ABSTRACT: Ties a runtime flag to the existence of a touch file
3             $Proc::tored::Flag::VERSION = '0.18';
4              
5 3     3   177856 use strict;
  3         9  
  3         101  
6 3     3   20 use warnings;
  3         7  
  3         94  
7 3     3   524 use Moo;
  3         10999  
  3         24  
8 3     3   2899 use Path::Tiny 'path';
  3         10788  
  3         396  
9 3     3   617 use Types::Standard -types;
  3         68537  
  3         26  
10              
11             has touch_file_path => (
12               is => 'ro',
13               isa => Str,
14               required => 1,
15             );
16              
17             has file => (
18               is => 'lazy',
19               isa => InstanceOf['Path::Tiny'],
20               handles => {
21                 set => 'touch',
22                 unset => 'remove',
23                 is_set => 'exists',
24               },
25             );
26              
27 11     11   36908 sub _build_file { path($_[0]->touch_file_path) }
28              
29             1;
30              
31             __END__
32            
33             =pod
34            
35             =encoding UTF-8
36            
37             =head1 NAME
38            
39             Proc::tored::Flag - Ties a runtime flag to the existence of a touch file
40            
41             =head1 VERSION
42            
43             version 0.18
44            
45             =head1 SYNOPSIS
46            
47             use Proc::tored::Flag;
48            
49             my $fnord = Proc::tored::Flag->new(touch_file_path => '/my/service/path');
50            
51             $fnord->set; # touch file created if not already there
52             $fnord->is_set; # true
53            
54             $fnord->unset; # touch file removed if it exists
55             $fnord->is_set; # false
56            
57             if ($fnord->is_set) {
58             warn "forgot what to do";
59             exit 1;
60             }
61            
62             =head1 AUTHOR
63            
64             Jeff Ober <sysread@fastmail.fm>
65            
66             =head1 COPYRIGHT AND LICENSE
67            
68             This software is copyright (c) 2017 by Jeff Ober.
69            
70             This is free software; you can redistribute it and/or modify it under
71             the same terms as the Perl 5 programming language system itself.
72            
73             =cut
74