[Bps-public-commit] r18477 - in Net-Trac/trunk: . inc/Module/Install lib/Net/Trac

jesse at bestpractical.com jesse at bestpractical.com
Thu Feb 19 18:11:18 EST 2009


Author: jesse
Date: Thu Feb 19 18:11:18 2009
New Revision: 18477

Modified:
   Net-Trac/trunk/META.yml
   Net-Trac/trunk/Makefile.PL
   Net-Trac/trunk/inc/Module/Install.pm
   Net-Trac/trunk/inc/Module/Install/AutoInstall.pm
   Net-Trac/trunk/inc/Module/Install/Base.pm
   Net-Trac/trunk/inc/Module/Install/Can.pm
   Net-Trac/trunk/inc/Module/Install/Fetch.pm
   Net-Trac/trunk/inc/Module/Install/Include.pm
   Net-Trac/trunk/inc/Module/Install/Makefile.pm
   Net-Trac/trunk/inc/Module/Install/Metadata.pm
   Net-Trac/trunk/inc/Module/Install/Win32.pm
   Net-Trac/trunk/inc/Module/Install/WriteAll.pm
   Net-Trac/trunk/lib/Net/Trac/Connection.pm
   Net-Trac/trunk/lib/Net/Trac/TicketHistory.pm
   Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm

Log:
Remove dependency on XML::Feed

Modified: Net-Trac/trunk/META.yml
==============================================================================
--- Net-Trac/trunk/META.yml	(original)
+++ Net-Trac/trunk/META.yml	Thu Feb 19 18:11:18 2009
@@ -3,7 +3,7 @@
 author:
   - 'Jesse Vincent <jesse at bestpractical.com>, Thomas Sibley <trs at bestpractical.com>'
 distribution_type: module
-generated_by: 'Module::Install version 0.77'
+generated_by: 'Module::Install version 0.79'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -15,7 +15,9 @@
     - t
 requires:
   Any::Moose: 0
+  DateTime: 0
   DateTime::Format::ISO8601: 0
+  HTTP::Date: 0
   IO::Scalar: 0
   LWP::Simple: 0
   Lingua::EN::Inflect: 0
@@ -24,7 +26,6 @@
   URI: 0
   URI::Escape: 0
   WWW::Mechanize: 1.52
-  XML::Feed: 0
 resources:
   license: http://dev.perl.org/licenses/
 version: 0.06

Modified: Net-Trac/trunk/Makefile.PL
==============================================================================
--- Net-Trac/trunk/Makefile.PL	(original)
+++ Net-Trac/trunk/Makefile.PL	Thu Feb 19 18:11:18 2009
@@ -9,12 +9,13 @@
 requires 'Any::Moose';
 requires 'URI';
 requires 'IO::Scalar';
-requires 'XML::Feed';
 requires 'Text::CSV_XS';
 requires 'LWP::Simple';
 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/inc/Module/Install.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install.pm	Thu Feb 19 18:11:18 2009
@@ -30,7 +30,7 @@
 	# This is not enforced yet, but will be some time in the next few
 	# releases once we can make sure it won't clash with custom
 	# Module::Install extensions.
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 
 	*inc::Module::Install::VERSION = *VERSION;
 	@inc::Module::Install::ISA     = __PACKAGE__;
@@ -250,7 +250,7 @@
 sub load_extensions {
 	my ($self, $path, $top) = @_;
 
-	unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) {
+	unless ( grep { !ref $_ and lc $_ eq lc $self->{prefix} } @INC ) {
 		unshift @INC, $self->{prefix};
 	}
 
@@ -366,4 +366,4 @@
 
 1;
 
-# Copyright 2008 Adam Kennedy.
+# Copyright 2008 - 2009 Adam Kennedy.

Modified: Net-Trac/trunk/inc/Module/Install/AutoInstall.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/AutoInstall.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/AutoInstall.pm	Thu Feb 19 18:11:18 2009
@@ -6,7 +6,7 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }

Modified: Net-Trac/trunk/inc/Module/Install/Base.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/Base.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/Base.pm	Thu Feb 19 18:11:18 2009
@@ -1,7 +1,7 @@
 #line 1
 package Module::Install::Base;
 
-$VERSION = '0.77';
+$VERSION = '0.79';
 
 # Suspend handler for "redefined" warnings
 BEGIN {

Modified: Net-Trac/trunk/inc/Module/Install/Can.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/Can.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/Can.pm	Thu Feb 19 18:11:18 2009
@@ -11,7 +11,7 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }

Modified: Net-Trac/trunk/inc/Module/Install/Fetch.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/Fetch.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/Fetch.pm	Thu Feb 19 18:11:18 2009
@@ -6,20 +6,20 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 
 sub get_file {
     my ($self, %args) = @_;
-    my ($scheme, $host, $path, $file) = 
+    my ($scheme, $host, $path, $file) =
         $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
 
     if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) {
         $args{url} = $args{ftp_url}
             or (warn("LWP support unavailable!\n"), return);
-        ($scheme, $host, $path, $file) = 
+        ($scheme, $host, $path, $file) =
             $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
     }
 

