Commits

Shlomi Fish committed f55c3c3

Got the tests to pass.

They test for ->new.

  • Participants
  • Parent commits 71a1319

Comments (0)

Files changed (3)

File-FindLines/module/MANIFEST

 Changes
 inc/Test/Run/Builder.pm
 lib/File/FindLines.pm
+lib/File/FindLines/Result/Context.pm
 lib/File/FindLines/Result.pm
-lib/File/FindLines/Result/Context.pm
 lib/File/FindLines/Result/Record.pm
 MANIFEST			This list of files
 README
 t/00-load.t
+t/Find-FileLines.t
 t/manifest.t
 t/pod-coverage.t
 t/pod.t

File-FindLines/module/lib/File/FindLines.pm

 package File::FindLines;
 
 use 5.006;
+
 use strict;
 use warnings;
 
+use Carp;
+
+use Class::XSAccessor
+    constructor => '_dont_use_me',
+    accessors => {
+        _iter_coderef => '_iter_coderef',
+        _filter_coderef => '_filter_coderef',
+    },
+    ;
+
 =head1 NAME
 
 File::FindLines - find records out of a stream that match certain qualities.
 
 =cut
 
-sub function1 {
+sub new
+{
+    my $class = shift;
+
+    my $self = {};
+    bless $self, $class;
+
+    $self->_init(@_);
+
+    return $self;
+}
+
+sub _init
+{
+    my ($self, $args) = @_;
+
+    $self->_iter_coderef($args->{input}->{code})
+        or Carp::confess "No input code ref specified.";
+
+    $self->_filter_coderef($args->{filter})
+        or Carp::confess "No filter code ref specified.";
+
+    return;
 }
 
 =head2 next

File-FindLines/module/t/Find-FileLines.t

 
 use Test::More tests => 1;
 
+use File::FindLines;
+
 {
+    my @lines =
+    (
+        "Ini\n",
+        "Mini\n",
+        "Foobar\n",
+        "Moo\n",
+    );
+
     my $finder = File::FindLines->new(
         {
             input => { code => sub { return shift(@lines); } },