[Bps-public-commit] r18515 - in Net-Trac/trunk: .
jesse at bestpractical.com
jesse at bestpractical.com
Sat Feb 21 20:17:32 EST 2009
Author: jesse
Date: Sat Feb 21 20:17:31 2009
New Revision: 18515
Modified:
Net-Trac/trunk/META.yml
Net-Trac/trunk/Makefile.PL
Net-Trac/trunk/lib/Net/Trac/Ticket.pm
Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm
Log:
Switch to using a custom DateTime parser to shed 7 dependencies
Stop fetching ticket update information on ticket load
Modified: Net-Trac/trunk/META.yml
==============================================================================
--- Net-Trac/trunk/META.yml (original)
+++ Net-Trac/trunk/META.yml Sat Feb 21 20:17:31 2009
@@ -16,11 +16,11 @@
requires:
Any::Moose: 0
DateTime: 0
- DateTime::Format::ISO8601: 0
HTTP::Date: 0
LWP::Simple: 0
Lingua::EN::Inflect: 0
Params::Validate: 0
+ Text::CSV: 0
URI: 0
URI::Escape: 0
WWW::Mechanize: 1.52
Modified: Net-Trac/trunk/Makefile.PL
==============================================================================
--- Net-Trac/trunk/Makefile.PL (original)
+++ Net-Trac/trunk/Makefile.PL Sat Feb 21 20:17:31 2009
@@ -12,7 +12,6 @@
requires 'Params::Validate';
requires 'WWW::Mechanize' => '1.52';
requires 'DateTime';
-requires 'DateTime::Format::ISO8601';
requires 'HTTP::Date';
requires 'Lingua::EN::Inflect';
requires 'URI::Escape';
Modified: Net-Trac/trunk/lib/Net/Trac/Ticket.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Ticket.pm (original)
+++ Net-Trac/trunk/lib/Net/Trac/Ticket.pm Sat Feb 21 20:17:31 2009
@@ -25,7 +25,7 @@
use Any::Moose;
use Params::Validate qw(:all);
use Lingua::EN::Inflect qw();
-use DateTime::Format::ISO8601;
+use DateTime;
use Net::Trac::TicketSearch;
use Net::Trac::TicketHistory;
@@ -86,14 +86,31 @@
*{ "Net::Trac::Ticket::" . $prop } = sub { shift->state->{$prop} };
}
-sub created { shift->_time_to_datetime('time') }
-sub last_modified { shift->_time_to_datetime('changetime') }
+sub created { my $self= shift; $self->timestamp_to_datetime($self->time) }
+sub last_modified { my $self= shift; $self->timestamp_to_datetime($self->changetime) }
-sub _time_to_datetime {
- my ($self, $prop) = @_;
- my $time = $self->$prop;
- $time =~ s/ /T/;
- return DateTime::Format::ISO8601->parse_datetime( $time );
+=head2 timestamp_to_datetime $stamp
+
+Accept's a timestamp in Trac's somewhat idiosyncratic format and returns a DateTime object
+
+=cut
+
+sub timestamp_to_datetime {
+ my ( $self, $prop ) = @_;
+ if ( $prop =~ /^(\d{4})-(\d\d)-(\d\d)T?(\d\d):(\d\d):(\d\d)(?:Z?([+-][\d:]+))?/ ) {
+ my ( $year, $month, $day, $hour, $min, $sec, $offset) =
+ ( $1, $2, $3, $4, $5, $6, $7 );
+
+ $offset =~ s/://;
+ return DateTime->new(
+ year => $year,
+ month => $month,
+ day => $day,
+ hour => $hour,
+ minute => $min,
+ second => $sec,
+ time_zone => $offset);
+ }
}
sub BUILD {
@@ -160,7 +177,6 @@
return undef unless $hash and $hash->{'id'};
$self->state( $hash );
- $self->_fetch_update_ticket_metadata unless $skip_metadata;
return $hash->{'id'};
}
@@ -194,7 +210,9 @@
return 1 if $LOADED_NEW_METADATA;
my ($form, $form_num) = $self->_get_new_ticket_form;
- return undef unless $form;
+ unless ( $form ) {
+ return undef;
+ }
$self->valid_milestones([ $form->find_input("field_milestone")->possible_values ]);
$self->valid_types ([ $form->find_input("field_type")->possible_values ]);
@@ -211,10 +229,10 @@
my $self = shift;
return 1 if $LOADED_UPDATE_METADATA;
-
my ($form, $form_num) = $self->_get_update_ticket_form;
- return undef unless $form;
-
+ unless ($form) {
+ return undef;
+ }
my $resolutions = $form->find_input("action_resolve_resolve_resolution");
$self->valid_resolutions( [$resolutions->possible_values] ) if $resolutions;
Modified: Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm (original)
+++ Net-Trac/trunk/lib/Net/Trac/TicketAttachment.pm Sat Feb 21 20:17:31 2009
@@ -4,7 +4,6 @@
package Net::Trac::TicketAttachment;
use Any::Moose;
-use DateTime::Format::ISO8601;
=head1 NAME
@@ -88,10 +87,8 @@
$self->author($1) if $html =~ qr{added by <em>(.+?)</em>};
if ( $html =~ qr{<a (?:.+?) title="(.+?) in Timeline">} ) {
my $scalar_date = $1;
- $scalar_date =~ s/Z//;
- $scalar_date =~ s/([+-]\d\d)(\d\d)$/$1:$2/;
- $self->date( DateTime::Format::ISO8601->parse_datetime($scalar_date) );
- }
+ $self->date( Net::Trac::Ticket->timestamp_to_datetime($scalar_date));
+ }
$self->description($1) if $html =~ qr{<dd>\s*(\S.*?)\s*</dd>\s*$};
return 1;
More information about the Bps-public-commit
mailing list