Skip to content
Browse files

Refactoring

  • Loading branch information...
1 parent 3a25b34 commit 5744b17120fdccf275e330233a6ef13aad53a05f @tadzik committed Sep 23, 2010
Showing with 34 additions and 60 deletions.
  1. +3 −8 README
  2. +22 −46 bin/neutro
  3. +9 −6 bin/smoker.pl
View
11 README
@@ -2,12 +2,6 @@ neutro is a module installer for Perl 6.
It's a temporary working solution, while experts build
the Real Deal (proto, pls). The difference is that neutro works :)
-It uses its own database (based on proto's one) using
-the actual module names (like Acme::Meow) rather than
-github's repo names (like perl6-Acme-Meow).
-
-It probably won't work on anything besides Unixes.
-
Patches, ideas and criticism welcome.
Bootstraping:
@@ -18,5 +12,6 @@ this:
PERL6LIB=tmplib bin/neutro i neutro
Usage:
-./neutro l
-./neutro i Acme::Meow
+neutro update
+neutro list
+neutro perl6-Acme-Meow
View
68 bin/neutro
@@ -9,7 +9,7 @@ use LWP::Simple;
my $home = ($*VM<config><osname> eq 'MSWin32')
?? %*ENV<HOMEPATH> !! %*ENV<HOME>;
my $CONFIGDIR = "$home/.neutro";
-my $INSTALLDIR = "$home/.perl6";
+my $INSTALLDIR = %*ENV<DESTDIR> // "$home/.perl6";
my $INSTALLED = "$CONFIGDIR/installed";
my $SRCDIR = "$CONFIGDIR/src";
my %modules;
@@ -61,44 +61,44 @@ sub fetch (Str $name) {
sub install (Str $module, Bool $strict?, Bool $v?) {
my $res;
- my $name = $module or crap "Unknown module '$module'";
- fetch $name;
- installdeps $name;
- notice "Building $name";
+ %modules.exists($module) or crap "Unknown module $module";
+ fetch $module;
+ installdeps $module;
+ notice "Building $module";
my $fail = False;
try {
Module::Build::build :$v;
CATCH {
$fail = True;
}
}
- crap "Building $name failed" if $fail;
+ crap "Building $module failed" if $fail;
# THINKABOUT: what if tests are someplace else?
# Everyone's allowed to do it
if $strict and 't'.IO !~~ :d {
- crap "No tests for $name";
+ crap "No tests for $module";
}
- notice "Testing $name";
+ notice "Testing $module";
try {
Module::Test::test :$v;
CATCH {
$fail = True;
}
}
- crap "Tests failed for $name" if $fail;
- notice "Installing $name";
+ crap "Tests failed for $module" if $fail;
+ notice "Installing $module";
try {
Module::Install::install :$v;
CATCH {
$fail = True;
}
}
- crap "Installing $name failed" if $fail;
- notice "Successfully installed $name";
+ crap "Installing $module failed" if $fail;
+ notice "Successfully installed $module";
- unless isinstalled $name {
+ unless isinstalled $module {
given open($INSTALLED, :a) {
- .say($name);
+ .say($module);
.close;
}
}
@@ -149,42 +149,18 @@ sub updatedb {
'projects.list';
}
-sub MAIN ($command, $param?, Bool :$strict, Bool :$v) {
+multi MAIN ('list') {
checklist;
- given $command {
- when 'i' {
- unless $param.defined {
- crap "i requires a parameter -- a module name";
- }
- install $param, $strict, $v;
- }
- when 'l' {
- listmodules;
- }
- when 'u' {
- updatedb;
- }
- default {
- USAGE;
- }
- }
+ listmodules;
}
-sub USAGE {
- say "Usage: neutro <command> [parameter]";
- say "Available commands (with example usage):
- neutro i Acme::Meow
- install Acme::Meow
-
- neutro i Acme::Meow --strict
- same as above, but terminate the process if no tests are found
-
- neutro l
- list available modules
+multi MAIN ('update') {
+ updatedb;
+}
- neutro u
- update the modules database
-";
+multi MAIN ($module, Bool :$strict, Bool :$v) {
+ checklist;
+ install $module, $strict, $v;
}
# vim: ft=perl6
View
15 bin/smoker.pl
@@ -1,19 +1,19 @@
#!/usr/bin/env perl6
use v6;
-my @list = qqx[neutro l].split("\n").grep({$_});
+my @list = qqx[neutro list].split("\n").grep({$_});
for @list -> $module {
print "$module - ";
- my $result = qqx[neutro i $module --strict --nocolor];
+ my $result = qqx[neutro $module --strict];
my @lines = $result.split("\n").grep({$_});
my $lastline = @lines[@lines.end];
given $lastline {
when /:s Tests failed for $module/ {
say 'tests failed'
}
when /:s Tests failed/ {
- say 'tests failed for some dependencies'
+ say 'unable to install dependencies'
}
when /:s Successfully installed $module/ {
say 'ok'
@@ -25,19 +25,22 @@
say 'building failed'
}
when /:s Building .+ failed/ {
- say 'building dependencies failed'
+ say 'unable to install dependencies'
}
when /:s Configure.pl has failed for $module/ {
say 'Configure.pl failed'
}
when /:s Configure.pl has failed/ {
- say 'building dependencies failed'
+ say 'unable to install dependencies'
}
when /:s Installing $module failed/ {
say 'installing failed'
}
when /:s Installing .+ failed/ {
- say 'installing dependencies failed'
+ say 'unable to install dependencies'
+ }
+ when /:s Unknown module/ {
+ say 'dependencies not in module ecosystem'
}
default {
say "Unknown result: '$lastline'"

0 comments on commit 5744b17

Please sign in to comment.
Something went wrong with that request. Please try again.