Algorithm-Diff-HTMLTable

 view release on metacpan or  search on metacpan

lib/Algorithm/Diff/HTMLTable.pm  view on Meta::CPAN

    return '' if !-f $file;

    my $mtime = (stat $file)[9];
    my $date  = _format_date( $mtime );

    return "$file<br />$date";
}

sub _format_date {
    my ($time) = @_;

    my $date = localtime $time;
    return $date->cdate;
}

sub _read_file {
    my ($self, $file) = @_;
    
    return if !$file;

    if ( ref $file && ref $file eq 'ARRAY' ) {
        return @{ $file };
    }

    return if !-r $file;
    
    my @lines;
    open my $fh, '<', $file;
    if ( $self->{encoding} ) {
        binmode $fh, ':encoding(' . $self->{encoding} . ')';
    }
    
    local $/ = $self->{eol} // "\n";
    
    @lines = <$fh>;
    close $fh;
    
    return @lines;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Algorithm::Diff::HTMLTable - Show differences of a file as a HTML table

=head1 VERSION

version 0.05

=head1 SYNOPSIS

    my $builder = Algorithm::Diff::HTMLTable->new(
       id       => 'diff_table',
       encoding => 'utf8',
    );
    
    $diff = $builder->diff( $sourcefile, $targetfile );

=head1 DESCRIPTION

=head1 METHODS

=head2 new

    my $builder = Algorithm::Diff::HTMLTable->new(
       id       => 'diff_table',
       encoding => 'utf8',
    );

Available options:

=over 4

=item * id

=item * encoding

=item * eol

=back

=head2 diff

    $diff = $builder->diff( $sourcefile, $targetfile );

=head1 AUTHOR

Renee Baecker <reneeb@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Renee Baecker.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

=cut



( run in 0.746 second using v1.01-cache-2.11-cpan-119454b85a5 )