2 Commits

Author SHA1 Message Date
  Zane C. B-H a0d4bb23d3 formatting cleanup 1 month ago
  Zane C. B-H 676a2b3a76 documented and done 1 month ago

+ 1
- 0
Git-PunchCard/MANIFEST View File

@@ -7,3 +7,4 @@ t/00-load.t
7 7
 t/manifest.t
8 8
 t/pod-coverage.t
9 9
 t/pod.t
10
+bin/punchcard-git

+ 2
- 0
Git-PunchCard/Makefile.PL View File

@@ -10,6 +10,7 @@ my %WriteMakefileArgs = (
10 10
 						 ABSTRACT_FROM    => 'lib/Git/PunchCard.pm',
11 11
 						 LICENSE          => 'artistic_2',
12 12
 						 MIN_PERL_VERSION => '5.006',
13
+						 INST_SCRIPT => 'bin',
13 14
 						 CONFIGURE_REQUIRES => {
14 15
 												'ExtUtils::MakeMaker' => '0',
15 16
 												},
@@ -21,6 +22,7 @@ my %WriteMakefileArgs = (
21 22
 									   'Term::ANSIColor'=>'4.06',
22 23
 									   'Text::Table'=>'1.133',
23 24
 									   'Getopt::Long'=>'0.0.0',
25
+									   'Cwd'=>'0.0.0',
24 26
 									   },
25 27
 						 dist  => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
26 28
 						 clean => { FILES => 'Git-PunchCard-*' },

+ 3
- 0
Git-PunchCard/README View File

@@ -50,6 +50,9 @@ You can also look for information at:
50 50
     Search CPAN
51 51
         https://metacpan.org/release/Git-PunchCard
52 52
 
53
+    Primary Code Repo
54
+        https://gitea.eesdp.org/vvelox/Git-PunchCard/
55
+
53 56
 
54 57
 LICENSE AND COPYRIGHT
55 58
 

+ 2
- 1
Git-PunchCard/bin/punchcard-git View File

@@ -141,7 +141,8 @@ foreach my $day ( @days ){
141 141
 	push( @line, $day );
142 142
 
143 143
 	foreach my $hour ( @hours ){
144
-		my $color_to_use=13*($card->{$day}{$hour}/$card->{hourly_max});
144
+		my $color_to_use=13*($card->{$day}{$hour}/$card->{max});
145
+		if ( $color_to_use > 13 ){ $color_to_use=13; }
145 146
 		push( @line, color($colors[$color_to_use]).$card->{$day}{$hour}.color('WHITE') );
146 147
 	}
147 148
 

+ 112
- 11
Git-PunchCard/lib/Git/PunchCard.pm View File

@@ -27,26 +27,62 @@ Perhaps a little code snippet.
27 27
 
28 28
     use Git::PunchCard;
29 29
     use Data::Dumper;
30
-
30
+    use Text::Table;
31
+    
31 32
     my $gpc = Git::PunchCard->new();
32
-
33
+    
33 34
     $gpc->dir($some_git_repo_dir);
34 35
     if ( $gpc->error ){
35 36
         print "Could not process the directory.\n";
36 37
     }
37
-    print Dumper( $gpc );
38
-
39
-=head1 EXPORT
38
+    
39
+    my $card=$gpc->get_card;
40
+    
41
+    print Dumper( $card );
42
+    
43
+    # The various keys for the hashes.
44
+    my @days=('Sun','Mon','Tue','Wed','Thu','Fri','Sat', );
45
+    my @hours=('00','01','02','03','04','05','06','07','08','09','10', '11','12','13','14','15','16','17','18','19','20','21','22','23');
46
+    
47
+    # Stores the lines to for the table.
48
+    my @data;
49
+
50
+    # Process each day hash in $card.
51
+    foreach my $day ( @days ){
52
+        my @line;
53
+    
54
+        # Add the day coloumn to the current line of the table.
55
+        push( @line, $day );
56
+    
57
+        # Add each hour entry to the current line of the table.
58
+        foreach my $hour ( @hours ){
59
+            push( @line, $card->{$day}{$hour} );
60
+        }
61
+    
62
+        # Finally add the total number of entries for that day.
63
+        push( @line, $card->{$day}{total}.color('WHITE') );
64
+    
65
+        # add the new line to the table data
66
+        push( @data, \@line );
67
+    }
68
+    
69
+    # Init the Text::Table object and add our headers.
70
+    my $table=Text::Table->new('','00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','Total');
40 71
 
41
-A list of functions that can be exported.  You can delete this section
42
-if you don't export anything, such as for a purely object-oriented module.
72
+    # Loads the data into the table
73
+    $table->load( @data );
74
+    
75
+    # produce some useful? output
76
+    print $table."\nTotal: ".$card->{total}."\n";
43 77
 
44
-=head1 SUBROUTINES/METHODS
78
+=head1 METHODS
45 79
 
46 80
 =head2 new
47 81
 
48 82
 Inits the object.
49 83
 
84
+    my $gpc->new;
85
+
50 86
 =cut
51 87
 
52 88
 sub new {
@@ -61,9 +97,10 @@ sub new {
61 97
 						   },
62 98
 			  card=>{
63 99
 					 total=>0,
64
-					 hourly_max=>0,
100
+					 max=>0,
65 101
 					 Sun=>{
66 102
 						   total=>0,
103
+						   max=>0,
67 104
 						   '00'=>0,
68 105
 						   '01'=>0,
69 106
 						   '02'=>0,
@@ -91,6 +128,7 @@ sub new {
91 128
 						   },
92 129
 					 Mon=>{
93 130
 						   total=>0,
131
+						   max=>0,
94 132
 						   '00'=>0,
95 133
 						   '01'=>0,
96 134
 						   '02'=>0,
@@ -118,6 +156,7 @@ sub new {
118 156
 						   },
119 157
 					 Tue=>{
120 158
 						   total=>0,
159
+						   max=>0,
121 160
 						   '00'=>0,
122 161
 						   '01'=>0,
123 162
 						   '02'=>0,
@@ -145,6 +184,7 @@ sub new {
145 184
 						   },
146 185
 					 Wed=>{
147 186
 						   total=>0,
187
+						   max=>0,
148 188
 						   '00'=>0,
149 189
 						   '01'=>0,
150 190
 						   '02'=>0,
@@ -172,6 +212,7 @@ sub new {
172 212
 						   },
173 213
 					 Thu=>{
174 214
 						   total=>0,
215
+						   max=>0,
175 216
 						   '00'=>0,
176 217
 						   '01'=>0,
177 218
 						   '02'=>0,
@@ -199,6 +240,7 @@ sub new {
199 240
 						   },
200 241
 					 Fri=>{
201 242
 						   total=>0,
243
+						   max=>0,
202 244
 						   '00'=>0,
203 245
 						   '01'=>0,
204 246
 						   '02'=>0,
@@ -226,6 +268,7 @@ sub new {
226 268
 						   },
227 269
 					 Sat=>{
228 270
 						   total=>0,
271
+						   max=>0,
229 272
 						   '00'=>0,
230 273
 						   '01'=>0,
231 274
 						   '02'=>0,
@@ -259,6 +302,21 @@ sub new {
259 302
 }
260 303
 
261 304
 
305
+=head2 card
306
+
307
+One argument is taken and that is the directory to parse in.
308
+
309
+If one is not passed, the current directory will be used.
310
+
311
+IF this is called multiple times, each new instance will be added
312
+to the current values.
313
+
314
+    $gpc->dir( $dir )
315
+    if ( $gpc->error ){
316
+        print "Errored!\n";
317
+    }
318
+
319
+=cut
262 320
 
263 321
 sub dir {
264 322
 	my $self=$_[0];
@@ -296,8 +354,11 @@ sub dir {
296 354
 			$self->{card}{$day}{total}++;
297 355
 			$self->{card}{total}++;
298 356
 
299
-			if ( $self->{card}{$day}{$hour} > $self->{card}{hourly_max}){
300
-				$self->{card}{hourly_max}=$self->{card}{$day}{$hour};
357
+			if ( $self->{card}{$day}{$hour} > $self->{card}{max}){
358
+				$self->{card}{max}=$self->{card}{$day}{$hour};
359
+			}
360
+			if ( $self->{card}{$day}{$hour} > $self->{card}{$day}{max}){
361
+				$self->{card}{max}=$self->{card}{$day}{$hour};
301 362
 			}
302 363
 		}
303 364
 	}
@@ -305,6 +366,34 @@ sub dir {
305 366
 	return 1;
306 367
 }
307 368
 
369
+=head get_card
370
+
371
+This returns the current card data.
372
+
373
+The returned value is a hashref.
374
+
375
+The first level keys are the three letter
376
+day names the the second level keys are the
377
+two digit hour.
378
+
379
+There are two special keys 'total' and 'max'.
380
+
381
+'total' represents the total level of commits. So
382
+at the primary level it is all the commits made to that
383
+repo while and the secondary level it is all the comits
384
+made to that repo on that day of the week.
385
+
386
+'max' is the largest number of commits made. At the primary
387
+level it is any hour on any day of the week while at the secondary
388
+level it is the max made during any given hour that day.
389
+
390
+For examples of making use of this, see the SYNOPSIS or check
391
+out the script punchard-git.
392
+
393
+    my $card=$gpc->get_card;
394
+
395
+=cut
396
+
308 397
 sub get_card{
309 398
 	my $self=$_[0];
310 399
 	my $dir=$_[1];
@@ -316,6 +405,14 @@ sub get_card{
316 405
 	return $self->{card};
317 406
 }
318 407
 
408
+=head1 ERROR NUMBERS/FLAGS
409
+
410
+Error handling is provided by L<Error::Helper>.
411
+
412
+=head2 1 / gitError
413
+
414
+Git exited with a non-zero value.
415
+
319 416
 =head1 AUTHOR
320 417
 
321 418
 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
@@ -356,6 +453,10 @@ L<https://cpanratings.perl.org/d/Git-PunchCard>
356 453
 
357 454
 L<https://metacpan.org/release/Git-PunchCard>
358 455
 
456
+=item * Primary Repo
457
+
458
+L<https://gitea.eesdp.org/vvelox/Git-PunchCard/>
459
+
359 460
 =back
360 461
 
361 462
 

Loading…
Cancel
Save