Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement Distro.path-sep plus some cleanup
  • Loading branch information
lizmat committed May 31, 2014
1 parent 7d6acc7 commit 6745862
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/core/Distro.pm
Expand Up @@ -4,10 +4,11 @@
# with the values that you expected and how to get them in your situation.

class Distro does Systemic{
has Bool $.is-win;
has Str $.release;
has Bool $.is-win;
has Str $.path-sep;

submethod BUILD (:$name, :$version, :$!release, :$!auth) {
submethod BUILD (:$name, :$version, :$!release, :$!auth, :$!path-sep) {
$!name = $name.lc; # lowercase
$!name ~~ s:g/" "//; # spaceless
$!version = Version.new($version);
Expand All @@ -29,41 +30,39 @@ class Distro does Systemic{
}

{
my $name =
#?if jvm
$*VM.properties<os.name>;
#?endif
#?if !jvm
$*VM.config<osname>;
#?endif

my $version =
#?if jvm
$*VM.properties<os.version>;
my $properties := $*VM.properties;
my $name := $properties<os.name>;
my $version := $properties<os.version>;
my $path-sep := $properties<path.separator>;
#?endif
#?if !jvm
$*VM.config<osvers>;
my $config := $*VM.config;
my $name := $config<osname>;
my $version := $config<osvers>;
my $path-sep := $name eq 'MSWin32' ?? ';' !! ':';
#?endif
my Str $release = "unknown";
my Str $auth = "unknown";
my Str $release := "unknown";
my Str $auth := "unknown";

# darwin specific info
if $name eq 'darwin' {
if qx/sw_vers/ ~~ m/ProductName\: \s+ (<[\w\ ]>+) \s+ ProductVersion\: \s+ (<[\d\.]>+) \s+ BuildVersion\: \s+ (<[\w\d]>+)/ {
$name = ~$0;
$version = ~$1;
$release = ~$2;
$name := ~$0;
$version := ~$1;
$release := ~$2;
}
else {
$name = 'Mac OS X'; # we assume
$version = "unknown";
$release = "unknown";
$name := 'Mac OS X'; # we assume
$version := "unknown";
$release := "unknown";
}
$auth = 'Apple Computer, Inc.'; # presumably
$auth := 'Apple Computer, Inc.'; # presumably
}

# set up $*DISTRO and deprecated $*OS and $*OSVER
PROCESS::<$DISTRO> = Distro.new( :$name, :$version, :$release, :$auth );
PROCESS::<$DISTRO> =
Distro.new( :$name, :$version, :$release, :$auth, :$path-sep );
PROCESS::<$OS> = Deprecation.obsolete(
:name('$*OS'),
:value($name),
Expand Down

0 comments on commit 6745862

Please sign in to comment.