Skip to content

Commit

Permalink
Pass separator along when tie'ing
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Dec 14, 2014
1 parent bfe376f commit 4c30e64
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
version: 0.84
date:
changes:
- Pass separator along when tie'ing (Fixes GH#52, Arthur Axel 'fREW' Schmidt)
- Add ->copy method (Arthur Axel 'fREW' Schmidt)
- Prefix private methods with underscores (Arthur Axel 'fREW' Schmidt)
---
Expand Down
2 changes: 1 addition & 1 deletion lib/IO/All/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sub assert_tied_file {
my $array_ref = do { my @array; \@array };
my $name = $self->pathname;
my @options = $self->_rdonly ? (mode => O_RDONLY) : ();
push @options, (recsep => "\n");
push @options, (recsep => $self->separator);
tie @$array_ref, 'Tie::File', $name, @options;
$self->throw("Can't tie 'Tie::File' to '$name':\n$!")
unless tied @$array_ref;
Expand Down
15 changes: 14 additions & 1 deletion test/autotie.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@ use IO_All_Test;

my $f = catfile($t, 'mystuff');
my @lines = read_file_lines($f);
plan(tests => 1 + @lines + 1);
plan(tests => 1 + @lines + 1 + 7);

{
my $io = io($f)->tie;
is($io->autoclose(0) . '', $f);
while (<$io>) {
is($_, shift @lines);
}
ok(close $io);
}

{
my $f = catfile($t, 'mystuff2');
my @lines = ('This ', 'is ', 'a ', 'silly ', "example\n");
my $io = io($f)->separator(q( ))->tie;
is($io->autoclose(0) . '', $f);
while (<$io>) {
is($_, shift @lines, $_);
}
ok(close $io);
}

del_output_dir();

0 comments on commit 4c30e64

Please sign in to comment.