Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit e8d86e4361f03640f860315a73742bbfa01b2379 @typester committed Oct 23, 2008
Showing with 621 additions and 0 deletions.
  1. +4 −0 .shipit
  2. +14 −0 Changes
  3. +381 −0 LICENSE
  4. +26 −0 MANIFEST
  5. +14 −0 MANIFEST.SKIP
  6. +8 −0 Makefile.PL
  7. +27 −0 README
  8. +82 −0 lib/Array/Diff.pm
  9. +9 −0 t/001_load.t
  10. +4 −0 t/002_pod.t
  11. +7 −0 t/003_podcoverage.t
  12. +32 −0 t/004_diff.t
  13. +4 −0 t/00_compile.t
  14. +4 −0 t/pod.t
  15. +5 −0 t/pod_coverage.t
@@ -0,0 +1,4 @@
+steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN
+
+git.tagpattern = %v
+git.push_to = origin
14 Changes
@@ -0,0 +1,14 @@
+Revision history for Perl module Array::Diff
+
+0.04 2006-09-02T13:14:13+09:00
+ - added count method that returns diff count
+
+0.03 2006-05-24T10:46:50+09:00
+ - fixed a diff bug.
+
+0.02 2006-04-04T17:42:18+09:00
+ - fixes no_plan => 1 in 004_diff.t
+ - no code changes
+
+0.01 2006-04-04T17:16:43+09:00
+ - original version; created by ExtUtils::ModuleMaker 0.44
381 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,26 @@
+Changes
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Include.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/TestBase.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+inc/Spiffy.pm
+inc/Test/Base.pm
+inc/Test/Base/Filter.pm
+inc/Test/Builder.pm
+inc/Test/Builder/Module.pm
+inc/Test/More.pm
+lib/Array/Diff.pm
+LICENSE
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+t/00_compile.t
+t/pod.t
+t/pod_coverage.t
@@ -0,0 +1,14 @@
+\bRCS\b
+\bCVS\b
+^MANIFEST\.
+^Makefile$
+~$
+\.old$
+^blib/
+^pm_to_blib
+^MakeMaker-\d
+\.gz$
+\.cvsignore
+^9\d_.*\.t
+^\.git/
+^\.shipit$
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name 'Array-Diff';
+all_from 'lib/Array/Diff.pm';
+
+test_requires 'Test::More';
+use_test_base;
+auto_include;
+WriteAll;
27 README
@@ -0,0 +1,27 @@
+This is Perl module Array::Diff.
+
+INSTALLATION
+
+Array::Diff installation is straightforward. If your CPAN shell is set up,
+you should just be able to do
+
+ % cpan Array::Diff
+
+Download it, unpack it, then build it as per the usual:
+
+ % perl Makefile.PL
+ % make && make test
+
+Then install it:
+
+ % make install
+
+DOCUMENTATION
+
+Array::Diff documentation is available as in POD. So you can do:
+
+ % perldoc Array::Diff
+
+to read the documentation online with your favorite pager.
+
+Daisuke Murase
@@ -0,0 +1,82 @@
+package Array::Diff;
+use strict;
+use warnings;
+use base qw/Class::Accessor::Fast/;
+
+use Algorithm::Diff;
+
+our $VERSION = '0.04';
+
+__PACKAGE__->mk_accessors(qw/added deleted count/);
+
+=head1 NAME
+
+Array::Diff - Diff two arrays
+
+=head1 SYNOPSIS
+
+ my @old = ( 'a', 'b', 'c' );
+ my @new = ( 'b', 'c', 'd' );
+
+ my $diff = Array::Diff->diff( \@old, \@new );
+
+ $diff->count # 2
+ $diff->added # [ 'd' ];
+ $diff->deleted # [ 'a' ];
+
+=head1 DESCRIPTION
+
+This module do diff two arrays, and return added and deleted arrays.
+It's simple usage of Algorithm::Diff.
+
+And if you need more complex array tools, check L<Array::Compare>.
+
+=head1 SEE ALSO
+
+L<Algorithm::Diff>
+
+=head1 METHODS
+
+=head2 diff
+
+=cut
+
+sub diff {
+ my ( $self, $old, $new ) = @_;
+ $self = $self->new unless ref $self;
+
+ $self->added( [] );
+ $self->deleted( [] );
+ $self->count( 0 );
+
+ my $diff = Algorithm::Diff->new( $old, $new );
+ while ( $diff->Next ) {
+ next if $diff->Same;
+
+ $self->{count}++;
+
+ push @{ $self->{deleted} }, $diff->Items(1)
+ if $diff->Items(1);
+
+ push @{ $self->{added} }, $diff->Items(2)
+ if $diff->Items(2);
+ }
+
+ $self;
+}
+
+=head1 AUTHOR
+
+Daisuke Murase <typester@cpan.org>
+
+=head1 COPYRIGHT
+
+This program is free software; you can redistribute
+it and/or modify it under the same terms as Perl itself.
+
+The full text of the license can be found in the
+LICENSE file included with this module.
+
+=cut
+
+1;
@@ -0,0 +1,9 @@
+# -*- perl -*-
+
+# t/001_load.t - check module loading and create testing directory
+
+use Test::More tests => 1;
+
+BEGIN { use_ok( 'Array::Diff' ); }
+
+
@@ -0,0 +1,4 @@
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
@@ -0,0 +1,7 @@
+use Test::More;
+eval "use Test::Pod::Coverage";
+plan skip_all => "Test::Pod::Coverage required for testing pod coverage"
+ if $@;
+
+plan tests => 1;
+pod_coverage_ok("Array::Diff");
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 9;
+
+my $m;
+BEGIN {
+ use_ok( $m = 'Array::Diff' );
+}
+
+can_ok( $m, 'new' );
+can_ok( $m, 'diff' );
+can_ok( $m, 'added' );
+can_ok( $m, 'deleted' );
+can_ok( $m, 'count' );
+
+my $old = [ 'a', 'b', 'c' ];
+my $new = [ 'b', 'c', 'd' ];
+
+my $diff_expected_added = ['d'];
+my $diff_expected_deleted = ['a'];
+my $diff;
+eval {
+ $diff = $m->diff( $old, $new );
+};
+
+is( $diff->count, 2, 'diff count is ok' );
+is_deeply( $diff->added, $diff_expected_added, "added list correctly" );
+is_deeply( $diff->deleted, $diff_expected_deleted, "deleted list correctly" );
+
@@ -0,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Array::Diff' }
@@ -0,0 +1,4 @@
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
@@ -0,0 +1,5 @@
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage"
+ if $@;
+all_pod_coverage_ok();

0 comments on commit e8d86e4

Please sign in to comment.