Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a Sys module for quick accessing info about current system. #819

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading