| 1 | package Taskwarrior::Kusarigama::Plugin; | ||||||||||||||||||||||||||||||||
| 2 | 15 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Base class for Kusarigama plugins | ||||||||||||||||||||||||||||||||
| 4 | 15 | $Taskwarrior::Kusarigama::Plugin::VERSION = '0.11.0'; | |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use Moo; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use MooseX::MungeHas; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 15 | has tw => ( | |||||||||||||||||||||||||||||||
| 16 | is => 'ro', | ||||||||||||||||||||||||||||||||
| 17 | required => 1, | ||||||||||||||||||||||||||||||||
| 18 | handles => 'Taskwarrior::Kusarigama::Core', | ||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | has name => sub { | ||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Subroutine
_build_name: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 24 | 0 | my $name = ref $self; | |||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return $name =~ s/Taskwarrior::Kusarigama::Plugin:://r || "+$name"; | ||||||||||||||||||||||||||||||
|
Condition0%0/4
$name =~ s/Taskwarrior::Kusarigama::Plugin:://r || "+$name"
$name =~ s/Taskwarrior::Kusarigama::Plugin:://r || "+$name"
MC/DC0%0/1
$name =~ s/Taskwarrior::Kusarigama::Plugin:://r || "+$name"
$name =~ s/Taskwarrior::Kusarigama::Plugin:://r
MC/DC0%0/1
$name =~ s/Taskwarrior::Kusarigama::Plugin:://r || "+$name"
$name =~ s/Taskwarrior::Kusarigama::Plugin:://r
Truth table0%0/2
A
A= $name =~ s/Taskwarrior::Kusarigama::Plugin:://r
Truth table0%0/2
A
A= $name =~ s/Taskwarrior::Kusarigama::Plugin:://r
| |||||||||||||||||||||||||||||||||
| 26 | 15 | }; | |||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | # TODO implement an uninstall counterpart | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | sub setup { | ||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if( $self->can('custom_uda') ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 35 | 0 | say "Setting up custom UDAs..."; | |||||||||||||||||||||||||||||||
| 36 | 0 | my $uda = $self->custom_uda; | |||||||||||||||||||||||||||||||
| 37 | 0 | for my $name ( keys %$uda ) { | |||||||||||||||||||||||||||||||
| 38 | 0 | my $c = "uda.$name"; | |||||||||||||||||||||||||||||||
| 39 | 0 | say $name; | |||||||||||||||||||||||||||||||
| 40 | say "UDA already defined, skipping" and next | ||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if $self->tw->config->{uda}{$name}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$self->tw->config->{'uda'}{$name} && (say('UDA already defined, skipping') && (next))
say "UDA already defined, skipping" and next
MC/DC0%0/2
$self->tw->config->{'uda'}{$name} && (say('UDA already defined, skipping') && (next))
$self->tw->config->{'uda'}{$name}
say "UDA already defined, skipping"
Truth table0%0/3
A && B
A= $self->tw->config->{'uda'}{$name}B= say "UDA already defined, skipping"
| |||||||||||||||||||||||||||||||||
| 42 | 0 | system 'task', 'config', $c . '.label', $uda->{$name}; | |||||||||||||||||||||||||||||||
| 43 | 0 | system 'task', 'config', $c . '.type', 'string'; | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ( $self->DOES('Taskwarrior::Kusarigama::Hook::OnCommand') ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | 0 | my $name = $self->command_name; | |||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ( $self->tw->config->{report}{$name} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 50 | 0 | say "report '$name' already exist, skipping"; | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | else { | ||||||||||||||||||||||||||||||||
| 53 | 0 | system 'task', 'config', 'report.'.$name.'.columns', 'id'; | |||||||||||||||||||||||||||||||
| 54 | 0 | system 'task', 'config', 'report.'.$name.'.description', | |||||||||||||||||||||||||||||||
| 55 | 'pseudo-report for command'; | ||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 15 | 1; | |||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | =pod | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | Taskwarrior::Kusarigama::Plugin - Base class for Kusarigama plugins | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | =head1 VERSION | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | version 0.11.0 | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | package Taskwarrior::Kusarigama::Plugin::Foo; | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | use Moo; | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | extends 'Taskwarrior::Kusarigama::Plugin'; | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | with 'Taskwarrior::Kusarigama::Hook::OnLaunch'; | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | sub on_launch { ... }' | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 1; | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | Base class for all Taskwarrior::Kusarigama plugins. | ||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | =head2 METHODS | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | =head3 new | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | my $plugin = Taskwarrior::Kusarigama::Plugin->new( | ||||||||||||||||||||||||||||||||
| 101 | tw => $tw, | ||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | Constructor. Supports the following arguments. | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | =over | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | =item tw | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | Associated L<Taskwarrior::Kusarigama::Hook> object. | ||||||||||||||||||||||||||||||||
| 111 | Required. | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | =item name | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | Plugin name. If not provided, it is derived from the package | ||||||||||||||||||||||||||||||||
| 116 | name. | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | =back | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | =head3 tw | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | Returns the associated L<Taskwarrior::Kusarigama::Hook> | ||||||||||||||||||||||||||||||||
| 123 | object. | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | All the L<Taskwarrior::Kusarigama::Core> methods | ||||||||||||||||||||||||||||||||
| 126 | are made available to the plugin object via this attribute. | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | =head3 name | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | Returns the plugin name. | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | =head3 setup | ||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | Method used by C<task-kusarigama> to set up the plugin. | ||||||||||||||||||||||||||||||||
| 135 | If the plugin defines any UDAs, they will be created. | ||||||||||||||||||||||||||||||||
| 136 | Likewise, if the plugin is a custom command, a dummy | ||||||||||||||||||||||||||||||||
| 137 | report will be created in the taskwarrior configuration | ||||||||||||||||||||||||||||||||
| 138 | to allow it to be used. | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | Yanick Champoux <yanick@cpan.org> | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | This software is copyright (c) 2018, 2017 by Yanick Champoux. | ||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||
| 149 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | =cut | ||||||||||||||||||||||||||||||||