diff --git a/Build.PL b/Build.PL index 9e46c6c..462b7a7 100644 --- a/Build.PL +++ b/Build.PL @@ -13,8 +13,9 @@ my $builder = Module::Build->new( 'Test::Most' => 0, }, requires => { - 'YAML' => 0, - 'Dancer' => 1.3040, + 'YAML' => 0, + 'Dancer' => 1.3040, + 'Archive::Zip' => 0, }, add_to_cleanup => [ 'App-Parrot-Create-*' ], meta_merge => { diff --git a/bin/new_parrot_language.pl b/bin/new_parrot_language.pl index 5298aad..e4d4897 100755 --- a/bin/new_parrot_language.pl +++ b/bin/new_parrot_language.pl @@ -70,8 +70,6 @@ =head1 DESCRIPTION use File::Spec; use Getopt::Long; -use Parrot::Config qw/ %PConfig /; - my ($with_doc, $with_ops, $with_pmc); GetOptions( 'with-doc' => \$with_doc, @@ -117,7 +115,8 @@ =head1 DESCRIPTION s{\@no_ops\@} {$no_ops}ig; s{\@no_pmc\@} {$no_pmc}ig; s{\@rev\@} {$rev}ig; - if (/^__(.*)__$/) { start_new_file("$path$PConfig{slash}$1"); } + # TODO: slashitis + if (/^__(.*)__$/) { start_new_file("$path/$1"); } elsif ($fh) { print $fh $_; } } ## close the last file diff --git a/lib/App/Parrot/Create.pm b/lib/App/Parrot/Create.pm index ed0c855..a52252e 100644 --- a/lib/App/Parrot/Create.pm +++ b/lib/App/Parrot/Create.pm @@ -1,5 +1,6 @@ package App::Parrot::Create; use Dancer ':syntax'; +use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); our $VERSION = '0.1'; @@ -10,6 +11,22 @@ get '/' => sub { get '/submit' => sub { my ($name, $builder, $harness) = map { param($_) } qw/language_name builder test_harness/; + $name =~ s/[^A-z]*//g; + + my $time = time; + my $tmp_base = "/tmp/app-parrot-create"; + my $dir = "$tmp_base/$time/$name"; + + my @args = ($^X,"bin/new_parrot_language.pl",$name, $dir); + system @args; + + my $zip = Archive::Zip->new(); + my $dir_member = $zip->addDirectory("$dir/"); + + unless ( $zip->writeToFileNamed("$dir.zip") == AZ_OK ) { + die 'write error'; + } + template 'submit', { name => $name, builder => $builder, harness => $harness }; };