Modified: Net-Trac/trunk/inc/Module/Install/Include.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/Include.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/Include.pm	Thu Feb 19 18:11:18 2009
@@ -6,7 +6,7 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }

Modified: Net-Trac/trunk/inc/Module/Install/Makefile.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/Makefile.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/Makefile.pm	Thu Feb 19 18:11:18 2009
@@ -7,7 +7,7 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
@@ -64,7 +64,7 @@
 	my $self  = shift;
 	my $clean = $self->makemaker_args->{clean} ||= {};
 	  %$clean = (
-		%$clean, 
+		%$clean,
 		FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_),
 	);
 }
@@ -73,7 +73,7 @@
 	my $self      = shift;
 	my $realclean = $self->makemaker_args->{realclean} ||= {};
 	  %$realclean = (
-		%$realclean, 
+		%$realclean,
 		FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_),
 	);
 }
@@ -124,7 +124,7 @@
 
 	$self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
 
-	# Generate the 
+	# Generate the
 	my $args = $self->makemaker_args;
 	$args->{DISTNAME} = $self->name;
 	$args->{NAME}     = $self->module_name || $self->name;
@@ -196,7 +196,7 @@
 	my $top_class     = ref($self->_top) || '';
 	my $top_version   = $self->_top->VERSION || '';
 
-	my $preamble = $self->preamble 
+	my $preamble = $self->preamble
 		? "# Preamble by $top_class $top_version\n"
 			. $self->preamble
 		: '';

Modified: Net-Trac/trunk/inc/Module/Install/Metadata.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/Metadata.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/Metadata.pm	Thu Feb 19 18:11:18 2009
@@ -6,7 +6,7 @@
 
 use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
@@ -176,18 +176,15 @@
 		"Did not provide a value to perl_version()"
 	);
 
-	# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to
-	# numbers (eg, 5.006001 or 5.008009).
+	# Normalize the version
+	$version = $self->_perl_version($version);
 
-	$version =~ s/^(\d+)\.(\d+)\.(\d+)$/sprintf("%d.%03d%03d",$1,$2,$3)/e;
-
-	$version =~ s/_.+$//;
-	$version = $version + 0; # Numify
+	# We don't support the reall old versions
 	unless ( $version >= 5.005 ) {
 		die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n";
 	}
+
 	$self->{values}{perl_version} = $version;
-	return 1;
 }
 
 sub license {
@@ -451,9 +448,6 @@
 		while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
 			$pattern =~ s{\s+}{\\s+}g;
 			if ( $license_text =~ /\b$pattern\b/i ) {
-				if ( $osi and $license_text =~ /All rights reserved/i ) {
-					print "WARNING: 'All rights reserved' in copyright may invalidate Open Source license.\n";
-				}
 				$self->license($license);
 				return 1;
 			}
@@ -482,19 +476,70 @@
 	return 1;
 }
 
-sub install_script {
+# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to
+# numbers (eg, 5.006001 or 5.008009).
+# Also, convert double-part versions (eg, 5.8)
+sub _perl_version {
+	my $v = $_[-1];
+	$v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e;	
+	$v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e;
+	$v =~ s/(\.\d\d\d)000$/$1/;
+	$v =~ s/_.+$//;
+	if ( ref($v) ) {
+		$v = $v + 0; # Numify
+	}
+	return $v;
+}
+
+
+
+
+
+######################################################################
+# MYMETA.yml Support
+
+sub WriteMyMeta {
+	$_[0]->write_mymeta;
+}
+
+sub write_mymeta {
 	my $self = shift;
-	my $args = $self->makemaker_args;
-	my $exe  = $args->{EXE_FILES} ||= [];
-        foreach ( @_ ) {
-		if ( -f $_ ) {
-			push @$exe, $_;
-		} elsif ( -d 'script' and -f "script/$_" ) {
-			push @$exe, "script/$_";
-		} else {
-			die("Cannot find script '$_'");
+	
+	# If there's no existing META.yml there is nothing we can do
+	return unless -f 'META.yml';
+
+	# Merge the perl version into the dependencies
+	my $val  = $self->Meta->{values};
+	my $perl = delete $val->{perl_version};
+	if ( $perl ) {
+		$val->{requires} ||= [];
+		my $requires = $val->{requires};
+
+		# Canonize to three-dot version after Perl 5.6
+		if ( $perl >= 5.006 ) {
+			$perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e
 		}
+		unshift @$requires, [ perl => $perl ];
 	}
+
+	# Load the advisory META.yml file
+	require YAML::Tiny;
+	my @yaml = YAML::Tiny::LoadFile('META.yml');
+	my $meta = $yaml[0];
+
+	# Overwrite the non-configure dependency hashs
+	delete $meta->{requires};
+	delete $meta->{build_requires};
+	delete $meta->{recommends};
+	if ( exists $val->{requires} ) {
+		$meta->{requires} = { map { @$_ } @{ $val->{requires} } };
+	}
+	if ( exists $val->{build_requires} ) {
+		$meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } };
+	}
+
+	# Save as the MYMETA.yml file
+	YAML::Tiny::DumpFile('MYMETA.yml', $meta);
 }
 
 1;

Modified: Net-Trac/trunk/inc/Module/Install/Win32.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/Win32.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/Win32.pm	Thu Feb 19 18:11:18 2009
@@ -6,7 +6,7 @@
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }

