Skip to content

Commit

Permalink
Merge pull request #819 from gugod/sys-module
Browse files Browse the repository at this point in the history
a Sys module for quick accessing info about current system.
  • Loading branch information
gugod authored Sep 20, 2024
2 parents 0b1ee1e + a793618 commit dd42267
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/App/Perlbrew/Sys.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package App::Perlbrew::Sys;
use strict;
use warnings;
use Config;

sub osname {
$Config{osname}
}

sub archname {
$Config{archname}
}

sub os {
$Config{osname}
}

sub arch {
(split(/-/, $Config{archname}, 2))[0]
}

1;
3 changes: 3 additions & 0 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use App::Perlbrew::Util qw( files_are_the_same uniq find_similar_tokens looks_li
use App::Perlbrew::Path ();
use App::Perlbrew::Path::Root ();
use App::Perlbrew::HTTP qw( http_download http_get );
use App::Perlbrew::Sys;

### global variables

Expand Down Expand Up @@ -225,6 +226,8 @@ sub parse_cmdline {
);
}

sub sys { App::Perlbrew::Sys:: }

sub root {
my ( $self, $new_root ) = @_;

Expand Down
14 changes: 14 additions & 0 deletions t/sys.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use Test2::V0;

use App::perlbrew;

subtest 'sys', sub {
my $o = App::perlbrew->new();
is $o->can("sys"), T();
is $o->sys->os(), D();
is $o->sys->arch(), D();
is $o->sys->osname(), D();
is $o->sys->archname(), D();
};

done_testing;

0 comments on commit dd42267

Please sign in to comment.