diff --git a/src/lib/Plumage/Dependencies.nqp b/src/lib/Plumage/Dependencies.nqp index 9bde815..991ab84 100644 --- a/src/lib/Plumage/Dependencies.nqp +++ b/src/lib/Plumage/Dependencies.nqp @@ -17,7 +17,7 @@ Plumage::Dependencies - Resolve dependency relationships class Plumage::Dependencies; -method resolve_dependencies (@projects) { +method resolve_dependencies(@projects) { my @known_projects := Plumage::Metadata.get_project_list(); my @all_deps := self.all_dependencies(@projects); my @installed := self.get_installed_projects; @@ -60,7 +60,7 @@ method resolve_dependencies (@projects) { return %resolutions; } -method all_dependencies (@projects) { +method all_dependencies(@projects) { my @dep_stack; my @deps; my %seen; @@ -97,7 +97,7 @@ method all_dependencies (@projects) { return @deps; } -method get_installed_projects () { +method get_installed_projects() { my $inst_file := replace_config_strings(%*CONF); my $contents := slurp($inst_file); my @projects := grep(-> $_ { ?$_ }, pir::split("\n", $contents)); @@ -109,14 +109,14 @@ method get_installed_projects () { } } -method mark_projects_installed (@projects) { +method mark_projects_installed(@projects) { my $lines := pir::join("\n", @projects) ~ "\n"; my $inst_file := replace_config_strings(%*CONF); append($inst_file, $lines); } -method mark_projects_uninstalled (@projects) { +method mark_projects_uninstalled(@projects) { my %uninst := set_from_array(@projects); my $inst_file := replace_config_strings(%*CONF); my $contents := slurp($inst_file); diff --git a/src/lib/Plumage/Metadata.nqp b/src/lib/Plumage/Metadata.nqp index 5b3ac0c..f436a10 100644 --- a/src/lib/Plumage/Metadata.nqp +++ b/src/lib/Plumage/Metadata.nqp @@ -325,7 +325,7 @@ method saved_copy_path () { return $copy_path; } -sub _saved_copy_root () { +sub _saved_copy_root() { return replace_config_strings(%*CONF); } diff --git a/src/lib/Plumage/NQPUtil.nqp b/src/lib/Plumage/NQPUtil.nqp index 1eb970b..d147dd2 100644 --- a/src/lib/Plumage/NQPUtil.nqp +++ b/src/lib/Plumage/NQPUtil.nqp @@ -91,7 +91,7 @@ Return a true value if C<$key> exists in C<%hash>, or a false value otherwise. =end - method exists ($key) { + method exists($key) { return Q:PIR{ $P1 = find_lex '$key' $I0 = exists self[$P1] @@ -107,7 +107,7 @@ Return all the C<@keys> in the C<%hash> as an unordered array. =end - method keys () { + method keys() { my @keys; for self { @keys.push($_.key); } @keys; @@ -121,7 +121,7 @@ Return all the C<@values> in the C<%hash> as an unordered array. =end - method values () { + method values() { my @values; for self { @values.push($_.value); } @values; @@ -138,7 +138,7 @@ when iterating over key and value simultaneously: =end - method kv () { + method kv() { my @kv; for self { @kv.push($_.key); @kv.push($_.value); } @kv; @@ -173,7 +173,7 @@ Return a C<@reversed> copy of the C<@array>. =end - method reverse () { + method reverse() { my @reversed; for self { @reversed.unshift($_); } @reversed; @@ -205,7 +205,7 @@ one entry in the C<@mapped> output. =end -sub map (&code, @originals) { +sub map(&code, @originals) { my @mapped; for @originals { @@ -224,7 +224,7 @@ Order is retained, and duplicates are handled independently. =end -sub grep (&code, @all) { +sub grep(&code, @all) { my @matches; for @all { @@ -255,7 +255,7 @@ C<$result> is an undefined value. =end -sub reduce (&code, @array, *@initial) { +sub reduce(&code, @array, *@initial) { my $init_elems := pir::elements(@initial); if $init_elems > 1 { pir::die('Only one initial value allowed in reduce()'); @@ -310,7 +310,7 @@ Coerce a list of pairs into a hash. =end -sub hash (*%h) { return %h } +sub hash(*%h) { return %h } =begin @@ -322,7 +322,7 @@ checks. =end -sub set_from_array (@array) { +sub set_from_array(@array) { my %set; for @array { @@ -420,7 +420,7 @@ Print a list of strings to standard output. =end -sub print (*@strings) { +sub print(*@strings) { for @strings { pir::print($_); } @@ -434,7 +434,7 @@ Print a list of strings to standard output, followed by a newline. =end -sub say (*@strings) { +sub say(*@strings) { print(|@strings, "\n"); } @@ -446,7 +446,7 @@ Read the C<$contents> of a file as a single string. =end -sub slurp ($filename) { +sub slurp($filename) { my $fh := pir::new__Ps('FileHandle'); $fh.open($filename, 'r'); my $contents := $fh.readall; @@ -463,7 +463,7 @@ Write the string C<$contents> to a file. =end -sub spew ($filename, $contents) { +sub spew($filename, $contents) { my $fh := pir::new__Ps('FileHandle'); $fh.open($filename, 'w'); $fh.print($contents); @@ -478,7 +478,7 @@ Append the string C<$contents> to a file. =end -sub append ($filename, $contents) { +sub append($filename, $contents) { my $fh := pir::new__Ps('FileHandle'); $fh.open($filename, 'a'); $fh.print($contents); @@ -538,7 +538,7 @@ value if not. =end -sub path_exists ($path) { +sub path_exists($path) { my @stat := pir::root_new__PP(< parrot OS >).stat($path); return 1; @@ -620,7 +620,7 @@ following way: =end -sub find_program ($program) { +sub find_program($program) { my $path_sep := %*VM eq 'MSWin32' ?? ';' !! ':'; my %env := pir::root_new__PP(< parrot Env >); my @paths := pir::split($path_sep, %env); @@ -649,7 +649,7 @@ top making directories as needed until an entire path has been created. =end -sub mkpath ($path) { +sub mkpath($path) { my @path := pir::split('/', $path); my $cur := @path.shift; @@ -682,7 +682,7 @@ if the process could not be spawned at all. =end -sub run (*@command_and_args) { +sub run(*@command_and_args) { my $aux := pir::spawnw__iP(@command_and_args); my $ret := Q:PIR< $P0 = find_lex '$aux' @@ -706,7 +706,7 @@ successfully but itself exited with failure. =end -sub do_run (*@command_and_args) { +sub do_run(*@command_and_args) { say(pir::join(' ', @command_and_args)); return pir::spawnw__iP(@command_and_args) ?? 0 !! 1; @@ -729,7 +729,7 @@ B: Parrot currently implements the pipe open B! =end -sub qx (*@command_and_args) { +sub qx(*@command_and_args) { my $cmd := pir::join(' ', @command_and_args); my $pipe := pir::new__Ps('FileHandle'); $pipe.open($cmd, 'rp'); @@ -762,7 +762,7 @@ returning the C<$result> of executing the compiled code. =end -sub eval ($source_code, $language) { +sub eval($source_code, $language) { $language := pir::downcase($language); pir::load_language($language); diff --git a/src/lib/Plumage/Project.nqp b/src/lib/Plumage/Project.nqp index 011dac6..4d82ec9 100644 --- a/src/lib/Plumage/Project.nqp +++ b/src/lib/Plumage/Project.nqp @@ -46,9 +46,9 @@ has $!name; has $!metadata; has $!source_dir; -method name () { $!name } -method metadata () { $!metadata } -method source_dir () { $!source_dir } +method name() { $!name } +method metadata() { $!metadata } +method source_dir() { $!source_dir } # CONSTRUCTION @@ -125,13 +125,13 @@ sub _get_winxed() { ### ACTIONS ### -method known_actions () { +method known_actions() { return grep(-> $_ {self.HOW.can(self, $_)}, < fetch update configure build test smoke install uninstall clean realclean >); } -sub _build_stage_paths () { +sub _build_stage_paths() { our %STAGES; # All stages in install path require their predecessors @@ -149,14 +149,14 @@ sub _build_stage_paths () { %STAGES[-1] := 'smoke'; } -method _actions_up_to ($stage) { +method _actions_up_to($stage) { our %STAGES; _build_stage_paths(); return %STAGES{$stage}; } -method perform_actions (:$up_to, :@actions, :$ignore_all, :%ignore) { +method perform_actions(:$up_to, :@actions, :$ignore_all, :%ignore) { if $up_to && @actions { die("Cannot specify both up_to and actions in perform_actions()"); } @@ -196,7 +196,7 @@ method perform_actions (:$up_to, :@actions, :$ignore_all, :%ignore) { # FETCH -method fetch () { +method fetch() { my %fetch := $!metadata.metadata; if %fetch { my $build_root := replace_config_strings(%*CONF); @@ -212,7 +212,7 @@ method fetch () { } } -method fetch_repository () { +method fetch_repository() { my %repo := $!metadata.metadata; if %repo { say("Fetching $!name ..."); @@ -225,7 +225,7 @@ method fetch_repository () { } } -method fetch_git () { +method fetch_git() { if path_exists($!source_dir) { if path_exists(fscat([$!source_dir, '.git'])) { $*OS.chdir($!source_dir); @@ -246,7 +246,7 @@ method fetch_git () { } } -method fetch_hg () { +method fetch_hg() { if path_exists($!source_dir) { if path_exists(fscat([$!source_dir, '.hg'])) { $*OS.chdir($!source_dir); @@ -263,7 +263,7 @@ method fetch_hg () { } } -method fetch_svn () { +method fetch_svn() { if path_exists($!source_dir) && !path_exists(fscat([$!source_dir, '.svn'])) { return report_fetch_collision('Subversion'); @@ -275,7 +275,7 @@ method fetch_svn () { } } -method report_fetch_collision ($type) { +method report_fetch_collision($type) { say("\n$!name is a $type project, but the fetch directory:\n" ~ "\n $!source_dir\n\n" ~ "already exists and is not the right type.\n" @@ -286,7 +286,7 @@ method report_fetch_collision ($type) { # UPDATE -method update () { +method update() { my %update := $!metadata.metadata; if %update && path_exists($!source_dir) { @@ -298,7 +298,7 @@ method update () { } } -method update_repository () { +method update_repository() { my %repo := $!metadata.metadata; if %repo { say("Updating $!name ..."); @@ -312,13 +312,13 @@ method update_repository () { } } -method update_parrot_setup () { +method update_parrot_setup() { $*OS.chdir($!source_dir); return do_run(%*BIN, 'setup.pir', 'update'); } -method update_nqp_setup () { +method update_nqp_setup() { $*OS.chdir($!source_dir); return do_run(%*BIN, 'setup.nqp', 'update'); @@ -332,7 +332,7 @@ method update_winxed_setup() { # CONFIGURE -method configure () { +method configure() { my %conf := $!metadata.metadata; if %conf { say("\nConfiguring $!name ..."); @@ -347,28 +347,28 @@ method configure () { } } -method configure_rake () { +method configure_rake() { return do_run(%*BIN, 'config'); } -method configure_perl5_configure () { +method configure_perl5_configure() { my $extra := $!metadata.metadata; my @extra := map(replace_config_strings, $extra); return do_run(%*BIN, 'Configure.pl', |@extra); } -method configure_parrot_configure () { +method configure_parrot_configure() { return do_run(%*BIN, 'Configure.pir'); } -method configure_nqp_configure () { +method configure_nqp_configure() { return do_run(%*BIN, 'Configure.nqp'); } # BUILD -method build () { +method build() { my %build := $!metadata.metadata; if %build { say("\nBuilding $!name ..."); @@ -383,19 +383,19 @@ method build () { } } -method build_make () { +method build_make() { return do_run(%*BIN); } -method build_rake () { +method build_rake() { return do_run(%*BIN); } -method build_parrot_setup () { +method build_parrot_setup() { return do_run(%*BIN, 'setup.pir'); } -method build_nqp_setup () { +method build_nqp_setup() { return do_run(%*BIN, 'setup.nqp'); } @@ -405,7 +405,7 @@ method build_winxed_setup() { # TEST -method test () { +method test() { my %test := $!metadata.metadata; if %test { say("\nTesting $!name ..."); @@ -420,19 +420,19 @@ method test () { } } -method test_make () { +method test_make() { return do_run(%*BIN, 'test'); } -method test_rake () { +method test_rake() { return do_run(%*BIN, 'test'); } -method test_parrot_setup () { +method test_parrot_setup() { return do_run(%*BIN, 'setup.pir', 'test'); } -method test_nqp_setup () { +method test_nqp_setup() { return do_run(%*BIN, 'setup.nqp', 'test'); } @@ -442,7 +442,7 @@ method test_winxed_setup() { # SMOKE -method smoke () { +method smoke() { my %smoke := $!metadata.metadata; if %smoke { say("\nSmoke testing $!name ..."); @@ -457,15 +457,15 @@ method smoke () { } } -method smoke_make () { +method smoke_make() { return do_run(%*BIN, 'smoke'); } -method smoke_parrot_setup () { +method smoke_parrot_setup() { return do_run(%*BIN, 'setup.pir', 'smoke'); } -method smoke_nqp_setup () { +method smoke_nqp_setup() { return do_run(%*BIN, 'setup.nqp', 'smoke'); } @@ -475,7 +475,7 @@ method smoke_winxed_setup() { # INSTALL -method install () { +method install() { my %inst := $!metadata.metadata; if %inst { say("\nInstalling $!name ..."); @@ -497,19 +497,19 @@ method install () { } } -method install_make () { +method install_make() { return self.do_with_privs(%*BIN, 'install'); } -method install_rake () { +method install_rake() { return self.do_with_privs(%*BIN, 'install'); } -method install_parrot_setup () { +method install_parrot_setup() { return self.do_with_privs(%*BIN, 'setup.pir', 'install'); } -method install_nqp_setup () { +method install_nqp_setup() { return self.do_with_privs(%*BIN, 'setup.nqp', 'install'); } @@ -519,7 +519,7 @@ method install_winxed_setup() { # UNINSTALL -method uninstall () { +method uninstall() { my %uninst := $!metadata.metadata; if %uninst { say("\nUninstalling $!name ..."); @@ -541,15 +541,15 @@ method uninstall () { } } -method uninstall_make () { +method uninstall_make() { return self.do_with_privs(%*BIN, 'uninstall'); } -method uninstall_parrot_setup () { +method uninstall_parrot_setup() { return self.do_with_privs(%*BIN, 'setup.pir', 'uninstall'); } -method uninstall_nqp_setup () { +method uninstall_nqp_setup() { return self.do_with_privs(%*BIN, 'setup.nqp', 'uninstall'); } @@ -557,7 +557,7 @@ method uninstall_winxed_setup() { return self.do_with_privs(_get_winxed(), 'setup.winxed', 'uninstall'); } -method do_with_privs (*@cmd) { +method do_with_privs(*@cmd) { my $bin_dir := %*VM; my $root_cmd := replace_config_strings(%*CONF); @@ -571,7 +571,7 @@ method do_with_privs (*@cmd) { # CLEAN -method clean () { +method clean() { unless path_exists($!source_dir) { say("\nProject source dir '$!source_dir' does not exist; nothing to do."); return 1; @@ -591,19 +591,19 @@ method clean () { } } -method clean_make () { +method clean_make() { return do_run(%*BIN, 'clean'); } -method clean_rake () { +method clean_rake() { return do_run(%*BIN, 'clean'); } -method clean_parrot_setup () { +method clean_parrot_setup() { return do_run(%*BIN, 'setup.pir', 'clean'); } -method clean_nqp_setup () { +method clean_nqp_setup() { return do_run(%*BIN, 'setup.nqp', 'clean'); } @@ -613,7 +613,7 @@ method clean_winxed_setup() { # REALCLEAN -method realclean () { +method realclean() { unless path_exists($!source_dir) { say("\nProject source dir '$!source_dir' does not exist; nothing to do."); return 1; @@ -633,11 +633,11 @@ method realclean () { } } -method realclean_make () { +method realclean_make() { return do_run(%*BIN, 'realclean'); } -method realclean_rake () { +method realclean_rake() { return do_run(%*BIN, 'clobber'); } diff --git a/src/plumage.nqp b/src/plumage.nqp index ae81cd8..bad88b2 100644 --- a/src/plumage.nqp +++ b/src/plumage.nqp @@ -163,7 +163,7 @@ our %OPT; my %*CONF; my %*BIN; -sub load_helper_libraries () { +sub load_helper_libraries() { # Support OO pir::load_bytecode('P6object.pbc'); @@ -186,7 +186,7 @@ sub load_helper_libraries () { pir::load_bytecode('Plumage/Dependencies.pbc'); } -sub parse_command_line_options () { +sub parse_command_line_options() { my $getopts := pir::root_new__PP(< parrot Getopt Obj >); # Configure -c switch @@ -214,7 +214,7 @@ sub parse_command_line_options () { %OPT := $getopts.get_options(@*ARGS); } -sub read_config_files () { +sub read_config_files() { # Find config files for this system and user (ignored if missing). my $etc := %*VM; my $home := %*ENV || user_home_dir(); @@ -253,7 +253,7 @@ sub read_config_files () { } } -sub merge_tree_structures ($dst, $src) { +sub merge_tree_structures($dst, $src) { for $src.keys -> $k { my $d := $dst{$k}; my $s := $src{$k}; @@ -270,7 +270,7 @@ sub merge_tree_structures ($dst, $src) { return $dst; } -sub find_binaries () { +sub find_binaries() { my %conf := %*VM; my $parrot_bin := %conf; @@ -294,7 +294,7 @@ sub find_binaries () { ### MAIN ### -sub MAIN () { +sub MAIN() { parse_command_line_options(); read_config_files(); find_binaries(); @@ -308,13 +308,13 @@ sub MAIN () { } } -sub parse_command_line () { +sub parse_command_line() { my $command := @*ARGS ?? @*ARGS.shift !! 'help'; return $command; } -sub execute_command ($command) { +sub execute_command($command) { my $action := %COMMANDS{$command}; my $args := %COMMANDS{$command}; @@ -338,11 +338,11 @@ sub execute_command ($command) { ### COMMANDS ### -sub command_usage () { +sub command_usage() { print(usage_info()); } -sub usage_info () { +sub usage_info() { return "Usage: $*PROGRAM_NAME [] [] @@ -387,7 +387,7 @@ Commands: "; } -sub command_help ($help_cmd, :$command) { +sub command_help($help_cmd, :$command) { if ?$help_cmd { my $usage := %COMMANDS{$help_cmd[0]}; my $help := %COMMANDS{$help_cmd[0]}; @@ -400,11 +400,11 @@ sub command_help ($help_cmd, :$command) { } } -sub command_version () { +sub command_version() { print(version_info()); } -sub version_info () { +sub version_info() { my $version := '0'; return "This is Parrot Plumage, version $version. @@ -417,7 +417,7 @@ included in the Parrot Plumage source tree. "; } -sub command_projects () { +sub command_projects() { my @projects := Plumage::Metadata.get_project_list(); @projects.sort; @@ -446,7 +446,7 @@ sub command_projects () { say(''); } -sub command_status (@projects, :$command) { +sub command_status(@projects, :$command) { my $showing_all := !@projects; unless @projects { @@ -466,7 +466,7 @@ sub command_status (@projects, :$command) { say('') if $showing_all; } -sub command_info (@projects, :$command) { +sub command_info(@projects, :$command) { unless (@projects) { say('Please include the name of the project you wish info for.'); } @@ -489,7 +489,7 @@ sub command_info (@projects, :$command) { } } -sub command_showdeps (@projects, :$command) { +sub command_showdeps(@projects, :$command) { unless (@projects) { say('Please include the name of the project to show dependencies for.'); } @@ -510,11 +510,11 @@ sub command_showdeps (@projects, :$command) { } } -sub report_metadata_error ($project_name, $meta) { +sub report_metadata_error($project_name, $meta) { say("Metadata error for project '$project_name':\n" ~ $meta.error); } -sub command_project_dir (@projects, :$command) { +sub command_project_dir(@projects, :$command) { unless (@projects) { say('Please include the name of the project you wish to find.'); } @@ -526,12 +526,12 @@ sub command_project_dir (@projects, :$command) { } } -sub command_project_action (@projects, :$command) { +sub command_project_action(@projects, :$command) { install_required_projects(@projects) && perform_actions_on_projects(@projects, :up_to($command)); } -sub install_required_projects (@projects) { +sub install_required_projects(@projects) { my %resolutions := Plumage::Dependencies.resolve_dependencies(@projects); my @need_projects := %resolutions; @@ -546,7 +546,7 @@ sub install_required_projects (@projects) { return 1; } -sub show_dependencies (@projects) { +sub show_dependencies(@projects) { my %resolutions := Plumage::Dependencies.resolve_dependencies(@projects); say(''); @@ -589,7 +589,7 @@ sub show_dependencies (@projects) { } } -sub perform_actions_on_projects (@projects, :$up_to, :@actions) { +sub perform_actions_on_projects(@projects, :$up_to, :@actions) { my $has_ignore_flag := %OPT.exists('IGNORE_FAIL'); my %ignore := %OPT; my $ignore_all := $has_ignore_flag && !%ignore; @@ -607,7 +607,7 @@ sub perform_actions_on_projects (@projects, :$up_to, :@actions) { return 1; } -sub print_project_summary ($meta) { +sub print_project_summary($meta) { my %general := $meta; my $name := %general;