Modified: Net-Trac/trunk/inc/Module/Install/WriteAll.pm
==============================================================================
--- Net-Trac/trunk/inc/Module/Install/WriteAll.pm	(original)
+++ Net-Trac/trunk/inc/Module/Install/WriteAll.pm	Thu Feb 19 18:11:18 2009
@@ -6,7 +6,7 @@
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.77';
+	$VERSION = '0.79';
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }

Modified: Net-Trac/trunk/lib/Net/Trac/Connection.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Connection.pm	(original)
+++ Net-Trac/trunk/lib/Net/Trac/Connection.pm	Thu Feb 19 18:11:18 2009
@@ -26,7 +26,6 @@
 
 use Any::Moose;
 
-use XML::Feed;
 use URI;
 use Text::CSV_XS;
 use IO::Scalar;
@@ -196,26 +195,6 @@
     else        { return }
 }
 
-=head2 _fetch_feed URL
-
-Fetches and parses a relative feed URL from the Trac server.  Warns if an error
-occurs and returns undef.  Otherwise returns an L<XML::Feed> object.
-
-=cut
-
-sub _fetch_feed {
-    my $self  = shift;
-    my $query = shift;
-    my $feed  = XML::Feed->parse( URI->new( $self->url . $query ) );
-
-    if ( not $feed ) {
-        warn XML::Feed->errstr;
-        return;
-    }
-
-    return $feed;
-}
-
 =head2 _csv_to_struct PARAMHASH
 
 Takes a paramhash of the keys C<data> and C<key> and optionally C<type>.

Modified: Net-Trac/trunk/lib/Net/Trac/TicketHistory.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/TicketHistory.pm	(original)
+++ Net-Trac/trunk/lib/Net/Trac/TicketHistory.pm	Thu Feb 19 18:11:18 2009
@@ -66,12 +66,19 @@
     # keywords
     my $temp_state = { %{ $ticket_obj->state()}};
 
-    my $feed = $self->connection->_fetch_feed( "/ticket/@{[$ticket_obj->id]}?format=rss" )
+    my $feed_content = $self->connection->_fetch( "/ticket/@{[$ticket_obj->id]}?format=rss" )
         or return;
 
+    my $entries = '';
+    if ($feed_content =~ m|^(?:.*?)<item>(.*)</item>(?:.*?)$|is) {
+        $entries = $1;
+    }
+
+    my @entries = split(m|</item>\s*<item>|, $entries);
+
     my @history;
     # Work on the newest entry first so we can back-calculate from the current state
-    foreach my $entry (reverse $feed->entries ) {
+    foreach my $entry (reverse @entries) {
         my $e = Net::Trac::TicketHistoryEntry->new({ connection => $self->connection });
         $e->parse_feed_entry($entry, $temp_state);
         # newest entry should be at the front of the list in the history later

Modified: Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm	(original)
+++ Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm	Thu Feb 19 18:11:18 2009
@@ -5,6 +5,8 @@
 
 use Any::Moose;
 use Net::Trac::TicketPropChange;
+use DateTime;
+use HTTP::Date;
 
 =head1 NAME
 
@@ -53,33 +55,50 @@
 
 =head2 parse_feed_entry
 
-Takes an L<XML::Feed::Entry> from a ticket history feed and parses it to fill
+Takes a feed entry from a ticket history feed and parses it to fill
 out the fields of this class.
 
 =cut
 
 sub parse_feed_entry {
     my $self = shift;
-    my $e    = shift;    # XML::Feed::Entry
+    my $e    = shift; 
 
     # We use a reference to a copy of ticket state as it was after this feed 
     # entry to interpret what "x added, y removed" meant for absolute values
     # of keywords
 
     my $ticket_state = shift; 
-    
-    $self->author( $e->author );
-    $self->date( $e->issued );
-    $self->category( $e->category );
 
-    my $desc = $e->content->body;
+    if ($e =~ m|<dc:creator>(.*?)</dc:creator>|is) {
+        my $author = $1;
+        $self->author( $author );
+    }
+
+    if ($e =~ m|<pubDate>(.*?)</pubDate>|is) {
+        my $date = $1;
+        $self->date(DateTime->from_epoch(epoch => str2time($date)));
+    }
+
+    if ($e =~ m|<category>(.*?)</category>|is) {
+        my $c = $1;
+        $self->category($c);
+    }
+
+ 
+    if ($e =~ m|<description>\s*(.*?)\s*</description>|is) {
+        my $desc = $1;
+        $desc =~ s/>/>/gi;
+        $desc =~ s/</</gi;
+        $desc =~ s/&/&/gi;
+        
     if ( $desc =~ s|^\s*?<ul>(.*)</ul>||is) {
         my $props = $1;
         $self->prop_changes( $self->_parse_props($props, $ticket_state) );
     }
 
     $self->content($desc);
-
+    }
 }
 
 sub _parse_props {



More information about the Bps-public-commit mailing list