| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | # Created on: 2014-09-05 04:34:42 | 
| 3 |  |  |  |  |  |  | # Create by:  Ivan Wills | 
| 4 |  |  |  |  |  |  | # $Id$ | 
| 5 |  |  |  |  |  |  | # $Revision$, $HeadURL$, $Date$ | 
| 6 |  |  |  |  |  |  | # $Revision$, $Source$, $Date$ | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | use strict; | 
| 9 | 24 |  |  | 24 |  | 4641 | use warnings; | 
|  | 24 |  |  |  |  | 49 |  | 
|  | 24 |  |  |  |  | 615 |  | 
| 10 | 24 |  |  | 24 |  | 102 | use version; | 
|  | 24 |  |  |  |  | 45 |  | 
|  | 24 |  |  |  |  | 574 |  | 
| 11 | 24 |  |  | 24 |  | 102 | use Carp qw/carp croak cluck confess longmess/; | 
|  | 24 |  |  |  |  | 45 |  | 
|  | 24 |  |  |  |  | 140 |  | 
| 12 | 24 |  |  | 24 |  | 1485 | use Data::Dumper qw/Dumper/; | 
|  | 24 |  |  |  |  | 55 |  | 
|  | 24 |  |  |  |  | 1333 |  | 
| 13 | 24 |  |  | 24 |  | 210 | use English qw/ -no_match_vars /; | 
|  | 24 |  |  |  |  | 83 |  | 
|  | 24 |  |  |  |  | 1020 |  | 
| 14 | 24 |  |  | 24 |  | 129 | use base qw/Exporter/; | 
|  | 24 |  |  |  |  | 68 |  | 
|  | 24 |  |  |  |  | 141 |  | 
| 15 | 24 |  |  | 24 |  | 7656 |  | 
|  | 24 |  |  |  |  | 46 |  | 
|  | 24 |  |  |  |  | 13822 |  | 
| 16 |  |  |  |  |  |  | our $VERSION     = version->new(1.1.20); | 
| 17 |  |  |  |  |  |  | our @EXPORT_OK   = qw//; | 
| 18 |  |  |  |  |  |  | our %EXPORT_TAGS = (); | 
| 19 |  |  |  |  |  |  | #our @EXPORT      = qw//; | 
| 20 |  |  |  |  |  |  | my $git; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | my $class = shift; | 
| 23 |  |  |  |  |  |  | my %param = @_; | 
| 24 | 24 |  |  | 24 | 1 | 43 | my $self  = \%param; | 
| 25 | 24 |  |  |  |  | 52 | $self->{data} = []; | 
| 26 | 24 |  |  |  |  | 42 |  | 
| 27 | 24 |  |  |  |  | 61 | bless $self, $class; | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 24 |  |  |  |  | 52 | return $git = $self; | 
| 30 |  |  |  |  |  |  | } | 
| 31 | 24 |  |  |  |  | 184 |  | 
| 32 |  |  |  |  |  |  | return $git || __PACKAGE__->new; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 | 24 |  | 33 | 24 | 1 | 346 | my $self = shift; | 
| 36 |  |  |  |  |  |  | confess "Data not Hashes!\n" . Dumper(\@_) if @_ && ref $_[0] ne 'HASH'; | 
| 37 |  |  |  |  |  |  | push @{ $self->{data} }, @_; | 
| 38 |  |  |  |  |  |  | } | 
| 39 | 118 |  |  | 118 | 1 | 9761 |  | 
| 40 | 118 | 50 | 66 |  |  | 666 | my $self = shift; | 
| 41 | 118 |  |  |  |  | 174 | @{ $self->{data} } = (); | 
|  | 118 |  |  |  |  | 316 |  | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | our $AUTOLOAD; | 
| 45 | 111 |  |  | 111 | 1 | 4610 | my $self = shift; | 
| 46 | 111 |  |  |  |  | 191 | my $called =  $AUTOLOAD; | 
|  | 111 |  |  |  |  | 366 |  | 
| 47 |  |  |  |  |  |  | $called =~ s/.*:://; | 
| 48 |  |  |  |  |  |  | $called =~ s/_/-/g; | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | return if $called eq 'DESTROY'; | 
| 51 | 494 |  |  | 494 |  | 743 |  | 
| 52 | 494 |  |  |  |  | 618 | my $cmd = "git $called " . (join ' ', @_); | 
| 53 | 494 |  |  |  |  | 1741 | if ( !@{ $self->{data} } ) { | 
| 54 | 494 |  |  |  |  | 814 | confess "No data setup for `$cmd`\n\t# ".(join "\n\t# ", reverse @{ $self->{ran} })."\n\t"; | 
| 55 |  |  |  |  |  |  | } | 
| 56 | 494 | 50 |  |  |  | 870 | push @{ $self->{ran} }, $cmd; | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 494 |  |  |  |  | 1277 | confess "Data not set up correctly! Not an ARRAY of HASHes\n" if ref $self->{data}    ne "ARRAY"; | 
| 59 | 494 | 100 |  |  |  | 599 | confess "Data not set up correctly! Not an Array of Hashes\n" if ref $self->{data}[0] ne "HASH"; | 
|  | 494 |  |  |  |  | 1048 |  | 
| 60 | 2 |  |  |  |  | 7 | my ($action, $return) = each %{ shift @{ $self->{data} } }; | 
|  | 2 |  |  |  |  | 594 |  | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 492 |  |  |  |  | 609 | # sanity check | 
|  | 492 |  |  |  |  | 870 |  | 
| 63 |  |  |  |  |  |  | if ($action ne $called) { | 
| 64 | 492 | 50 |  |  |  | 999 | confess "Expected mock data for '$called' but got data for '$action'!\n" | 
| 65 | 492 | 50 |  |  |  | 915 | . Dumper($cmd, $return) | 
| 66 | 492 |  |  |  |  | 556 | . "\t# " | 
|  | 492 |  |  |  |  | 528 |  | 
|  | 492 |  |  |  |  | 1361 |  | 
| 67 |  |  |  |  |  |  | . (join "\n\t# ", reverse @{ $self->{ran} }) | 
| 68 |  |  |  |  |  |  | . "\n\t"; | 
| 69 | 492 | 100 |  |  |  | 865 | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | if (wantarray) { | 
| 72 |  |  |  |  |  |  | if ( !$return || !ref $return || ref $return ne 'ARRAY' ) { | 
| 73 | 2 |  |  |  |  | 8 | confess "Returning Mock for `$cmd` with scalar value when expecting an array\n" . Dumper($return), "\t"; | 
|  | 2 |  |  |  |  | 409 |  | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  | return @$return; | 
| 76 |  |  |  |  |  |  | } | 
| 77 | 490 | 100 |  |  |  | 770 | else { | 
| 78 | 230 | 50 | 33 |  |  | 1019 | #cluck "Returning mock for `$cmd`\n" . Dumper($return), "\t"; | 
|  |  |  | 33 |  |  |  |  | 
| 79 | 0 |  |  |  |  | 0 | return $return; | 
| 80 |  |  |  |  |  |  | } | 
| 81 | 230 |  |  |  |  | 791 | } | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | 1; | 
| 84 |  |  |  |  |  |  |  | 
| 85 | 260 |  |  |  |  | 798 |  | 
| 86 |  |  |  |  |  |  | =head1 NAME | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | Mock::App::Git::Workflow::Repository - Mock of a git repository | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head1 VERSION | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | This documentation refers to Mock::App::Git::Workflow::Repository version 1.1.20 | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | use Mock::App::Git::Workflow::Repository; | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | # Brief but working code example(s) here showing the most common usage(s) | 
| 99 |  |  |  |  |  |  | # This section will be as far as many users bother reading, so make it as | 
| 100 |  |  |  |  |  |  | # educational and exemplary as possible. | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =head1 SUBROUTINES/METHODS | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =head2 C<new ()> | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | Create a new Mock::App::Git::Workflow::Repository | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | =head2 C<git ()> | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | return the last created Mock::App::Git::Workflow::Repository | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head2 C<mock_add (@data)> | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | push data to be returned when methods are called | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | =head2 C<mock_reset ()> | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | Clear out any mock data, useful if tests have added too much data | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | =head1 DIAGNOSTICS | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 CONFIGURATION AND ENVIRONMENT | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =head1 DEPENDENCIES | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =head1 INCOMPATIBILITIES | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =head1 BUGS AND LIMITATIONS | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | There are no known bugs in this module. | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | Please report problems to Ivan Wills (ivan.wills@gmail.com). | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | Patches are welcome. | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =head1 AUTHOR | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | Ivan Wills - (ivan.wills@gmail.com) | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). | 
| 145 |  |  |  |  |  |  | All rights reserved. | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | This module is free software; you can redistribute it and/or modify it under | 
| 148 |  |  |  |  |  |  | the same terms as Perl itself. See L<perlartistic>.  This program is | 
| 149 |  |  |  |  |  |  | distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | 
| 150 |  |  |  |  |  |  | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 
| 151 |  |  |  |  |  |  | PARTICULAR PURPOSE. | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | =cut |