[Bps-public-commit] net-lighthouse branch, master, updated. 19efaf0228dd7d60732ced2f0f2dfb0cdc1262d3
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Tue Sep 1 01:27:12 EDT 2009
The branch, master has been updated
via 19efaf0228dd7d60732ced2f0f2dfb0cdc1262d3 (commit)
from 24ca40b4b0520c6df03c9353cdd78769ab1a0eda (commit)
Summary of changes:
lib/Net/Lighthouse/Project.pm | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 19efaf0228dd7d60732ced2f0f2dfb0cdc1262d3
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 1 13:27:00 2009 +0800
enhance project->load with name as arg too
diff --git a/lib/Net/Lighthouse/Project.pm b/lib/Net/Lighthouse/Project.pm
index 69fecc1..7686be0 100644
--- a/lib/Net/Lighthouse/Project.pm
+++ b/lib/Net/Lighthouse/Project.pm
@@ -54,8 +54,21 @@ __PACKAGE__->meta->make_immutable;
sub load {
my $self = shift;
- validate_pos( @_, { type => SCALAR, regex => qr/^\d+$/ } );
+ validate_pos( @_, { type => SCALAR, regex => qr/^\d+|\w+$/ } );
my $id = shift;
+
+ if ( $id !~ /^\d$/ ) {
+
+ # so we got a project name, let's find it
+ my ( $project ) = grep { $_->name eq $id } $self->list;
+ if ($project) {
+ $id = $project->id;
+ }
+ else {
+ die "can't find project $id in account " . $self->account;
+ }
+ }
+
my $ua = $self->ua;
my $url = $self->base_url . '/projects/' . $id . '.xml';
my $res = $ua->get( $url );
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list