Compare commits
2 Commits
2aa684a1e3
...
a0d4bb23d3
Author | SHA1 | Date |
---|---|---|
Zane C. B-H | a0d4bb23d3 | |
Zane C. B-H | 676a2b3a76 |
|
@ -7,3 +7,4 @@ t/00-load.t
|
||||||
t/manifest.t
|
t/manifest.t
|
||||||
t/pod-coverage.t
|
t/pod-coverage.t
|
||||||
t/pod.t
|
t/pod.t
|
||||||
|
bin/punchcard-git
|
||||||
|
|
|
@ -10,6 +10,7 @@ my %WriteMakefileArgs = (
|
||||||
ABSTRACT_FROM => 'lib/Git/PunchCard.pm',
|
ABSTRACT_FROM => 'lib/Git/PunchCard.pm',
|
||||||
LICENSE => 'artistic_2',
|
LICENSE => 'artistic_2',
|
||||||
MIN_PERL_VERSION => '5.006',
|
MIN_PERL_VERSION => '5.006',
|
||||||
|
INST_SCRIPT => 'bin',
|
||||||
CONFIGURE_REQUIRES => {
|
CONFIGURE_REQUIRES => {
|
||||||
'ExtUtils::MakeMaker' => '0',
|
'ExtUtils::MakeMaker' => '0',
|
||||||
},
|
},
|
||||||
|
@ -21,6 +22,7 @@ my %WriteMakefileArgs = (
|
||||||
'Term::ANSIColor'=>'4.06',
|
'Term::ANSIColor'=>'4.06',
|
||||||
'Text::Table'=>'1.133',
|
'Text::Table'=>'1.133',
|
||||||
'Getopt::Long'=>'0.0.0',
|
'Getopt::Long'=>'0.0.0',
|
||||||
|
'Cwd'=>'0.0.0',
|
||||||
},
|
},
|
||||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||||
clean => { FILES => 'Git-PunchCard-*' },
|
clean => { FILES => 'Git-PunchCard-*' },
|
||||||
|
|
|
@ -50,6 +50,9 @@ You can also look for information at:
|
||||||
Search CPAN
|
Search CPAN
|
||||||
https://metacpan.org/release/Git-PunchCard
|
https://metacpan.org/release/Git-PunchCard
|
||||||
|
|
||||||
|
Primary Code Repo
|
||||||
|
https://gitea.eesdp.org/vvelox/Git-PunchCard/
|
||||||
|
|
||||||
|
|
||||||
LICENSE AND COPYRIGHT
|
LICENSE AND COPYRIGHT
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,8 @@ foreach my $day ( @days ){
|
||||||
push( @line, $day );
|
push( @line, $day );
|
||||||
|
|
||||||
foreach my $hour ( @hours ){
|
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') );
|
push( @line, color($colors[$color_to_use]).$card->{$day}{$hour}.color('WHITE') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,26 +27,62 @@ Perhaps a little code snippet.
|
||||||
|
|
||||||
use Git::PunchCard;
|
use Git::PunchCard;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
use Text::Table;
|
||||||
|
|
||||||
my $gpc = Git::PunchCard->new();
|
my $gpc = Git::PunchCard->new();
|
||||||
|
|
||||||
$gpc->dir($some_git_repo_dir);
|
$gpc->dir($some_git_repo_dir);
|
||||||
if ( $gpc->error ){
|
if ( $gpc->error ){
|
||||||
print "Could not process the directory.\n";
|
print "Could not process the directory.\n";
|
||||||
}
|
}
|
||||||
print Dumper( $gpc );
|
|
||||||
|
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;
|
||||||
|
|
||||||
=head1 EXPORT
|
# 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
|
# Loads the data into the table
|
||||||
if you don't export anything, such as for a purely object-oriented module.
|
$table->load( @data );
|
||||||
|
|
||||||
|
# produce some useful? output
|
||||||
|
print $table."\nTotal: ".$card->{total}."\n";
|
||||||
|
|
||||||
=head1 SUBROUTINES/METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
=head2 new
|
=head2 new
|
||||||
|
|
||||||
Inits the object.
|
Inits the object.
|
||||||
|
|
||||||
|
my $gpc->new;
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -61,9 +97,10 @@ sub new {
|
||||||
},
|
},
|
||||||
card=>{
|
card=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
hourly_max=>0,
|
max=>0,
|
||||||
Sun=>{
|
Sun=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
|
max=>0,
|
||||||
'00'=>0,
|
'00'=>0,
|
||||||
'01'=>0,
|
'01'=>0,
|
||||||
'02'=>0,
|
'02'=>0,
|
||||||
|
@ -91,6 +128,7 @@ sub new {
|
||||||
},
|
},
|
||||||
Mon=>{
|
Mon=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
|
max=>0,
|
||||||
'00'=>0,
|
'00'=>0,
|
||||||
'01'=>0,
|
'01'=>0,
|
||||||
'02'=>0,
|
'02'=>0,
|
||||||
|
@ -118,6 +156,7 @@ sub new {
|
||||||
},
|
},
|
||||||
Tue=>{
|
Tue=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
|
max=>0,
|
||||||
'00'=>0,
|
'00'=>0,
|
||||||
'01'=>0,
|
'01'=>0,
|
||||||
'02'=>0,
|
'02'=>0,
|
||||||
|
@ -145,6 +184,7 @@ sub new {
|
||||||
},
|
},
|
||||||
Wed=>{
|
Wed=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
|
max=>0,
|
||||||
'00'=>0,
|
'00'=>0,
|
||||||
'01'=>0,
|
'01'=>0,
|
||||||
'02'=>0,
|
'02'=>0,
|
||||||
|
@ -172,6 +212,7 @@ sub new {
|
||||||
},
|
},
|
||||||
Thu=>{
|
Thu=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
|
max=>0,
|
||||||
'00'=>0,
|
'00'=>0,
|
||||||
'01'=>0,
|
'01'=>0,
|
||||||
'02'=>0,
|
'02'=>0,
|
||||||
|
@ -199,6 +240,7 @@ sub new {
|
||||||
},
|
},
|
||||||
Fri=>{
|
Fri=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
|
max=>0,
|
||||||
'00'=>0,
|
'00'=>0,
|
||||||
'01'=>0,
|
'01'=>0,
|
||||||
'02'=>0,
|
'02'=>0,
|
||||||
|
@ -226,6 +268,7 @@ sub new {
|
||||||
},
|
},
|
||||||
Sat=>{
|
Sat=>{
|
||||||
total=>0,
|
total=>0,
|
||||||
|
max=>0,
|
||||||
'00'=>0,
|
'00'=>0,
|
||||||
'01'=>0,
|
'01'=>0,
|
||||||
'02'=>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 {
|
sub dir {
|
||||||
my $self=$_[0];
|
my $self=$_[0];
|
||||||
|
@ -296,8 +354,11 @@ sub dir {
|
||||||
$self->{card}{$day}{total}++;
|
$self->{card}{$day}{total}++;
|
||||||
$self->{card}{total}++;
|
$self->{card}{total}++;
|
||||||
|
|
||||||
if ( $self->{card}{$day}{$hour} > $self->{card}{hourly_max}){
|
if ( $self->{card}{$day}{$hour} > $self->{card}{max}){
|
||||||
$self->{card}{hourly_max}=$self->{card}{$day}{$hour};
|
$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;
|
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{
|
sub get_card{
|
||||||
my $self=$_[0];
|
my $self=$_[0];
|
||||||
my $dir=$_[1];
|
my $dir=$_[1];
|
||||||
|
@ -316,6 +405,14 @@ sub get_card{
|
||||||
return $self->{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
|
=head1 AUTHOR
|
||||||
|
|
||||||
Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
|
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>
|
L<https://metacpan.org/release/Git-PunchCard>
|
||||||
|
|
||||||
|
=item * Primary Repo
|
||||||
|
|
||||||
|
L<https://gitea.eesdp.org/vvelox/Git-PunchCard/>
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue