| 1 | package Test::Smoke::App::ConfigSmoke::Sync; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | |||
| 5 | our $VERSION = '0.001'; | ||
| 6 | |||
| 7 | use Exporter 'import'; | ||
| 8 | our @EXPORT = qw/ config_sync /; | ||
| 9 | |||
| 10 | use Test::Smoke::App::Options; | ||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | Test::Smoke::App::ConfigSmoke::Sync - Mixin for L<Test::Smoke::App::ConfigSmoke> | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | These methods will be added to the L<Test::Smoke::App::ConfigSmoke> class. | ||
| 19 | |||
| 20 | =head2 config_sync | ||
| 21 | |||
| 22 | Configure options for C<sync_type> and each sync-type. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | sub config_sync { | ||
| 27 | my $self = shift; | ||
| 28 | |||
| 29 | print "\n-- Sync section --\n"; | ||
| 30 | my $synctree = Test::Smoke::App::Options->synctree_config(); | ||
| 31 | |||
| 32 | my $sync_type = $self->handle_option(Test::Smoke::App::Options->sync_type); | ||
| 33 | my @sync_options = sort { | ||
| 34 | $a->configord <=> $b->configord | ||
| 35 | } @{ $synctree->{$sync_type} }; | ||
| 36 | for my $option (@sync_options) { | ||
| 37 | $self->handle_option($option); | ||
| 38 | } | ||
| 39 | |||
| 40 | # (post)handle gitbranchfile | ||
| 41 | if ( exists($self->current_values->{gitbranchfile}) | ||
| 42 | and my $fn = $self->current_values->{gitbranchfile}) | ||
| 43 | { | ||
| 44 | if ( open(my $fh, '>', $fn) ) { | ||
| 45 | print $fh $self->current_values->{gitdfbranch}; | ||
| 46 | close($fh); | ||
| 47 | printf " >> Created '%s'\n", $fn; | ||
| 48 | } | ||
| 49 | else { | ||
| 50 | print "!!!!!\nProblem: could not create '$fn': $!\n"; | ||
| 51 | print "Please correct your self.\n!!!!!\n"; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | 1; | ||
| 57 | |||
| 58 | =head1 COPYRIGHT | ||
| 59 | |||
| 60 | (c) 2020, All rights reserved. | ||
| 61 | |||
| 62 | * Abe Timmerman <abeltje@cpan.org> | ||
| 63 | |||
| 64 | This library is free software; you can redistribute it and/or modify | ||
| 65 | it under the same terms as Perl itself. | ||
| 66 | |||
| 67 | See: | ||
| 68 | |||
| 69 | =over 4 | ||
| 70 | |||
| 71 | =item * L<http://www.perl.com/perl/misc/Artistic.html> | ||
| 72 | |||
| 73 | =item * L<http://www.gnu.org/copyleft/gpl.html> | ||
| 74 | |||
| 75 | =back | ||
| 76 | |||
| 77 | This program is distributed in the hope that it will be useful, | ||
| 78 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 79 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 80 | |||
| 81 | =cut |