Skip to content

Commit 47ccb73

Browse files
committed
add CALL-ME
1 parent 1393c25 commit 47ccb73

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

META6.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"perl" : "6.*",
33
"name" : "Archive::SimpleZip",
4-
"version" : "0.3.0",
4+
"version" : "0.4.0",
55
"description" : "Write Zip Files.",
66
"authors" : [ "Paul Marquess <pmqs@cpan.org>" ],
77
"tags" : [ "archive", "compression" ],

lib/Archive/SimpleZip.pm6

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
unit module Archive::SimpleZip:ver<0.3.0>:auth<Paul Marquess (pmqs@cpan.org)>;
2+
unit module Archive::SimpleZip:ver<0.4.0>:auth<Paul Marquess (pmqs@cpan.org)>;
33

44
need Compress::Zlib;
55
# need Compress::Bzip2; # disable for now
@@ -17,7 +17,7 @@ use CompUnit::Util :re-export;
1717
BEGIN re-export('Archive::SimpleZip::Headers');
1818

1919

20-
class SimpleZip is export
20+
class SimpleZip does Callable is export
2121
{
2222
has IO::Handle $!zip-filehandle ;
2323
has IO::Path $.filename ;
@@ -54,6 +54,16 @@ class SimpleZip is export
5454
if $!zip64 ;
5555
}
5656

57+
method CALL-ME(IO() $path, |c --> IO)
58+
{
59+
return $path
60+
unless $path ;
61+
62+
self.add($path, |c);
63+
64+
$path;
65+
}
66+
5767
multi method add(Str:D $string, |c --> Int:D)
5868
{
5969
# say "ADDING String [{$string.^name}][$string]";

t/002-basic.t

+37-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use lib 't';
66

77
use Test;
88

9-
plan 10;
9+
plan 11;
1010

1111
use ZipTest;
1212

@@ -289,6 +289,42 @@ subtest # List
289289

290290
}, "list";
291291

292+
subtest # List
293+
{
294+
use IO::Glob;
295+
unlink $zipfile;
296+
297+
my $dir2 = 'dir2';
298+
ok mkdir $dir2, 0o777;
299+
300+
my $datafile = "$dir2/gdata123";
301+
my $datafile1 = "gdata124";
302+
my $datafile2 = "gdata125";
303+
304+
spurt $datafile, "some data" ;
305+
spurt $datafile1, "more data" ;
306+
spurt $datafile2, "even more data" ;
307+
308+
ok $datafile.IO.e, "$datafile does exists";
309+
nok $zipfile.IO.e, "$zipfile does not exists";
310+
311+
my $zip = SimpleZip.new($zipfile);
312+
isa-ok $zip, SimpleZip;
313+
314+
my @got = glob("gdata*")>>.grep(/5/).$zip().subst(/"gdata"/, "fred");
315+
316+
ok $zip.close(), "closed";
317+
318+
is @got, 'fred125';
319+
is get-filenames-in-zip($zipfile), $datafile2, "filename OK";
320+
321+
unlink $zipfile;
322+
323+
# @got = glob("gdata*").dir.$zip().subst(/"gdata"/, "fred");
324+
325+
326+
}, "CALL-ME";
327+
292328
subtest
293329
{
294330
# Add file that doesn't exist

0 commit comments

Comments
 (0)