Skip to content

Commit

Permalink
Slurping up everything from my local repo
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Apr 16, 2007
0 parents commit 6c5eb33
Show file tree
Hide file tree
Showing 14 changed files with 1,084 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Changes
@@ -0,0 +1,12 @@
Revision history for App-HWD

0.02 Mon Aug 1 14:32:29 PDT 2005
[FIXES]
* Fixes silly syntax bummers.

[ENHANCEMENTS]
* Added --nextid

0.01
First version, released on an unsuspecting world.

73 changes: 73 additions & 0 deletions HWD.pm
@@ -0,0 +1,73 @@
package App::HWD;

use warnings;
use strict;

=head1 NAME
App::HWD - The great new App::HWD!
=head1 VERSION
Version 0.02
=cut

our $VERSION = '0.02';

=head1 SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
use App::HWD;
my $foo = App::HWD->new();
...
=head1 EXPORT
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.
=head1 FUNCTIONS
=head2 function1
=cut

sub function1 {
}

=head2 function2
=cut

sub function2 {
}

=head1 AUTHOR
Andy Lester, C<< <andy@petdance.com> >>
=head1 BUGS
Please report any bugs or feature requests to
C<bug-app-hwd@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-HWD>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
=head1 ACKNOWLEDGEMENTS
=head1 COPYRIGHT & LICENSE
Copyright 2005 Andy Lester, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut

1; # End of App::HWD
15 changes: 15 additions & 0 deletions MANIFEST
@@ -0,0 +1,15 @@
Changes
MANIFEST
Makefile.PL
README
HWD.pm
Task.pm
Work.pm
bin/hwd
eg/sked.txt
t/00-load.t
t/pod-coverage.t
t/pod.t
t/task.t
t/work.t
META.yml Module meta-data (added by MakeMaker)
37 changes: 37 additions & 0 deletions Makefile.PL
@@ -0,0 +1,37 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;

WriteMakefile(
NAME => 'App::HWD',
AUTHOR => 'Andy Lester <andy@petdance.com>',
VERSION_FROM => 'HWD.pm',
ABSTRACT_FROM => 'HWD.pm',
PL_FILES => {},
EXE_FILES => [ 'bin/hwd' ],
PM => {
'HWD.pm' => '$(INST_LIBDIR)/HWD.pm',
'Task.pm' => '$(INST_LIBDIR)/HWD/Task.pm',
'Work.pm' => '$(INST_LIBDIR)/HWD/Work.pm',
},
PREREQ_PM => {
'Test::More' => 0,
'Getopt::Long' => 0,
'Pod::Usage' => 0,
},
MAN3PODS => { }, # no need for docs on these
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'App-HWD-*' },
);

sub MY::postamble {
return <<'MAKE_FRAG';
.PHONY: tags
tags:
ctags -f tags --recurse --totals \
--exclude=blib/ --exclude=t/lib \
--exclude=.svn --exclude='*~' \
--languages=Perl --langmap=Perl:+.t \
MAKE_FRAG
}
29 changes: 29 additions & 0 deletions README
@@ -0,0 +1,29 @@
App-HWD

The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.

A README file is required for CPAN modules since CPAN extracts the README
file from a module distribution so that people browsing the archive
can use it get an idea of the modules uses. It is usually a good idea
to provide version information here so that people can decide whether
fixes for the module are worth downloading.

INSTALLATION

To install this module, run the following commands:

perl Makefile.PL
make
make test
make install


COPYRIGHT AND LICENCE

Copyright (C) 2005 Andy Lester

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
200 changes: 200 additions & 0 deletions Task.pm
@@ -0,0 +1,200 @@
package App::HWD::Task;

use warnings;
use strict;

=head1 NAME
App::HWD::Task - Tasks for HWD
=head1 SYNOPSIS
Used only by the F<hwd> application.
Note that these functions are pretty fragile, and do almost no data
checking.
=head1 FUNCTIONS
=head2 App::HWD::Task->parse()
Returns an App::HWD::Task object from an input line
=cut

sub parse {
my $class = shift;
my $line = shift;

my $line_regex = qr/
^
(-+) # leading dashes
\s* # whitespace
(.+) # everything else
$
/x;

if ( $line =~ $line_regex ) {
my $level = length $1;
my $name = $2;
my $id;
my $estimate;

if ( $name =~ s/\s*\(([^)]+)\)$// ) {
my $parens = $1;
my @subfields = split /,/, $parens;
for ( @subfields ) {
s/^\s+//;
s/\s+$//;
/^#(\d+)$/ and $id = $1, next;
/^(\d+)h$/ and $estimate = $1, next;
warn "Don't understand $_";
}
}

my $task = $class->new( {
level => $level,
name => $name,
id => $id,
estimate => $estimate,
} );
}
else {
return;
}
}

=head2 App::HWD::Task->new( { args } )
Creates a new task from the args passed in. They should include at
least I<level>, I<name> and I<id>, even if I<id> is C<undef>.
my $task = App::HWD::Task->new( {
level => $level,
name => $name,
id => $id,
estimate => $estimate,
} );
=cut

sub new {
my $class = shift;
my $args = shift;

my $self = bless {
%$args,
work => [],
}, $class;

return $self;
}

=head2 $task->level()
Returns the level of the task
=head2 $task->name()
Returns the name of the task
=head2 $task->id()
Returns the ID of the task, or the empty string if there isn't one.
=head2 $task->estimate()
Returns the estimate, or 0 if it's not set.
=cut

sub level { return shift->{level} }
sub name { return shift->{name} }
sub id { return shift->{id} || "" }
sub estimate { return shift->{estimate} || 0 }

=head2 $task->set( $key => $value )
Sets the I<$key> field to I<$value>.
=cut

sub set {
my $self = shift;
my $key = shift;
my $value = shift;

die "Dupe key $key" if exists $self->{$key};
$self->{$key} = $value;
}

=head2 add_work( $work )
Adds a Work record to the task, for later accumulating
=cut

sub add_work {
my $self = shift;
my $work = shift;

push( @{$self->{work}}, $work );
}

=head2 hours_worked()
Returns the number of hours worked, but counting up all the work records added in L</add_work>.
=cut

sub hours_worked {
my $self = shift;

my $hours = 0;
for my $work ( @{$self->{work}} ) {
$hours += $work->hours;
}
return $hours;
}

=head2 completed()
Returns whether the task has been completed.
=cut

sub completed {
my $self = shift;

my $completed = 0;
for my $work ( @{$self->{work}} ) {
$completed = $work->completed;
}

return $completed;
}

=head1 AUTHOR
Andy Lester, C<< <andy at petdance.com> >>
=head1 BUGS
Please report any bugs or feature requests to
C<bug-app-hwd-task@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-HWD>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
=head1 ACKNOWLEDGEMENTS
=head1 COPYRIGHT & LICENSE
Copyright 2005 Andy Lester, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut

1; # End of App::HWD::Task

0 comments on commit 6c5eb33

Please sign in to comment.