| 1 | 10 | ▶ | use 5.008; # utf8 |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 10 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 10 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 10 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | package Git::Wrapper::Plus::Tester; | ||
| 7 | 10 | $Git::Wrapper::Plus::Tester::VERSION = '0.004010'; | |
| 8 | # ABSTRACT: Utility for testing things with a git repository | ||
| 9 | |||
| 10 | 10 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |
| 11 | |||
| 12 | 10 | ▶ | use Moo qw( has ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 10 | ▶ | use Path::Tiny qw(path); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | 10 | has 'temp_dir' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 87 | 10 | has 'home_dir' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 88 | 10 | has 'repo_dir' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 89 | 10 | has 'git' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 90 | |||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | |||
| 99 | |||
| 100 | |||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | 10 | has 'committer_name' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 110 | 10 | has 'committer_email' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 111 | 10 | has 'author_name' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 112 | 10 | has 'author_email' => ( is => ro =>, lazy => 1, builder => 1 ); | |
| 113 | |||
| 114 | sub _build_temp_dir { | ||
| 115 | 9 | ▶ | return Path::Tiny->tempdir; |
|
Subroutine
_build_temp_dir: called CC=1 SCAR=0.0
| |||
| 116 | } | ||
| 117 | |||
| 118 | sub _build_home_dir { | ||
| 119 | 9 | ▶ | my ( $self, ) = @_; |
|
Subroutine
_build_home_dir: called CC=1 SCAR=0.0
| |||
| 120 | 9 | my $d = $self->temp_dir->child('homedir'); | |
| 121 | 9 | $d->mkpath; | |
| 122 | 9 | return $d; | |
| 123 | } | ||
| 124 | |||
| 125 | sub _build_repo_dir { | ||
| 126 | 9 | ▶ | my ( $self, ) = @_; |
|
Subroutine
_build_repo_dir: called CC=1 SCAR=0.0
| |||
| 127 | 9 | my $d = $self->temp_dir->child('repodir'); | |
| 128 | 9 | $d->mkpath; | |
| 129 | 9 | return $d; | |
| 130 | } | ||
| 131 | |||
| 132 | sub _build_git { | ||
| 133 | 9 | ▶ | my ( $self, ) = @_; |
|
Subroutine
_build_git: called CC=1 SCAR=0.0
| |||
| 134 | 9 | require Git::Wrapper; | |
| 135 | 9 | return Git::Wrapper->new( $self->repo_dir->absolute->stringify ); | |
| 136 | } | ||
| 137 | |||
| 138 | sub _build_committer_name { | ||
| 139 | 9 | ▶ | return 'A. U. Thor'; |
|
Subroutine
_build_committer_name: called CC=1 SCAR=0.0
| |||
| 140 | } | ||
| 141 | |||
| 142 | sub _build_committer_email { | ||
| 143 | 9 | ▶ | return 'author@example.org'; |
|
Subroutine
_build_committer_email: called CC=1 SCAR=0.0
| |||
| 144 | } | ||
| 145 | |||
| 146 | sub _build_author_name { | ||
| 147 | 9 | ▶ | my ( $self, ) = @_; |
|
Subroutine
_build_author_name: called CC=1 SCAR=0.0
| |||
| 148 | 9 | return $self->committer_name; | |
| 149 | } | ||
| 150 | |||
| 151 | sub _build_author_email { | ||
| 152 | 9 | ▶ | my ( $self, ) = @_; |
|
Subroutine
_build_author_email: called CC=1 SCAR=0.0
| |||
| 153 | 9 | return $self->committer_email; | |
| 154 | |||
| 155 | } | ||
| 156 | |||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | |||
| 161 | |||
| 162 | |||
| 163 | |||
| 164 | |||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | sub run_env { | ||
| 169 | 9 | ▶ | my ( $self, $code ) = @_; |
|
Subroutine
run_env: called CC=1 SCAR=0.0
Pod
documented
| |||
| 170 | 9 | local $ENV{HOME} = $self->home_dir->absolute->stringify; | |
| 171 | 9 | local $ENV{GIT_AUTHOR_NAME} = $self->author_name; | |
| 172 | 9 | local $ENV{GIT_AUTHOR_EMAIL} = $self->author_email; | |
| 173 | 9 | local $ENV{GIT_COMMITTER_NAME} = $self->committer_name; | |
| 174 | 9 | local $ENV{GIT_COMMITTER_EMAIL} = $self->committer_email; | |
| 175 | 9 | return $code->( $self, ); | |
| 176 | } | ||
| 177 | |||
| 178 | 10 | ▶ | no Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 179 | 10 | 1; | |
| 180 | |||
| 181 | __END__ | ||