| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Module::Setup::Test::Utils; | 
| 2 | 40 |  |  | 40 |  | 16680 | use strict; | 
|  | 40 |  |  |  |  | 53 |  | 
|  | 40 |  |  |  |  | 1362 |  | 
| 3 | 40 |  |  | 40 |  | 165 | use warnings; | 
|  | 40 |  |  |  |  | 67 |  | 
|  | 40 |  |  |  |  | 1331 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 40 |  |  | 40 |  | 35301 | use File::Temp; | 
|  | 40 |  |  |  |  | 930054 |  | 
|  | 40 |  |  |  |  | 3314 |  | 
| 6 | 40 |  |  | 40 |  | 19911 | use Path::Class; | 
|  | 40 |  |  |  |  | 776802 |  | 
|  | 40 |  |  |  |  | 2591 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 40 |  |  | 40 |  | 20087 | use Module::Setup; | 
|  | 40 |  |  |  |  | 145 |  | 
|  | 40 |  |  |  |  | 4525 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | my $stdout = []; | 
| 11 | 34 |  |  | 34 | 1 | 169 | sub stdout { $stdout } | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub import { | 
| 14 | 41 |  |  | 41 |  | 1194 | my $class  = shift; | 
| 15 | 41 |  |  |  |  | 92 | my $caller = caller; | 
| 16 | 41 |  |  |  |  | 108 | my %args   = @_; | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 41 |  |  |  |  | 103 | for my $func (qw/ context module_setup stdout dialog default_dialog setup_dir target_dir clear_tempdir flavors_dir template_dir additional_dir additional_config_file plugins_dir config_file /) { | 
| 19 | 40 |  |  | 40 |  | 1126 | no strict 'refs'; | 
|  | 40 |  |  |  |  | 54 |  | 
|  | 40 |  |  |  |  | 4285 |  | 
| 20 | 574 |  |  |  |  | 429 | *{"$caller\::$func"} = \&{ $func }; | 
|  | 574 |  |  |  |  | 1728 |  | 
|  | 574 |  |  |  |  | 2682 |  | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  |  | 
| 23 | 41 |  |  |  |  | 1956 | strict->import; | 
| 24 | 41 |  |  |  |  | 372 | warnings->import; | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 41 | 100 |  |  |  | 1102 | unless ($args{without_stdout}) { | 
| 27 | 40 |  |  | 40 |  | 204 | no warnings 'redefine'; | 
|  | 40 |  |  |  |  | 848 |  | 
|  | 40 |  |  |  |  | 29038 |  | 
| 28 | 40 |  |  | 10 |  | 1518 | *Module::Setup::stdout = sub { push @{ $stdout }, $_[1] }; | 
|  | 10 |  |  |  |  | 22 |  | 
|  | 10 |  |  |  |  | 185 |  | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | sub _path_dir (@) { | 
| 33 | 327 |  |  | 327 |  | 1724 | Path::Class::Dir->new(@_); | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  | my $setup_dir; | 
| 36 |  |  |  |  |  |  | sub setup_dir (@) { | 
| 37 | 184 | 100 |  | 184 | 1 | 4471 | $setup_dir = File::Temp->newdir unless $setup_dir; | 
| 38 | 184 |  |  |  |  | 24804 | _path_dir($setup_dir, @_); | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  | sub flavors_dir { | 
| 41 | 71 |  |  | 71 | 1 | 144 | setup_dir('flavors', @_); | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | sub template_dir { | 
| 44 | 11 |  |  | 11 | 1 | 2982 | my $flavor = shift; | 
| 45 | 11 |  |  |  |  | 44 | flavors_dir($flavor, 'template', @_); | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  | sub additional_dir { | 
| 48 | 42 |  |  | 42 | 1 | 2927 | my $flavor = shift; | 
| 49 | 42 |  |  |  |  | 97 | flavors_dir($flavor, 'additional', @_); | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  | sub additional_config_file { | 
| 52 | 15 |  |  | 15 | 1 | 87 | my $flavor = shift; | 
| 53 | 15 |  |  |  |  | 28 | additional_dir($flavor)->file('config.yaml'); | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  | sub plugins_dir { | 
| 56 | 5 |  |  | 5 | 1 | 16 | my $flavor = shift; | 
| 57 | 5 |  |  |  |  | 17 | flavors_dir($flavor, 'plugins', @_); | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  | sub config_file { | 
| 60 | 9 |  |  | 9 | 1 | 2938 | my $flavor = shift; | 
| 61 | 9 |  |  |  |  | 21 | flavors_dir($flavor)->file('config.yaml'); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | my $target_dir; | 
| 65 |  |  |  |  |  |  | sub target_dir (@) { | 
| 66 | 143 | 100 |  | 143 | 1 | 1848 | $target_dir = File::Temp->newdir unless $target_dir; | 
| 67 | 143 |  |  |  |  | 10394 | _path_dir($target_dir, @_); | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | sub clear_tempdir { | 
| 71 | 16 |  |  | 16 | 1 | 105 | $setup_dir  = undef; | 
| 72 | 16 |  |  |  |  | 98 | $target_dir = undef; | 
| 73 |  |  |  |  |  |  | } | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | my $context; | 
| 76 | 15 |  |  | 15 | 1 | 2236 | sub context { $context } | 
| 77 |  |  |  |  |  |  | sub module_setup ($@) { | 
| 78 | 91 |  |  | 91 | 1 | 15211 | $stdout = []; | 
| 79 | 91 |  |  |  |  | 281 | my($options, @argv) = @_; | 
| 80 | 91 | 100 |  |  |  | 375 | @argv = @{ $argv[0] } if ref $argv[0] eq 'ARRAY'; | 
|  | 10 |  |  |  |  | 29 |  | 
| 81 |  |  |  |  |  |  |  | 
| 82 | 91 | 100 |  |  |  | 529 | $options->{module_setup_dir} = setup_dir unless $options->{module_setup_dir}; | 
| 83 | 91 | 100 |  |  |  | 8372 | if ($options->{target}) { | 
| 84 | 50 |  |  |  |  | 161 | $options->{target} = target_dir; | 
| 85 |  |  |  |  |  |  | } | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 91 |  |  |  |  | 2780 | $context = Module::Setup->new( | 
| 88 |  |  |  |  |  |  | options => $options, | 
| 89 |  |  |  |  |  |  | argv => \@argv, | 
| 90 |  |  |  |  |  |  | ); | 
| 91 | 91 |  |  |  |  | 422 | $context->run; | 
| 92 |  |  |  |  |  |  | } | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | sub dialog (;&) { | 
| 95 | 32 |  |  | 32 | 1 | 6225 | my $code = shift; | 
| 96 | 40 |  |  | 40 |  | 1489 | no warnings 'redefine'; | 
|  | 40 |  |  |  |  | 916 |  | 
|  | 40 |  |  |  |  | 7777 |  | 
| 97 | 32 |  |  |  |  | 195 | *Module::Setup::dialog = $code; | 
| 98 |  |  |  |  |  |  | } | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | sub default_dialog { | 
| 101 |  |  |  |  |  |  | dialog { | 
| 102 | 136 |  |  | 136 |  | 1393 | my($self, $msg, $default) = @_; | 
| 103 | 136 | 100 |  |  |  | 651 | return 'n' if $msg =~ /Check Makefile.PL\?/i; | 
| 104 | 118 | 100 |  |  |  | 288 | return 'n' if $msg =~ /Subversion friendly\?/i; | 
| 105 | 117 |  |  |  |  | 467 | return $default; | 
| 106 | 15 |  |  | 15 | 1 | 179 | }; | 
| 107 |  |  |  |  |  |  | } | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | 1; | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =head1 NAME | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | Module::Setup::Test::Utils - Test utils | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | =head1 METHODS | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =head2 module_setup | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | =head2 context | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | =head2 stdout | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | =head2 clear_tempdir | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =head2 dialog | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =head2 default_dialog | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | =head2 target_dir | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | =head2 setup_dir | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | =head2 flavors_dir | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =head2 template_dir | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | =head2 plugins_dir | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =head2 config_file | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =head2 additional_dir | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | =head2 additional_config_file | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =cut |