Commits

Anonymous committed a2d160a

Correct the tests.

Comments (0)

Files changed (5)

File-Format-CRD/Changes

 Revision history for File-Format-CRD
 
-0.01    Date/time
+0.0.1
         First version, released on an unsuspecting world.
 

File-Format-CRD/README

 File-Format-CRD
 
-The README is used to introduce the module and provide instructions on
-how to install the module, any machine dependencies it may have (for
-example C compilers and installed libraries) and any other information
-that should be provided before the module is installed.
+This is a distribution for reading the Windows Card database (.CRD) format.
+It is based on this C code:
 
-A README file is required for CPAN modules since CPAN extracts the README
-file from a module distribution so that people browsing the archive
-can use it to get an idea of the module's uses. It is usually a good idea
-to provide version information here so that people can decide whether
-fixes for the module are worth downloading.
-
+http://ihaa.com/english/crd2html.html
 
 INSTALLATION
 

File-Format-CRD/lib/File/Format/CRD.pm

 
 =head1 NAME
 
-File::Format::CRD - The great new File::Format::CRD!
+File::Format::CRD - Distribution for reading the Windows CRD format.
 
 =head1 VERSION
 
-Version 0.01
+Version 0.0.1
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.0.1';
 
 
 =head1 SYNOPSIS
 
-Quick summary of what the module does.
-
-Perhaps a little code snippet.
-
-    use File::Format::CRD;
-
-    my $foo = File::Format::CRD->new();
-    ...
-
-=head1 EXPORT
-
-A list of functions that can be exported.  You can delete this section
-if you don't export anything, such as for a purely object-oriented module.
-
-=head1 FUNCTIONS
-
-=head2 function1
-
-=cut
-
-sub function1 {
-}
-
-=head2 function2
-
-=cut
-
-sub function2 {
-}
-
-=head1 AUTHOR
-
-Shlomi Fish, C<< <shlomif at iglu.org.il> >>
-
-=head1 BUGS
-
-Please report any bugs or feature requests to C<bug-file-format-crd at rt.cpan.org>, or through
-the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Format-CRD>.  I will be notified, and then you'll
-automatically be notified of progress on your bug as I make changes.
-
-
-
+See L<File::Format::CRD::Reader> .
 
 =head1 SUPPORT
 

File-Format-CRD/lib/File/Format/CRD/Reader.pm

 
 use Encode;
 
+use Fcntl qw(SEEK_SET);
+
 =head1 NAME
 
 File::Format::CRD::Reader - read Windows .CRD files.
             $card->{'body'}, "\n>>>\n\n";
     }
 
+=head1 METHODS
+
+=head2 File::Format::CRD::Reader->new({filename => $filename});
+
+Open CRD file $filename for reading.
+
 =cut
 
 sub new
 
     my $filename = $args->{'filename'};
 
-    my $in = open, "<", $filename
+    open my $in, "<", $filename
         or Carp::confess "Could not open '$filename'";
 
     $self->{_fh} = $in;
     return;
 }
 
+=head2 $self->get_num_cards()
+
+Get the number of cards.
+
+=cut
+
 sub get_num_cards
 {
     return shift->{_num_cards};
 {
     my $self = shift;
 
-    $self->end();
+    $self->finish();
 
     return;
 }
 
-sub end
+=head2 $self->finish()
+
+Clean up and finish. Can no longer read cards after that.
+
+=cut
+
+sub finish
 {
     my $self = shift;
 
     return;
 }
 
+=head2 $self->get_next_card({encoding => "windows-1255"})
+
+Get the next card. Returns undef or the empty list at the end of the file,
+and a hash-ref like that upon success:
+
+    {
+        'title' => "My Card",
+        'body' => "Body of card\nHello",
+    }
+
+The encoding parameter C<'encoding'> can be used to decode the card using a 
+certain encoding.
+
+=cut
+
 sub get_next_card
 {
     my $self = shift;
-    my $args = shift;
+    my $args = shift || {};
 
     my $encoding = $args->{'encoding'};
 
 
         if (defined($encoding))
         {
-            return decode($encoding, $title);
+            return decode($encoding, $text);
         }
         else
         {

File-Format-CRD/t/boilerplate.t

 
 use strict;
 use warnings;
+
 use Test::More tests => 4;
 
 sub not_in_file_ok {
     );
 }
 
-TODO: {
-  local $TODO = "Need to replace the boilerplate text";
+{
 
   not_in_file_ok(README =>
     "The README is used..."       => qr/The README is used/,