Kusarigama/App/Install.pm

filter: Statementstmt 61.2% 30 / 49 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 69.2% 9 / 13 Podpod 0.0% 0 / 3 totaltotal 56.5% 39 / 69 CC 5 SCAR 14.3
CC
5
Cov
57%
run
12.0
install_hook_scripts
6.0
install_script
6.0
CRAP 4.2
« Kusarigama/Hook.pm ↑ Summary Kusarigama/Plugin/ProjectDefaults.pm »
1 package Taskwarrior::Kusarigama::App::Install;
2 1 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: install scripts and tweak config for Taskwarrior::Kusarigama
4 1 $Taskwarrior::Kusarigama::App::Install::VERSION = '0.10.0';
5  
6 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use File::HomeDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Taskwarrior::Kusarigama::Hook;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use MooseX::App::Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use MooseX::MungeHas;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use experimental 'postderef';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 has tw => sub {
22 0 ▶ Taskwarrior::Kusarigama::Hook->new( data => '~/.task/' )
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 1 };
24  
25 sub run {
26 0 ▶ my $self = shift;
Subroutine run: not called CC=3 SCAR=24.8
Pod undocumented
27  
28 0 $self->install_hook_scripts;
29  
30 0 say "Performing plugins setup...";
31 0 for my $p ( $self->tw->plugins->@* ) {
32 0 say "-", ref $p;
33 0 ▶ next unless $p->can('setup');
Branch: 1 branch
BranchTrueFalseTotal
unless $p->can("setup") 0 0 0
34 0 $p->setup;
35 }
36  
37 0 say "Done";
38
39 }
40  
41 sub install_hook_scripts {
42 0 ▶ my $self = shift;
Subroutine install_hook_scripts: not called CC=2 SCAR=17.9
Pod undocumented
43
44 # TODO make that a configuration element
45 0 my $hook_dir = path( File::HomeDir->my_home, '.task', 'hooks' );
46  
47 0 say "Installing hooks in $hook_dir";
48  
49 0 $self->install_script($hook_dir, $_) for qw/ exit add launch modify /;
50 }
51  
52 sub install_script {
53 0 ▶ my( $self, $dir, $event ) = @_;
Subroutine install_script: not called CC=2 SCAR=17.9
Pod undocumented
54  
55 0 my $file = $dir->child( 'on-' . $event . '-kusarigama.pl' );
56 0 ▶ return warn "'$file' already exist, skipping\n" if $file->exists;
Branch: 1 branch
BranchTrueFalseTotal
if $file->exists 0 0 0
57  
58 0 say "installing '$file'...";
59  
60 0 $file->spew(<<"END");
61 #!/usr/bin/env perl
62  
63 use Taskwarrior::Kusarigama::Hook;
64  
65 Taskwarrior::Kusarigama::Hook->new( raw_args => \\\@ARGV )->run_event( '$event' );
66  
67 END
68  
69 0 $file->chmod('u+x');
70 }
71  
72 1 1;
73  
74 __END__
75  
76 =pod
77  
78 =encoding UTF-8
79  
80 =head1 NAME
81  
82 Taskwarrior::Kusarigama::App::Install - install scripts and tweak config for Taskwarrior::Kusarigama
83  
84 =head1 VERSION
85  
86 version 0.10.0
87  
88 =head1 SYNOPSIS
89  
90 $ task-kusarigama install
91  
92 =head1 DESCRIPTION
93  
94 Do the few things required to make Taskwarrior uses L<Taskwarrior::Kusarigama>. Namely:
95  
96 =over
97  
98 =item *
99  
100 Create the hook files "I<event>-kusarigama.pl" in F<~/.task/hooks> directory. If the files already exist, nothing is done.
101  
102 =item *
103  
104 Perform any installation action required by all the declared plugins.
105  
106 =back
107  
108 =head1 AUTHOR
109  
110 Yanick Champoux <yanick@cpan.org>
111  
112 =head1 COPYRIGHT AND LICENSE
113  
114 This software is copyright (c) 2018, 2017 by Yanick Champoux.
115  
116 This is free software; you can redistribute it and/or modify it under
117 the same terms as the Perl 5 programming language system itself.
118  
119 =cut
« Kusarigama/Hook.pm ↑ Summary Kusarigama/Plugin/ProjectDefaults.pm »