| 1 | package Devel::Platform::Info::Mac; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 6 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 6 | $VERSION = '1.00'; | |||||||||
| 8 | |||||||||||
| 9 | #------------------------------------------------------------------------------- | ||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | 2 | my ($class) = @_; | |||||||||
| 13 | 2 | my $self = {}; | |||||||||
| 14 | 2 | bless $self, $class; | |||||||||
| 15 | |||||||||||
| 16 | 2 | return $self; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | #------------------------------------------------------------------------------- | ||||||||||
| 20 | |||||||||||
| 21 | 6 | ▶ | sub get_info { | ||||||||
|
Subroutine
get_info: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||
| 22 | 6 | my $self = shift; | |||||||||
| 23 | 6 | $self->{info}{osname} = 'Mac'; | |||||||||
| 24 | 6 | $self->{info}{osflag} = $^O; | |||||||||
| 25 | |||||||||||
| 26 | 6 | my $uname_s = $self->_command('uname -s'); | |||||||||
| 27 | 6 | ▶ | if ($uname_s =~ /Darwin/i) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 4 | $self->{info}{oslabel} = 'OS X'; | |||||||||
| 29 | |||||||||||
| 30 | 4 | my $productversion = $self->_command('sw_vers -productVersion'); | |||||||||
| 31 | 4 | ▶ | if ($productversion =~ /((\d+)\.(\d+)(\.(\d+))?)/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 4 | my ($version, $major, $minor) = ($1, $2, $3); | |||||||||
| 33 | 4 | my $versions = _macos_versions(); | |||||||||
| 34 | 4 | ▶ | if (my $codename = $versions->{"$major.$minor"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 4 | $self->{info}{codename} = $codename; | |||||||||
| 36 | 4 | $self->{info}{osvers} = $version; | |||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 6 | ▶ | if (my $arch = $self->_command('uname -p')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 5 | chomp $arch; | |||||||||
| 43 | 5 | $self->{info}{archname} = $arch; | |||||||||
| 44 | 5 | ▶ | $self->{info}{is32bit} = $arch !~ /_(64)$/ ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 5 | ▶ | $self->{info}{is64bit} = $arch =~ /_(64)$/ ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 6 | ▶ | if (my $unamev = $self->_command('uname -v')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 5 | chomp $unamev; | |||||||||
| 50 | 5 | $self->{info}{kernel} = $unamev; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 6 | $self->_command('uname -a'); | |||||||||
| 54 | |||||||||||
| 55 | 6 | return $self->{info}; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | #------------------------------------------------------------------------------- | ||||||||||
| 60 | |||||||||||
| 61 | 9 | ▶ | sub _command { | ||||||||
|
Subroutine
_command: called CC=1 SCAR=0.0
| |||||||||||
| 62 | 9 | my $self = shift; | |||||||||
| 63 | 9 | my $command = shift; | |||||||||
| 64 | 9 | my $result = `$command`; | |||||||||
| 65 | 9 | chomp $result; | |||||||||
| 66 | |||||||||||
| 67 | 9 | $self->{info}{source}{$command} = $result; | |||||||||
| 68 | |||||||||||
| 69 | 9 | return $result; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | #------------------------------------------------------------------------------- | ||||||||||
| 73 | |||||||||||
| 74 | 4 | ▶ | sub _macos_versions { | ||||||||
|
Subroutine
_macos_versions: called CC=1 SCAR=0.0
| |||||||||||
| 75 | return { | ||||||||||
| 76 | 4 | '10.0' => 'Cheetah', | |||||||||
| 77 | '10.1' => 'Puma', | ||||||||||
| 78 | '10.2' => 'Jaguar', | ||||||||||
| 79 | '10.3' => 'Panther', | ||||||||||
| 80 | '10.4' => 'Tiger', | ||||||||||
| 81 | '10.5' => 'Leopard', | ||||||||||
| 82 | '10.6' => 'Snow Leopard', | ||||||||||
| 83 | '10.7' => 'Lion', | ||||||||||
| 84 | '10.8' => 'Mountain Lion', | ||||||||||
| 85 | '10.9' => 'Mavericks', | ||||||||||
| 86 | '10.10' => 'Yosemite', | ||||||||||
| 87 | '10.11' => 'El Capitan', | ||||||||||
| 88 | }; | ||||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | #------------------------------------------------------------------------------- | ||||||||||
| 92 | |||||||||||
| 93 | 6 | 1; | |||||||||
| 94 | |||||||||||
| 95 | __END__ | ||||||||||