Created
June 13, 2011 14:05
-
-
Save kuzuha/1022831 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.12.1; | |
use warnings; | |
use Plack::Request; | |
use Router::Simple; | |
use FindBin; | |
use AnyEvent::Util qw(run_cmd); | |
my $router = Router::Simple->new(); | |
my @tap = (); | |
my $builder = "/Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/ | |
builder.py"; | |
my $pid; | |
$router->connect('/', { | |
action => sub { | |
say "[" . localtime() . "] start building"; | |
kill 2, $pid if $pid; | |
`coffee -o $FindBin::Bin/Resources -c $FindBin::Bin/Resourcaes/coffee &> | |
/dev/null`; | |
run_cmd [$builder, "run", $FindBin::Bin], | |
'>' => '/dev/null', | |
'2>' => '/dev/null', | |
'$$' => \$pid,; | |
} | |
}); | |
$router->connect('/tap', { | |
action => sub { | |
say my $current = shift->param('tap'); | |
push @tap, $current; | |
if ($current =~ /^\d+\.\.\d+$/) { | |
open my $fh, '>', 'Gatherer'; | |
say $fh 'print while <DATA>;'; | |
say $fh '__DATA__'; | |
print $fh join "\n", @tap; | |
close $fh; | |
say `prove --harness TAP::Harness::JUnit Gatherer 2> /dev/null`; | |
unlink('Gatherer'); | |
@tap = (); | |
} | |
} | |
}); | |
my $app = sub { | |
my $env = shift; | |
if (my $p = $router->match($env)) { | |
$p->{action}->(Plack::Request->new($env)); | |
[200, [], ['']] | |
} else { | |
[404, [], ['not found']]; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment