Browse Source

documented and done

tags/0.0.0
Zane C. B-H 5 months ago
parent
commit
676a2b3a76
5 changed files with 120 additions and 12 deletions
  1. +1
    -0
      Git-PunchCard/MANIFEST
  2. +2
    -0
      Git-PunchCard/Makefile.PL
  3. +3
    -0
      Git-PunchCard/README
  4. +2
    -1
      Git-PunchCard/bin/punchcard-git
  5. +112
    -11
      Git-PunchCard/lib/Git/PunchCard.pm

+ 1
- 0
Git-PunchCard/MANIFEST View File

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

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

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

+ 3
- 0
Git-PunchCard/README View File

@@ -50,6 +50,9 @@ You can also look for information at:
Search CPAN
https://metacpan.org/release/Git-PunchCard

Primary Code Repo
https://gitea.eesdp.org/vvelox/Git-PunchCard/


LICENSE AND COPYRIGHT


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

@@ -141,7 +141,8 @@ foreach my $day ( @days ){
push( @line, $day );

foreach my $hour ( @hours ){
my $color_to_use=13*($card->{$day}{$hour}/$card->{hourly_max});
my $color_to_use=13*($card->{$day}{$hour}/$card->{max});
if ( $color_to_use > 13 ){ $color_to_use=13; }
push( @line, color($colors[$color_to_use]).$card->{$day}{$hour}.color('WHITE') );
}


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

@@ -27,26 +27,62 @@ Perhaps a little code snippet.

use Git::PunchCard;
use Data::Dumper;

use Text::Table;
my $gpc = Git::PunchCard->new();
$gpc->dir($some_git_repo_dir);
if ( $gpc->error ){
print "Could not process the directory.\n";
}
print Dumper( $gpc );

=head1 EXPORT
my $card=$gpc->get_card;
print Dumper( $card );
# The various keys for the hashes.
my @days=('Sun','Mon','Tue','Wed','Thu','Fri','Sat', );
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');
# Stores the lines to for the table.
my @data;

# Process each day hash in $card.
foreach my $day ( @days ){
my @line;
# Add the day coloumn to the current line of the table.
push( @line, $day );
# Add each hour entry to the current line of the table.
foreach my $hour ( @hours ){
push( @line, $card->{$day}{$hour} );
}
# Finally add the total number of entries for that day.
push( @line, $card->{$day}{total}.color('WHITE') );
# add the new line to the table data
push( @data, \@line );
}
# Init the Text::Table object and add our headers.
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');

A list of functions that can be exported. You can delete this section
if you don't export anything, such as for a purely object-oriented module.
# Loads the data into the table
$table->load( @data );
# produce some useful? output
print $table."\nTotal: ".$card->{total}."\n";

=head1 SUBROUTINES/METHODS
=head1 METHODS

=head2 new

Inits the object.

my $gpc->new;

=cut

sub new {
@@ -61,9 +97,10 @@ sub new {
},
card=>{
total=>0,
hourly_max=>0,
max=>0,
Sun=>{
total=>0,
max=>0,
'00'=>0,
'01'=>0,
'02'=>0,
@@ -91,6 +128,7 @@ sub new {
},
Mon=>{
total=>0,
max=>0,
'00'=>0,
'01'=>0,
'02'=>0,
@@ -118,6 +156,7 @@ sub new {
},
Tue=>{
total=>0,
max=>0,
'00'=>0,
'01'=>0,
'02'=>0,
@@ -145,6 +184,7 @@ sub new {
},
Wed=>{
total=>0,
max=>0,
'00'=>0,
'01'=>0,
'02'=>0,
@@ -172,6 +212,7 @@ sub new {
},
Thu=>{
total=>0,
max=>0,
'00'=>0,
'01'=>0,
'02'=>0,
@@ -199,6 +240,7 @@ sub new {
},
Fri=>{
total=>0,
max=>0,
'00'=>0,
'01'=>0,
'02'=>0,
@@ -226,6 +268,7 @@ sub new {
},
Sat=>{
total=>0,
max=>0,
'00'=>0,
'01'=>0,
'02'=>0,
@@ -259,6 +302,21 @@ sub new {
}


=head2 card

One argument is taken and that is the directory to parse in.

If one is not passed, the current directory will be used.

IF this is called multiple times, each new instance will be added
to the current values.

$gpc->dir( $dir )
if ( $gpc->error ){
print "Errored!\n";
}

=cut

sub dir {
my $self=$_[0];
@@ -296,8 +354,11 @@ sub dir {
$self->{card}{$day}{total}++;
$self->{card}{total}++;

if ( $self->{card}{$day}{$hour} > $self->{card}{hourly_max}){
$self->{card}{hourly_max}=$self->{card}{$day}{$hour};
if ( $self->{card}{$day}{$hour} > $self->{card}{max}){
$self->{card}{max}=$self->{card}{$day}{$hour};
}
if ( $self->{card}{$day}{$hour} > $self->{card}{$day}{max}){
$self->{card}{max}=$self->{card}{$day}{$hour};
}
}
}
@@ -305,6 +366,34 @@ sub dir {
return 1;
}

=head get_card

This returns the current card data.

The returned value is a hashref.

The first level keys are the three letter
day names the the second level keys are the
two digit hour.

There are two special keys 'total' and 'max'.

'total' represents the total level of commits. So
at the primary level it is all the commits made to that
repo while and the secondary level it is all the comits
made to that repo on that day of the week.

'max' is the largest number of commits made. At the primary
level it is any hour on any day of the week while at the secondary
level it is the max made during any given hour that day.

For examples of making use of this, see the SYNOPSIS or check
out the script punchard-git.

my $card=$gpc->get_card;

=cut

sub get_card{
my $self=$_[0];
my $dir=$_[1];
@@ -316,6 +405,14 @@ sub get_card{
return $self->{card};
}

=head1 ERROR NUMBERS/FLAGS

Error handling is provided by L<Error::Helper>.

=head2 1 / gitError

Git exited with a non-zero value.

=head1 AUTHOR

Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
@@ -356,6 +453,10 @@ L<https://cpanratings.perl.org/d/Git-PunchCard>

L<https://metacpan.org/release/Git-PunchCard>

=item * Primary Repo

L<https://gitea.eesdp.org/vvelox/Git-PunchCard/>

=back



Loading…
Cancel
Save