Skip to content

Commit

Permalink
Handle the case where a change starts with no leading whitespace, and…
Browse files Browse the repository at this point in the history
… still parse continuation lines correctly.
  • Loading branch information
autarch committed Feb 10, 2011
1 parent 7c44068 commit 2cbfb38
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/CPAN/Changes.pm
Expand Up @@ -71,9 +71,11 @@ sub load_string {


next if $l =~ m{^\s*$}; next if $l =~ m{^\s*$};


if ( !$indent ) { if ( !defined $indent ) {
$l =~ m{^(\s+)}; $indent
$indent = '\s' x length $1; = $l =~ m{^(\s+)}
? '\s' x length $1
: '';
} }


$l =~ s{^$indent}{}; $l =~ s{^$indent}{};
Expand Down
3 changes: 3 additions & 0 deletions t/corpus/no-leading-space-for-change.changes
@@ -0,0 +1,3 @@
0.01 2010-06-16
- Initial release
This line is part of the first
31 changes: 31 additions & 0 deletions t/read_no-leading-space-for-change.t
@@ -0,0 +1,31 @@
use strict;
use warnings;

use Test::More;

use_ok( 'CPAN::Changes' );

my $changes = CPAN::Changes->load( 't/corpus/no-leading-space-for-change.changes' );

isa_ok( $changes, 'CPAN::Changes' );
is( $changes->preamble, '', 'no preamble' );

my @releases = $changes->releases;

is( scalar @releases, 1, 'has 1 release' );
isa_ok( $releases[ 0 ], 'CPAN::Changes::Release' );
is( $releases[ 0 ]->version, '0.01', 'version' );
is( $releases[ 0 ]->date, '2010-06-16', 'date' );
is_deeply(
$releases[ 0 ]->changes,
{ '' => [ "Initial release This line is part of the first" ] },
'full changes'
);
is_deeply( [ $releases[ 0 ]->groups ], [ '' ], 'only the main group' );
is_deeply(
$releases[ 0 ]->changes( '' ),
[ "Initial release This line is part of the first" ],
'one change line'
);

done_testing;

0 comments on commit 2cbfb38

Please sign in to comment.