Skip to content

Commit

Permalink
add CALL-ME
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqs committed Jun 27, 2020
1 parent 1393c25 commit 47ccb73
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"perl" : "6.*",
"name" : "Archive::SimpleZip",
"version" : "0.3.0",
"version" : "0.4.0",
"description" : "Write Zip Files.",
"authors" : [ "Paul Marquess <pmqs@cpan.org>" ],
"tags" : [ "archive", "compression" ],
Expand Down
14 changes: 12 additions & 2 deletions lib/Archive/SimpleZip.pm6
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

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

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


class SimpleZip is export
class SimpleZip does Callable is export
{
has IO::Handle $!zip-filehandle ;
has IO::Path $.filename ;
Expand Down Expand Up @@ -54,6 +54,16 @@ class SimpleZip is export
if $!zip64 ;
}

method CALL-ME(IO() $path, |c --> IO)
{
return $path
unless $path ;

self.add($path, |c);

$path;
}

multi method add(Str:D $string, |c --> Int:D)
{
# say "ADDING String [{$string.^name}][$string]";
Expand Down
38 changes: 37 additions & 1 deletion t/002-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use lib 't';

use Test;

plan 10;
plan 11;

use ZipTest;

Expand Down Expand Up @@ -289,6 +289,42 @@ subtest # List

}, "list";

subtest # List
{
use IO::Glob;
unlink $zipfile;

my $dir2 = 'dir2';
ok mkdir $dir2, 0o777;

my $datafile = "$dir2/gdata123";
my $datafile1 = "gdata124";
my $datafile2 = "gdata125";

spurt $datafile, "some data" ;
spurt $datafile1, "more data" ;
spurt $datafile2, "even more data" ;

ok $datafile.IO.e, "$datafile does exists";
nok $zipfile.IO.e, "$zipfile does not exists";

my $zip = SimpleZip.new($zipfile);
isa-ok $zip, SimpleZip;

my @got = glob("gdata*")>>.grep(/5/).$zip().subst(/"gdata"/, "fred");

ok $zip.close(), "closed";

is @got, 'fred125';
is get-filenames-in-zip($zipfile), $datafile2, "filename OK";

unlink $zipfile;

# @got = glob("gdata*").dir.$zip().subst(/"gdata"/, "fred");


}, "CALL-ME";

subtest
{
# Add file that doesn't exist
Expand Down

0 comments on commit 47ccb73

Please sign in to comment.