Commits

Burak Gürsoy committed 049b5a1

Cleanup

  • Participants
  • Parent commits 478864c

Comments (0)

Files changed (6)

 
 Time zone is GMT+2.
 
-0.73 Sun Dec 26 23:49:02 2010
-    => First release.
+0.73 Tue Jan 11 02:13:45 2011
+    => First release. Currently not enabled in Sys::Info.
 
 COPYRIGHT
 
-Copyright (c) 2010 Burak Gursoy. All rights reserved.
+Copyright (c) 2010-2011 Burak Gursoy. All rights reserved.
 
 LICENSE
 

lib/Sys/Info/Driver/OSX.pm

 package Sys::Info::Driver::OSX;
 use strict;
 use warnings;
-use vars qw( $VERSION @ISA @EXPORT );
-use base qw( Exporter   Sys::Info::Base );
-use Carp qw( croak );
-use Capture::Tiny qw( capture );
-
-$VERSION = '0.73';
-@EXPORT  = qw( fsysctl nsysctl sw_vers system_profiler );
-
-use constant ERROR_NO_VALUE     => 'Can not happen! No value in output!';
-
+use base qw( Exporter Sys::Info::Base );
 use constant SYSCTL_NOT_EXISTS  =>
     qr{top    \s level \s name .+? in .+? is \s invalid}xms,
     qr{second \s level \s name .+? in .+? is \s invalid}xms,
     qr{name                    .+? in .+? is \s unknown}xms,
 ;
 
+use Capture::Tiny qw( capture );
+use Carp          qw( croak   );
+
+our $VERSION = '0.73';
+our @EXPORT  = qw( fsysctl nsysctl sw_vers system_profiler );
+
 sub system_profiler {
     # SPSoftwareDataType -> os version. user
     # SPHardwareDataType -> cpu
-    # SPMemoryDataType -> ramler
+    # SPMemoryDataType   -> ram
     my(@types) = @_;
     my($out, $error) = capture {
-                        system system_profiler => '-xml',
-                                                    (@types ? @types : ())
-                    };
+        system system_profiler => '-xml', (@types ? @types : ())
+    };
 
     require Mac::PropertyList;
     my $raw = Mac::PropertyList::parse_plist( $out )->as_perl;
+
     my %rv;
     foreach my $e ( @$raw ) {
         next if ref $e ne 'HASH' || ! (keys %{ $e });
-        my $key = delete $e->{_dataType};
-        my $value = delete $e->{_items};
-        if ( @{ $value } == 1 ) {
-            $value = $value->[0];
-        }
-        $rv{ $key } = $value;
+        my $key     = delete $e->{_dataType};
+        my $value   = delete $e->{_items};
+        $rv{ $key } = @{ $value } == 1 ? $value->[0] : $value;
     }
 
     return @types && @types == 1 ? values %rv : %rv;
     my($out, $error) = capture { system 'sw_vers' };
     $_ = __PACKAGE__->trim( $_ ) for $out, $error;
     croak "Unable to capture `sw_vers`: $error" if $error;
-    my %data = map { split m{:\s+?}xms, $_ } split m{\n}xms, $out;
-    return %data;
+    return map { split m{:\s+?}xms, $_ } split m{\n}xms, $out;
 }
 
 sub fsysctl {
             my($name, $value) = split m{:\s}xms, $row, 2;
             chomp $name;
             chomp $value;
-            croak ERROR_NO_VALUE if ! $value && $value ne '0';
+            croak 'Can not happen! No value in output!'
+                if ! $value && $value ne '0';
             $rv{ $name } = $value;
         }
     }
 
 n(ormal)sysctl.
 
+=head2 system_profiler
+
+System call to system_profiler.
+
+=head2 sw_vers
+
+System call to sw_vers.
+
 =cut

lib/Sys/Info/Driver/OSX/Device.pm

 package Sys::Info::Driver::OSX::Device;
 use strict;
 use warnings;
-use vars qw( $VERSION );
 
-$VERSION = '0.70';
+our $VERSION = '0.73';
 
 1;
 

lib/Sys/Info/Driver/OSX/Device/CPU.pm

 package Sys::Info::Driver::OSX::Device::CPU;
 use strict;
 use warnings;
-use vars qw($VERSION);
 use base qw(Sys::Info::Base);
+use Carp qw( croak );
 use POSIX ();
-use Carp qw( croak );
 use Sys::Info::Driver::OSX;
 use constant RE_SPACE => qr{\s+}xms;
 
-$VERSION = '0.70';
+our $VERSION = '0.73';
 
 sub identify {
     my $self = shift;
             $rv->{machdep}{cpu};
         };
 
-        # $cpu:
-        #    'boot_rom_version' => 'MBP71.0039.B0B',
-        #    'machine_name' => 'MacBook Pro',
-        #    'SMC_version_system' => '1.62f6',
-        #    'platform_UUID' => '23985E75-7B4C-5D25-BF98-6E37D958926C',
-        #    'machine_model' => 'MacBookPro7,1'
-
         my $mach = $self->uname->{machine} || fsysctl('hw.machine_arch');
         my $arch = $mach =~ m{ i [0-9] 86 }xmsi ? 'x86'
                  : $mach =~ m{ ia64       }xmsi ? 'IA64'
             ( $byteorder ? (byteorder    => $byteorder):()),
         } for 1..$cpu->{number_processors};
     }
-    #$VAR1 = 'Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz';
+
     return $self->_serve_from_cache(wantarray);
 }
 

lib/Sys/Info/Driver/OSX/OS.pm

 package Sys::Info::Driver::OSX::OS;
 use strict;
 use warnings;
-use vars qw( $VERSION );
 use base qw( Sys::Info::Base );
+use Carp qw( croak );
+use Cwd;
 use POSIX ();
-use Cwd;
-use Carp qw( croak );
 use Sys::Info::Constants qw( LIN_REAL_NAME_FIELD );
 use Sys::Info::Driver::OSX;
 
-$VERSION = '0.70';
+our $VERSION = '0.73';
 
 my %OSVERSION;