blib/lib/App/KGB/Client/Fake.pm

filter: Statementstmt 70.0% 28 / 40 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod 100% 2 / 2 totaltotal 70.3% 38 / 54 CC 2 SCAR 6.9
CC
2
Cov
67%
describe_commit
6.0
new
2.0
BEGIN
1.0
CRAP 2.0
« blib/lib/JSON/RPC/Client/Any.pm ↑ Summary blib/lib/App/KGB/Client/Subversion.pm »
1 package App::KGB::Client::Fake;
2 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = 1.17;
8  
9 # vim: ts=4:sw=4:et:ai:sts=4
10 #
11 # KGB - an IRC bot helping collaboration -- Fake client
12 # Copyright © 2012 Damyan Ivanov
13 #
14 # This program is free software; you can redistribute it and/or modify it under
15 # the terms of the GNU General Public License as published by the Free Software
16 # Foundation; either version 2 of the License, or (at your option) any later
17 # version.
18 #
19 # This program is distributed in the hope that it will be useful, but WITHOUT
20 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 # details.
23 #
24 # You should have received a copy of the GNU General Public License along with
25 # this program; if not, write to the Free Software Foundation, Inc., 51
26 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27  
28 =head1 NAME
29  
30 App::KGB::Client::Fake - Fake KGB client
31  
32 =head1 SYNOPSIS
33  
34 use App::KGB::Client::Fake;
35 my $client = App::KGB::Client::Fake(
36 # common App::KGB::Client parameters
37 repo_id => 'my-repo',
38 ...
39 );
40 $client->process;
41  
42 =head1 DESCRIPTION
43  
44 B<App::KGB::Client::Fake> generates a fake commit. It is useful when
45 testing client-server communication separately from SCM setup. See
46 L<kgb-client(1)>'s C<--fake> option.
47  
48 =head1 CONSTRUCTOR
49  
50 =head2 B<new> ()
51  
52 Standard constructor. Accepts no arguments.
53  
54 =head1 FIELDS
55  
56 None.
57  
58 =head1 METHODS
59  
60 =over
61  
62 =item describe_commit
63  
64 The first time this method is called, it returns an instance of
65 L<App::KGB::Commit> containing random information.
66  
67 All subsequential invocations return B<undef>.
68  
69 =back
70  
71 =cut
72  
73 1 require v5.10.0;
74 1 ▶use base 'App::KGB::Client';
Subroutine BEGIN: called CC=1 SCAR=0.0
75 1 ▶use App::KGB::Change;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 1 ▶use App::KGB::Commit;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 1 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
78 1 ▶use Digest::SHA qw(sha1_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
79 1 __PACKAGE__->mk_accessors(qw( _called ));
80  
81 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
82 0 my $class = shift;
83 0 my $self = $class->SUPER::new(@_);
84 0 $self->_called(0);
85  
86 0 return $self;
87 }
88  
89 0 ▶sub describe_commit {
Subroutine describe_commit: not called CC=2 SCAR=17.9
Pod documented
90 0 my ($self) = @_;
91  
92 0 ▶ return undef if $self->_called;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_called 0 0 0
93  
94 0 my @changes;
95 0 push @changes,
96 App::KGB::Change->new(
97 { action => 'A',
98 path => 'added/file',
99 }
100 );
101 0 push @changes,
102 App::KGB::Change->new(
103 { action => 'M',
104 path => 'file/modified',
105 }
106 );
107 0 push @changes,
108 App::KGB::Change->new(
109 { action => 'D',
110 path => 'file/deleted',
111 }
112 );
113  
114 0 $self->_called(1);
115  
116 0 return App::KGB::Commit->new(
117 { id => substr(sha1_hex(time), 0, 7),
118 changes => \@changes,
119 author => 'user',
120 log => 'This is a test commit message',
121 module => 'module'
122 }
123 );
124 }
125  
126 1 1;
« blib/lib/JSON/RPC/Client/Any.pm ↑ Summary blib/lib/App/KGB/Client/Subversion.pm »