Sys-Info-Base-0.7810/ 000755 000765 000024 00000000000 15056376347 014417 5 ustar 00burak staff 000000 000000 Sys-Info-Base-0.7810/LICENSE 000644 000765 000024 00000046301 15056376347 015430 0 ustar 00burak staff 000000 000000 This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2006 by Burak Gursoy.
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Moe Ghoul, President of Vice
That's all there is to it!
--- The Perl Artistic License 1.0 ---
This software is Copyright (c) 2006 by Burak Gursoy.
This is free software, licensed under:
The Perl Artistic License 1.0
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own. You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.
6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package. If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.
7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.
8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
Sys-Info-Base-0.7810/Changes 000644 000765 000024 00000003145 15056376347 015715 0 ustar 00burak staff 000000 000000 Revision history for Perl extension Sys::Info::Base.
0.7810 2025-09-04 BURAK
- Returned the device id instead of ip in the previous version.
- Filter out the localhost.
0.7809 2025-09-04 BURAK
- Filter out junk ips.
0.7808 2025-08-29 BURAK
- Release the Sys::HostIP change.
- use parent
0.7807 2018-12-25 BURAK
- Distro fix.
0.7806 2018-12-25 BURAK
- Distro fix.
0.7805 2018-12-25 BURAK
- Migrate to dzil.
0.7803 Fri May 10 01:06:29 EEST 2013
- Bump version for new release.
0.7802 Sun Jul 31 03:21:23 2011
- Fix device('available'). Reported by Matthäus Kiem.
0.7801 Sun Jul 31 01:39:17 2011
- Remove Linux specific constants.
0.78 Sat Apr 16 15:18:44 2011
- Enable OSX driver
0.74 Sat Jul 17 02:19:44 2010
- Cleanup.
0.73 Sun Jan 10 07:36:19 2010
- NEW_PERL constant.
- os->locale method.
- Base method uname().
- Removed all constants related to uname().
- Perl::Critic refactoring.
0.72 Thu Apr 23 16:36:03 2009
- Update builder.
0.71 Sat Apr 11 03:37:15 2009
- Update build tool.
0.70 Mon Apr 6 03:54:23 2009
- Bump version for new stable release.
0.69_11 Sat Apr 4 06:06:39 2009
- Remove bitness from cpu. This'll be implemented in driver.
0.69_10 Fri Apr 3 22:00:43 2009
- Update tests.
0.69_06 Sat Mar 14 15:55:08 2009
- Add support for BSD driver.
0.69_05 Sat Mar 14 01:57:38 2009
- Bump version.
0.69_03 Thu Mar 12 03:49:58 2009
- Remove cache from ::CPU.
0.69_02 Thu Mar 5 02:25:32 2009
- Fix date2time test.
0.69_01 Thu Mar 5 02:25:32 2009
- Separation from Sys::Info.
Sys-Info-Base-0.7810/MANIFEST 000644 000765 000024 00000000725 15056376347 015554 0 ustar 00burak staff 000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.033.
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
dist.ini
lib/Sys/Info/Base.pm
lib/Sys/Info/Constants.pm
lib/Sys/Info/Device.pm
lib/Sys/Info/Device/CPU.pm
lib/Sys/Info/Driver.pm
lib/Sys/Info/Helper.pm
lib/Sys/Info/OS.pm
t/00-report-prereqs.dd
t/00-report-prereqs.t
t/03-basic.t
t/author-distmeta.t
t/author-pod-coverage.t
t/author-pod-syntax.t
t/lib/MyLoadableThing.pm
t/slurp.txt
Sys-Info-Base-0.7810/t/ 000755 000765 000024 00000000000 15056376347 014662 5 ustar 00burak staff 000000 000000 Sys-Info-Base-0.7810/META.yml 000644 000765 000024 00000001507 15056376347 015673 0 ustar 00burak staff 000000 000000 ---
abstract: 'Base class for Sys::Info'
author:
- 'Burak Gursoy'
build_requires:
ExtUtils::MakeMaker: '0'
File::Spec: '0'
Test::More: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.033, CPAN::Meta::Converter version 2.150010'
keywords:
- sys
- system
- info
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Sys-Info-Base
requires:
Sys::HostIP: '0'
Text::Template::Simple: '0'
parent: '0'
perl: '5.010'
resources:
bugtracker: https://github.com/burak/CPAN-Sys-Info-Base/issues
repository: git://github.com/burak/CPAN-Sys-Info-Base.git
version: '0.7810'
x_generated_by_perl: v5.40.1
x_serialization_backend: 'YAML::Tiny version 1.76'
x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'
Sys-Info-Base-0.7810/lib/ 000755 000765 000024 00000000000 15056376347 015165 5 ustar 00burak staff 000000 000000 Sys-Info-Base-0.7810/Makefile.PL 000644 000765 000024 00000002305 15056376347 016371 0 ustar 00burak staff 000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.033.
use strict;
use warnings;
use 5.010;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
"ABSTRACT" => "Base class for Sys::Info",
"AUTHOR" => "Burak Gursoy",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "Sys-Info-Base",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.010",
"NAME" => "Sys::Info::Base",
"PREREQ_PM" => {
"Sys::HostIP" => 0,
"Text::Template::Simple" => 0,
"parent" => 0
},
"TEST_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Test::More" => 0
},
"VERSION" => "0.7810",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Sys::HostIP" => 0,
"Test::More" => 0,
"Text::Template::Simple" => 0,
"parent" => 0
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
Sys-Info-Base-0.7810/META.json 000644 000765 000024 00000003360 15056376347 016042 0 ustar 00burak staff 000000 000000 {
"abstract" : "Base class for Sys::Info",
"author" : [
"Burak Gursoy"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.033, CPAN::Meta::Converter version 2.150010",
"keywords" : [
"sys",
"system",
"info"
],
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Sys-Info-Base",
"prereqs" : {
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"develop" : {
"requires" : {
"Pod::Coverage::TrustPod" : "0",
"Test::CPAN::Meta" : "0",
"Test::Pod" : "1.41",
"Test::Pod::Coverage" : "1.08"
}
},
"runtime" : {
"requires" : {
"Sys::HostIP" : "0",
"Text::Template::Simple" : "0",
"parent" : "0",
"perl" : "5.010"
}
},
"test" : {
"recommends" : {
"CPAN::Meta" : "2.120900"
},
"requires" : {
"ExtUtils::MakeMaker" : "0",
"File::Spec" : "0",
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/burak/CPAN-Sys-Info-Base/issues"
},
"repository" : {
"type" : "git",
"url" : "git://github.com/burak/CPAN-Sys-Info-Base.git",
"web" : "https://github.com/burak/CPAN-Sys-Info-Base"
}
},
"version" : "0.7810",
"x_generated_by_perl" : "v5.40.1",
"x_serialization_backend" : "Cpanel::JSON::XS version 4.39",
"x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later"
}
Sys-Info-Base-0.7810/dist.ini 000644 000765 000024 00000001762 15056376347 016071 0 ustar 00burak staff 000000 000000 ; basic stuff
name = Sys-Info-Base
author = Burak Gursoy
license = Perl_5
copyright_holder = Burak Gursoy
copyright_year = 2006
; file modifiers
[PkgVersion]
[PodWeaver]
; file generators
[ManifestSkip]
[Manifest]
[License]
[MakeMaker]
[PruneCruft]
[GatherDir]
exclude_filename = weaver.ini
exclude_match = Sys-Info-Base[0-9]+
; metadata
[MetaYAML]
[MetaJSON]
[Keywords]
keywords = sys system info
[Prereqs]
perl = 5.010
parent = 0
Sys::HostIP = 0
Text::Template::Simple = 0
[ExecDir]
[ShareDir]
[GitHub::Meta]
[Meta::Contributors]
; tests
[MetaTests]
[ExtraTests]
[PodSyntaxTests]
[PodCoverageTests]
[Test::ReportPrereqs]
; The required drivers is not yet installed.
;[Test::Compile]
; release
[NextRelease]
format = %v %{yyyy-MM-dd}d %P
[TestRelease]
[ConfirmRelease]
[UploadToCPAN]
; git
[Git::Check]
[Git::Commit]
commit_msg = Changes for version %v
[Git::Tag]
tag_format = v%v
tag_message = %N v%v
[Git::Push]
push_to = origin
[Git::NextVersion]
Sys-Info-Base-0.7810/lib/Sys/ 000755 000765 000024 00000000000 15056376347 015743 5 ustar 00burak staff 000000 000000 Sys-Info-Base-0.7810/lib/Sys/Info/ 000755 000765 000024 00000000000 15056376347 016636 5 ustar 00burak staff 000000 000000 Sys-Info-Base-0.7810/lib/Sys/Info/Constants.pm 000644 000765 000024 00000010303 15056376347 021145 0 ustar 00burak staff 000000 000000 package Sys::Info::Constants;
$Sys::Info::Constants::VERSION = '0.7810';
use strict;
use warnings;
use Carp qw( croak );
use parent qw( Exporter );
BEGIN {
if ( ! defined &OSID ) {
my %OS = (
MSWin32 => 'Windows',
MSWin64 => 'Windows',
linux => 'Linux',
darwin => 'OSX',
);
$OS{$_} = 'BSD' for qw( freebsd openbsd netbsd );
my $ID = $OS{ $^O } || 'Unknown';
*OSID = sub () { "$ID" }
}
}
use constant DCPU_LOAD_LAST_01 => 0;
use constant DCPU_LOAD_LAST_05 => 1;
use constant DCPU_LOAD_LAST_10 => 2;
use constant DCPU_LOAD => (0..2);
use constant WIN_REG_HW_KEY => 'HKEY_LOCAL_MACHINE/HARDWARE/';
use constant WIN_REG_CPU_KEY => WIN_REG_HW_KEY
. q{DESCRIPTION/System/CentralProcessor};
use constant WIN_REG_CDKEY => q{HKEY_LOCAL_MACHINE/Software/Microsoft/}
. q{Windows NT/CurrentVersion//DigitalProductId};
use constant WIN_REG_OCDKEY => q{HKEY_LOCAL_MACHINE/Software/Microsoft/Office};
use constant WIN_WMI_DATE_TMPL => 'A4 A2 A2 A2 A2 A2';
use constant WIN_B24_DIGITS => qw( B C D F G H J K M P Q R T V W X Y 2 3 4 6 7 8 9 );
use constant WIN_USER_INFO_LEVEL => 3;
use constant DATE_WEEKDAYS => qw( Sun Mon Tue Wed Thu Fri Sat );
use constant DATE_MONTHS => qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
use constant DATE_MKTIME_YDAY => 0;
use constant DATE_MKTIME_ISDST => -1;
use constant UN_RE_BUILD => qr{\A Build \s+ (\d+) .* \z}xmsi;
use constant NEW_PERL => $] >= 5.008;
use constant USER_REAL_NAME_FIELD => 6;
our %EXPORT_TAGS = (
device_cpu => [qw/
DCPU_LOAD_LAST_01
DCPU_LOAD_LAST_05
DCPU_LOAD_LAST_10
DCPU_LOAD
/],
windows_reg => [qw/
WIN_REG_HW_KEY
WIN_REG_CPU_KEY
WIN_REG_CDKEY
WIN_REG_OCDKEY
/],
windows_wmi => [qw/
WIN_WMI_DATE_TMPL
/],
windows_etc => [qw/
WIN_B24_DIGITS
WIN_USER_INFO_LEVEL
/],
date => [qw/
DATE_WEEKDAYS
DATE_MONTHS
DATE_MKTIME_YDAY
DATE_MKTIME_ISDST
/],
unknown => [qw/
UN_RE_BUILD
/],
general => [qw/
OSID
NEW_PERL
USER_REAL_NAME_FIELD
/],
);
our @EXPORT_OK = map { @{ $_ } } values %EXPORT_TAGS;
$EXPORT_TAGS{all} = \@EXPORT_OK;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Sys::Info::Constants
=head1 VERSION
version 0.7810
=head1 SYNOPSIS
use Sys::Info::Constants qw( :device_cpu );
printf "CPU Load: %s\n", $cpu->load(DCPU_LOAD_LAST_01);
=head1 DESCRIPTION
This module defines all the constants used inside C and it's
subclasses.
=head1 NAME
Sys::Info::Constants - Constants for Sys::Info
=head1 CONSTANTS
Every constant can be imported individually or via import keys:
Import Key Constant
------------ -----------------
:device_cpu DCPU_LOAD_LAST_01
DCPU_LOAD_LAST_05
DCPU_LOAD_LAST_10
DCPU_LOAD
:windows_reg WIN_REG_HW_KEY
WIN_REG_CPU_KEY
WIN_REG_CDKEY
WIN_REG_OCDKEY
:windows_wmi WIN_WMI_DATE_TMPL
:windows_etc WIN_B24_DIGITS
WIN_USER_INFO_LEVEL
:date DATE_WEEKDAYS
DATE_MONTHS
DATE_MKTIME_YDAY
DATE_MKTIME_ISDST
:general OSID
=head2 OSID
The Operating System name used inside all C modules.
=head1 SEE ALSO
L.
=head1 AUTHOR
Burak Gursoy
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
Sys-Info-Base-0.7810/lib/Sys/Info/Device.pm 000644 000765 000024 00000004412 15056376347 020374 0 ustar 00burak staff 000000 000000 package Sys::Info::Device;
$Sys::Info::Device::VERSION = '0.7810';
use strict;
use warnings;
use constant SUPPORTED => qw( CPU BIOS );
use Carp qw( croak );
use parent qw( Sys::Info::Base );
use Sys::Info::Constants qw( OSID );
BEGIN {
MK_ACCESSORS: {
no strict qw(refs);
foreach my $device ( SUPPORTED ) {
*{ '_device_' . lc $device } = sub {
my $self = shift;
return Sys::Info::Base->load_module(
'Sys::Info::Device::' . $device
)->new(@_);
}
}
}
}
sub new {
my($class, @args) = @_;
my $device = shift @args or croak 'Device ID is missing';
my $self = {};
bless $self, $class;
my $method = '_device_' . lc $device;
croak "Bogus device ID: $device" if ! $self->can( $method );
return $self->$method( @args ? @args : () );
}
sub _device_available {
my $self = shift;
my $class = ref $self || $self;
my @buf;
local $@;
local $SIG{__DIE__};
foreach my $test ( SUPPORTED ) {
my $eok = eval { $class->new( $test ); 1; };
next if $@ || ! $eok;
push @buf, $test;
}
return @buf;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Sys::Info::Device
=head1 VERSION
version 0.7810
=head1 SYNOPSIS
use Sys::Info;
my $info = Sys::Info->new;
my $device = $info->device( $device_id );
my @available = $info->device('available');
or
use Sys::Info::Device;
my $device = Sys::Info::Device->new( $device_id );
my @available = Sys::Info::Device->new('available');
=head1 DESCRIPTION
This is an interface to the available devices such as the C.
=head1 NAME
Sys::Info::Device - Information about devices
=head1 METHODS
=head2 new DEVICE_ID
Returns an object to the related device or dies if C is
bogus or false.
If C has the value of C, then the names of the
available devices will be returned.
=head1 SEE ALSO
L, L.
=head1 AUTHOR
Burak Gursoy
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
Sys-Info-Base-0.7810/lib/Sys/Info/OS.pm 000644 000765 000024 00000021074 15056376347 017521 0 ustar 00burak staff 000000 000000 package Sys::Info::OS;
$Sys::Info::OS::VERSION = '0.7810';
use strict;
use warnings;
use subs qw( LC_TYPE );
use parent qw( Sys::Info::Base );
use Carp qw( croak );
use Sys::HostIP;
use Sys::Info::Constants qw( OSID );
use constant TARGET_CLASS => __PACKAGE__->load_subclass('Sys::Info::Driver::%s::OS');
use parent TARGET_CLASS;
use constant {
LOCALHOST_IP => '127.0.0.1',
RE_IS_JUNK_DEVICE => qr{ docker[0-9]+ }xms,
};
my $POSIX;
BEGIN {
# this check is for the Unknown driver
local $@;
my $eok = eval {
require POSIX;
POSIX->import( qw(locale_h) );
$POSIX = 1;
1;
};
*LC_CTYPE = sub () {} if $@ || ! $eok;
}
BEGIN {
CREATE_SYNONYMS_AND_UTILITY_METHODS: {
## no critic (TestingAndDebugging::ProhibitProlongedStrictureOverride)
no strict qw(refs);
*is_admin = *is_admin_user
= *is_adminuser
= *is_root_user
= *is_rootuser
= *is_super_user
= *is_superuser
= *is_su
= *{ TARGET_CLASS.'::is_root' }
;
*is_win32 = *is_windows
= *is_win
= sub () { OSID eq 'Windows' }
;
*is_linux = *is_lin
= sub () { OSID eq 'Linux' }
;
*is_bsd = sub () { OSID eq 'BSD' };
*is_unknown = sub () { OSID eq 'Unknown' };
*workgroup = *{ TARGET_CLASS . '::domain_name' };
*host_name = *{ TARGET_CLASS . '::node_name' };
*time_zone = *{ TARGET_CLASS . '::tz' };
## use critic
}
CREATE_FAKES: {
# driver specific methods
my @fakes = qw(
is_winnt
is_win95
is_win9x
product_type
cdkey
);
no strict qw(refs);
foreach my $meth ( @fakes ) {
next if __PACKAGE__->can( $meth );
*{ $meth } = sub {};
}
}
}
sub new {
my($class, @args) = @_;
my $self = { @args % 2 ? () : @args };
bless $self, $class;
$self->init if $self->can('init');
return $self;
}
sub meta {
my $self = shift;
my $id = shift;
my %info = $self->SUPER::meta( $id );
return %info if ! $id;
my $lcid = lc $id;
croak "$id meta value is not supported" if ! exists $info{ $lcid };
return $info{ $lcid };
}
sub ip {
my $self = shift;
my $hostip = Sys::HostIP->new;
my $int = $hostip->interfaces;
my $ip;
if ( my $eth = $int->{eth0} ) {
$ip = $eth;
}
else {
my @devs = keys %{ $int };
my @junk_keys = grep {
$_ =~ RE_IS_JUNK_DEVICE
} @devs;
delete @{ $ip }->{ @junk_keys}
if @junk_keys;
for my $type ( keys %{ $int } ) {
if ( $int->{ $type } eq LOCALHOST_IP ) {
delete $int->{ $type };
}
}
if ( my $i_feel_lucky = $devs[ rand @devs ] ) {
$ip = $int->{ $i_feel_lucky };
}
}
if (
$ip && $ip =~ m{ \A 127 }xms
&& $self->SUPER::can('_ip')
) {
$ip = $self->SUPER::_ip()
}
return $ip;
}
sub locale {
return if ! $POSIX;
my $self = shift;
return setlocale( LC_CTYPE() );
}
1;
=pod
=encoding UTF-8
=head1 NAME
Sys::Info::OS
=head1 VERSION
version 0.7810
=head1 SYNOPSIS
use Sys::Info;
my $info = Sys::Info->new;
my $os = $info->os(%options);
or
use Sys::Info::OS;
my $os = Sys::Info::OS->new(%options);
Example:
use Data::Dumper;
warn "Collected information can be incomplete\n" if $os->is_unknown;
my %fs = $os->fs;
print Data::Dumper->Dump([\%fs], ['*FILE_SYSTEM']);
print "B1ll G4teZ rull4z!\n" if $os->is_windows;
print "Pinguin detected!\n" if $os->is_linux;
if ( $os->is_windows ) {
printf "This is a %s based system\n", $os->is_winnt ? 'NT' : '9.x';
}
printf "Operating System: %s\n", $os->name( long => 1 );
my $user = $os->login_name( real => 1 ) || $os->login_name || 'User';
print "$user, You've Got The P.O.W.E.R.!\n" if $os->is_root;
if ( my $up = $os->uptime ) {
my $tick = $os->tick_count;
printf "Running since %s\n" , scalar localtime $up;
printf "Uptime: %.2f hours\n" , $tick / (60*60 ); # probably windows
printf "Uptime: %.2f days\n" , $tick / (60*60*24 ); # might be windows
printf "Uptime: %.2f months\n", $tick / (60*60*24*30); # hmm... smells like tux
}
=head1 DESCRIPTION
Supplies detailed operating system information.
=head1 NAME
Sys::Info::OS - Detailed os information.
=head1 METHODS
=head2 new
Object constructor.
=head2 name
Returns the OS name. Supports these named parameters: C, C:
# also include the edition info if present
$os->name( edition => 1 );
This will return the long OS name (with build number, etc.):
# also include the edition info if present
$os->name( long => 1, edition => 1 );
=head2 version
Returns the OS version.
=head2 build
Returns the OS build number or build date, depending on
the system.
=head2 uptime
Returns the uptime as a unix timestamp.
=head2 tick_count
Returns the uptime in seconds since the machine booted.
=head2 node_name
Machine name
=head2 domain_name
Returns the network domain name.
Synonyms:
=over 4
=item workgroup
=back
=head2 login_name
Returns the name of the effective user. Supports parameters in
C<< name => value >> format. Accepted parameters: C:
my $user = $os->login_name( real => 1 ) || $os->login_name;
=head2 ip
Returns the IP number.
=head2 fs
Returns an info hash about the filesystem. The contents of the hash can
vary among different systems.
=head2 host_name
=head2 time_zone
=head2 product_type
=head2 bitness
If successful, returns the bitness ( C<32> or C<64> ) of the OS. Returns
false otherwise.
=head2 meta
Returns a hash containing various informations about the OS.
=head2 cdkey
=head2 locale
=head1 UTILITY METHODS
These are some useful utility methods.
=head2 is_windows
Returns true if the os is windows.
Synonyms:
=over 4
=item is_win32
=item is_win
=back
=head2 is_winnt
Returns true if the OS is a NT based system (NT/2000/XP/2003).
Always returns false if you are not under windows or you are
not under a NT based system.
=head2 is_win95
Returns true if the OS is a 9x based system (95/98/Me).
Always returns false if you are not under Windows or
Windows9x.
Synonyms:
=over 4
=item is_win9x
=back
=head2 is_linux
Returns true if the os is linux.
Synonyms:
=over 4
=item is_lin
=back
=head2 is_bsd
Returns true if the os is (free|open|net)bsd.
=head2 is_unknown
Returns true if this module does not support the OS directly.
=head2 is_root
Returns true if the current user has admin rights.
Synonyms:
=over 4
=item is_admin
=item is_admin_user
=item is_adminuser
=item is_root_user
=item is_rootuser
=item is_super_user
=item is_superuser
=item is_su
=back
=head1 CAVEATS
=over 4
=item *
I don't have access to all operating systems in the world, so this module
(currently) only supports Windows, Linux and (Free)BSD. Windows support is better.
If you want support for some other OS, you'll need to write the driver
yourself. Anything other than natively supported systems will fall-back
to the generic C driver which has I limited capabilities.
=item *
Win32::IsAdminUser() implemented in 5.8.4 (However, it is possible to
manually upgrade the C module). If your ActivePerl
is older than this, C method will always returns false.
(There I be a workaround for that).
=item *
Contents of the filesystem hash may change in further releases.
=item *
Filesystem [Windows]
File system information can not be extracted under restricted
environments. If this is the case, we'll get an
I error.
=item *
Bitness has some problems [Linux, BSD], especially on the os side.
=back
=head1 SEE ALSO
L, L,
L,
L,
L.
=head1 AUTHOR
Burak Gursoy
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
__END__
use Socket;
sub network_name {
my $self = shift;
my $ip = shift;
my $iaddr = inet_aton($ip);
my $name = gethostbyaddr($iaddr, AF_INET);
return $name || $ip;
}
#
sub disk_quota {}
#
Sys-Info-Base-0.7810/lib/Sys/Info/Helper.pm 000644 000765 000024 00000014146 15056376347 020421 0 ustar 00burak staff 000000 000000 package Sys::Info::Helper;
$Sys::Info::Helper::VERSION = '0.7810';
use strict;
use warnings;
use parent qw(Exporter);
use File::Spec::Functions qw( catdir catfile );
use File::Path;
use File::Basename;
use Cwd;
use Carp qw( croak );
use Data::Dumper;
use Text::Template::Simple;
our @EXPORT = qw( new_driver );
sub new {
my($class, @args) = @_;
my $self = {
@args % 2 ? () : @args,
};
bless $self, $class;
return $self;
}
sub new_driver {
my $os = shift || croak 'OS name?';
my $you = shift || 'Your Name';
my $self = __PACKAGE__->new( os => $os, you => $you );
my $mb = catdir qw( lib Sys Info Driver );
my %file = (
catfile( $mb, "$os.pm" ) => $self->_template( 'base' ),
catfile( $mb, $os, 'OS.pm' ) => $self->_template( 'os' ),
catfile( $mb, $os, 'Device.pm' ) => $self->_template( 'device' ),
catfile( $mb, $os, 'Device', 'CPU.pm') => $self->_template( 'cpu' ),
catfile( qw( t 01-basic.t ) ) => $self->_template( 't' ),
'Changes' => $self->_template( 'changes' ),
'README' => $self->_template( 'readme' ),
);
$file{MANIFEST} = $self->_manifest( \%file );
return print Dumper( \%file );
}
sub _write_files {}
sub _manifest {
my($self, $file) = @_;
my @list = keys %{ $file };
return join "\n", map { s{\\}{/}xmsg; $_ } sort @list;
}
sub _template {
my($self, $target) = @_;
my $meth = '_template_' . $target;
croak "$target is not a valid target" if ! $self->can( $meth );
my $id = $self->{os};
my $you = $self->{you};
my $date = localtime time;
my $year = (localtime time)[5] + 1900;
my $perlv = $];
my $tmp = $self->$meth();
$tmp =~ s{<%ID%>}{$id}xmsg;
$tmp =~ s{<%DATE%>}{$date}xmsg;
$tmp =~ s{<%YEAR%>}{$year}xmsg;
$tmp =~ s{<%PERLV%>}{$perlv}xmsg;
$tmp =~ s{<%YOU%>}{$you}xmsg;
return $tmp;
}
sub _template_readme {
my $self = shift;
return <<'TEMPLATE';
Sys::Info::Driver::<%ID%>
========================
<%ID%> driver for Sys::Info.
Read the module's POD for documentation.
See the tests for examples.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
or under Windows:
perl Makefile.PL
nmake
nmake test
nmake install
COPYRIGHT
Copyright (c) <%YEAR%> <%YOU%>. All rights reserved.
LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version <%PERLV%> or,
at your option, any later version of Perl 5 you may have available.
TEMPLATE
}
sub _template_changes {
my $self = shift;
return <<'TEMPLATE';
Revision history for Perl extension Sys::Info::Driver::<%ID%>.
0.10 <%DATE%>
=> Initial release.
TEMPLATE
}
sub _template_device {
my $self = shift;
return <<'TEMPLATE';
package Sys::Info::Driver::<%ID%>::Device;
use strict;
use warnings;
use vars qw( $VERSION );
$VERSION = '0.10';
1;
__END__
=head1 NAME
Sys::Info::Driver::<%ID%>::Device - Base class for <%ID%> device drivers
=head1 SYNOPSIS
use parent qw( Sys::Info::Driver::<%ID%>::Device );
=head1 DESCRIPTION
Base class for <%ID%> device drivers.
=cut
TEMPLATE
}
sub _template_base {
my $self = shift;
return <<'TEMPLATE';
package Sys::Info::Driver::<%ID%>;
use strict;
use warnings;
use vars qw( $VERSION );
$VERSION = '0.10';
1;
__END__
=head1 NAME
Sys::Info::Driver::<%ID%> - <%ID%> driver for Sys::Info
=head1 SYNOPSIS
use Sys::Info::Driver::<%ID%>;
=head1 DESCRIPTION
This is the main module in the C<<%ID%>> driver collection.
=cut
TEMPLATE
}
sub _template_cpu {
my $self = shift;
return <<'TEMPLATE';
package Sys::Info::Driver::<%ID%>::Device::CPU;
use strict;
use warnings;
use vars qw($VERSION);
use parent qw(Sys::Info::Base);
$VERSION = '0.10';
sub identify { }
sub bitness { }
sub load { }
1;
__END__
=head1 NAME
Sys::Info::Driver::<%ID%>::Device::CPU - <%ID%> CPU Device Driver
=head1 SYNOPSIS
-
=head1 DESCRIPTION
Identifies the CPU.
=head1 METHODS
=head2 identify
See identify in L.
=head2 load
See load in L.
=head2 bitness
See bitness in L.
=head1 SEE ALSO
L, L.
=cut
TEMPLATE
}
sub _template_t {
my $self = shift;
return <<'TEMPLATE';
#!/usr/bin/env perl
use strict;
use warnings;
use Test::Sys::Info;
driver_ok('<%ID%>');
TEMPLATE
}
sub _template_os {
my $self = shift;
return <<'TEMPLATE';
package Sys::Info::Driver::<%ID%>::OS;
use strict;
use warnings;
use vars qw( $VERSION );
use parent qw( Sys::Info::Base );
$VERSION = '0.10';
sub init {
my $self = shift;
# initialize here, if necessary
return;
}
sub logon_server {}
sub edition { }
sub tz { }
sub meta { }
sub tick_count { }
sub name { }
sub version { }
sub build { }
sub uptime { }
sub is_root { }
sub login_name { }
sub node_name { }
sub domain_name { }
sub fs { }
sub bitness { }
1;
__END__
=pod
=head1 NAME
Sys::Info::Driver::<%ID%>::OS - <%ID%> backend
=head1 SYNOPSIS
-
=head1 DESCRIPTION
-
=head1 METHODS
Please see L for definitions of these methods and more.
=head2 build
=head2 domain_name
=head2 edition
=head2 fs
=head2 is_root
=head2 login_name
=head2 logon_server
=head2 meta
=head2 name
=head2 node_name
=head2 tick_count
=head2 tz
=head2 uptime
=head2 version
=head2 bitness
=head1 SEE ALSO
L, L.
=cut
TEMPLATE
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Sys::Info::Helper
=head1 VERSION
version 0.7810
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 NAME
Sys::Info::Helper - Helps to create new Sys::Info drivers.
=head1 METHODS
=head2 new
=head1 FUNCTIONS
=head2 new_driver
=head1 SEE ALSO
L.
=head1 AUTHOR
Burak Gursoy
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
Sys-Info-Base-0.7810/lib/Sys/Info/Device/ 000755 000765 000024 00000000000 15056376347 020035 5 ustar 00burak staff 000000 000000 Sys-Info-Base-0.7810/lib/Sys/Info/Driver.pm 000644 000765 000024 00000001212 15056376347 020423 0 ustar 00burak staff 000000 000000 package Sys::Info::Driver;
$Sys::Info::Driver::VERSION = '0.7810';
use strict;
use warnings;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Sys::Info::Driver
=head1 VERSION
version 0.7810
=head1 NAME
Sys::Info::Driver - Driver base class
=head1 SEE ALSO
L,
L,
L,
L,
L.
=head1 AUTHOR
Burak Gursoy
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
Sys-Info-Base-0.7810/lib/Sys/Info/Base.pm 000644 000765 000024 00000011676 15056376347 020061 0 ustar 00burak staff 000000 000000 package Sys::Info::Base;
$Sys::Info::Base::VERSION = '0.7810';
use strict;
use warnings;
use IO::File;
use Carp qw( croak );
use File::Spec;
use Sys::Info::Constants qw( :date OSID );
use constant DRIVER_FAIL_MSG => q{Operating system identified as: '%s'. }
. q{Native driver can not be loaded: %s. }
. q{Falling back to compatibility mode};
use constant YEAR_DIFF => 1900;
my %LOAD_MODULE; # cache
my %UNAME; # cache
sub load_subclass { # hybrid: static+dynamic
my $self = shift;
my $template = shift || croak 'Template missing for load_subclass()';
my $class;
my $eok = eval { $class = $self->load_module( sprintf $template, OSID ); };
if ( $@ || ! $eok ) {
my $msg = sprintf DRIVER_FAIL_MSG, OSID, $@;
warn "$msg\n";
$class = $self->load_module( sprintf $template, 'Unknown' );
}
return $class;
}
sub load_module {
my $self = shift;
my $class = shift || croak 'No class name specified for load_module()';
return $class if $LOAD_MODULE{ $class };
croak "Invalid class name: $class" if ref $class;
(my $check = $class) =~ tr/a-zA-Z0-9_://d;
croak "Invalid class name: $class" if $check;
my @raw_file = split /::/xms, $class;
my $inc_file = join( q{/}, @raw_file) . '.pm';
return $class if exists $INC{ $inc_file };
my $file = File::Spec->catfile( @raw_file ) . '.pm';
my $eok = eval { require $file; };
croak "Error loading $class: $@" if $@ || ! $eok;
$LOAD_MODULE{ $class } = 1;
$INC{ $inc_file } = $file;
return $class;
}
sub trim {
my($self, $str) = @_;
return $str if ! $str;
$str =~ s{ \A \s+ }{}xms;
$str =~ s{ \s+ \z }{}xms;
return $str;
}
sub slurp { # fetches all data inside a flat file
my $self = shift;
my $file = shift;
my $msgerr = shift || 'I can not open file %s for reading: ';
my $FH = IO::File->new;
$FH->open( $file ) or croak sprintf($msgerr, $file) . $!;
my $slurped = do {
local $/;
my $rv = <$FH>;
$rv;
};
$FH->close;
return $slurped;
}
sub read_file {
my $self = shift;
my $file = shift;
my $msgerr = shift || 'I can not open file %s for reading: ';
my $FH = IO::File->new;
$FH->open( $file ) or croak sprintf( $msgerr, $file ) . $!;
my @flat = <$FH>;
$FH->close;
return @flat;
}
sub date2time { # date stamp to unix time stamp conversion
my $self = shift;
my $stamp = shift || croak 'No date input specified';
my($i, $j) = (0,0); # index counters
my %wdays = map { $_ => $i++ } DATE_WEEKDAYS;
my %months = map { $_ => $j++ } DATE_MONTHS;
my @junk = split /\s+/xms, $stamp;
my $reg = join q{|}, keys %wdays;
# remove until ve get a day name
while ( @junk && $junk[0] !~ m{ \A $reg \z }xmsi ) {
shift @junk;
}
return q{} if ! @junk;
my($wday, $month, $mday, $time, $zone, $year) = @junk;
my($hour, $min, $sec) = split /:/xms, $time;
require POSIX;
my $unix = POSIX::mktime(
$sec,
$min,
$hour,
$mday,
$months{$month},
$year - YEAR_DIFF,
$wdays{$wday},
DATE_MKTIME_YDAY,
DATE_MKTIME_ISDST,
);
return $unix;
}
sub uname {
my $self = shift;
%UNAME = do {
require POSIX;
my %u;
@u{ qw( sysname nodename release version machine ) } = POSIX::uname();
%u;
} if ! %UNAME;
return { %UNAME };
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Sys::Info::Base
=head1 VERSION
version 0.7810
=head1 SYNOPSIS
use parent qw(Sys::Info::Base);
#...
sub foo {
my $self = shift;
my $data = $self->slurp("/foo/bar.txt");
}
=head1 DESCRIPTION
Includes some common methods.
=head1 NAME
Sys::Info::Base - Base class for Sys::Info
=head1 METHODS
=head2 load_module CLASS
Loads the module named with C.
=head2 load_subclass TEMPLATE
Loads the specified class via C:
my $class = __PACKAGE__->load_subclass('Sys::Info::Driver::%s::OS');
C<%s> will be replaced with C. Apart from the template usage, it is
the same as C.
=head2 trim STRING
Returns the trimmed version of C.
=head2 slurp FILE
Caches all contents of C into a scalar and then returns it.
=head2 read_file FILE
Caches all contents of C into an array and then returns it.
=head2 date2time DATE_STRING
Converts C into unix timestamp.
=head2 uname
Returns a hashref built from C.
=head1 SEE ALSO
L.
=head1 AUTHOR
Burak Gursoy
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
Sys-Info-Base-0.7810/lib/Sys/Info/Device/CPU.pm 000644 000765 000024 00000013420 15056376347 021022 0 ustar 00burak staff 000000 000000 package Sys::Info::Device::CPU;
$Sys::Info::Device::CPU::VERSION = '0.7810';
use strict;
use warnings;
use subs qw(hyper_threading ht);
use parent qw( Sys::Info::Base );
use Sys::Info::Constants qw( OSID );
use Carp qw( croak );
use parent __PACKAGE__->load_subclass('Sys::Info::Driver::%s::Device::CPU');
BEGIN {
# define aliases
*ht = \&hyper_threading;
}
sub new {
my($class, @args) = @_;
my %opt = @args % 2 ? () : @args;
my $self = {
%opt,
META_DATA => undef,
};
bless $self, $class;
return $self;
}
sub count {
my $self = shift;
my $id = shift || q{};
my @cpu = $self->identify;
if ( $id ) {
croak "Parameter to count($id) if bogus" if $id ne 'cores';
# do something
}
return @cpu ? scalar @cpu : undef;
}
sub hyper_threading {
my $self = shift;
my %test;
my $logical = 0;
foreach my $cpu ( $self->identify ) {
$logical++;
my $noc = $cpu->{number_of_cores};
my $nol = $cpu->{number_of_logical_processors};
if ( defined $noc && defined $nol ) {
# ht? then return the number of threads
return $nol if $noc != $nol;
}
next if not exists $cpu->{socket_designation};
$test{ $cpu->{socket_designation} }++;
}
return 0 if $logical < 1; # failed to fill cache
my $physical = keys %test;
return 0 if $physical < 1; # an error occurred somehow
return $logical > $physical;
}
sub speed {
my $self = shift;
my @cpu = $self->identify;
return if !@cpu || !ref $cpu[0];
return $cpu[0]->{speed};
}
sub load {
my $self = shift;
my $level = int +(shift || 0) + 0;
croak "Illegal cpu_load level: $level" if $level > 2 || $level < 0;
return $self->SUPER::load( $level );
}
# ------------------------[ P R I V A T E ]------------------------ #
sub _serve_from_cache {
my $self = shift;
my $context = shift;
return if not defined $context; # void context
croak 'Can not happen: META_DATA is empty' if not $self->{META_DATA};
return @{ $self->{META_DATA} } if $context;
# scalar context
my @cpu = @{ $self->{META_DATA} };
# OK for single processor ("name" will be same)
my $count = @cpu;
my $name = $cpu[0] ? $cpu[0]->{name} : q{};
return $name if ! $count || $count == 1;
return "$count x $name";
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Sys::Info::Device::CPU
=head1 VERSION
version 0.7810
=head1 SYNOPSIS
use Sys::Info;
use Sys::Info::Constants qw( :device_cpu );
my $info = Sys::Info->new;
my $cpu = $info->device( CPU => %options );
Example:
printf "CPU: %s\n", scalar($cpu->identify) || 'N/A';
printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A';
printf "There are %d CPUs\n" , $cpu->count || 1;
printf "CPU load: %s\n" , $cpu->load || 0;
=head1 DESCRIPTION
Collects and returns information about the Central Processing Unit
(CPU) on the host machine.
Some platforms can limit the available information under some
user accounts and this will affect the accessible amount of
data. When this happens, some methods will not return
anything usable.
=head1 NAME
Sys::Info::Device::CPU - CPU information.
=head1 METHODS
=head2 new
Acceps parameters in C<< key => value >> format.
=head3 cache
If has a true value, internal cache will be enabled.
Cache timeout can be controlled via C
parameter.
On some platforms, some methods can take a long time
to be completed (i.e.: WMI access on Windows platform).
If cache is enabled, all gathered data will be saved
in an internal in-memory cache and, the related method will
serve from cache until the cache expires.
Cache only has a meaning, if you call the related method
continiously (in a loop, under persistent environments
like GUI, mod_perl, PerlEx, etc.). It will not have any
effect if you are calling it only once.
=head3 cache_timeout
Must be used together with C parameter. If cache
is enabled, and this is not set, it will take the default
value: C<10>.
Timeout value is in seconds.
=head2 identify
If called in a list context; returns an AoH filled with
CPU metadata. If called in a scalar context, returns the
name of the CPU (if CPU is multi-core or there are multiple CPUs,
it'll also include the number of CPUs).
Returns C upon failure.
=head2 speed
Returns the CPU clock speed in MHz if successful.
Returns C otherwise.
=head2 count
Returns the number of CPUs (or number of total cores).
=head2 bitness
If successful, returns the bitness ( C<32> or C<64> ) of the CPU. Returns
false otherwise.
=head2 load [, LEVEL]
Returns the CPU load percentage if successful.
Returns C otherwise.
The average CPU load average in the last minute. If you pass a
level argument, it'll return the related CPU load.
use Sys::Info::Constants qw( :device_cpu );
printf "CPU Load: %s\n", $cpu->load(DCPU_LOAD_LAST_01);
Load level constants:
LEVEL MEANING
----------------- -------------------------------
DCPU_LOAD_LAST_01 CPU Load in the last 1 minute
DCPU_LOAD_LAST_05 CPU Load in the last 5 minutes
DCPU_LOAD_LAST_10 CPU Load in the last 10 minutes
C defaults to C.
Using this method under I is not recommended since,
the C interface will possibly take at least C<2> seconds
to complete the request.
=head2 hyper_threading
=head2 ht
Returns the number of threads if hyper threading is supported, returns false
otherwise.
=head1 SEE ALSO
L, L, L.
=head1 AUTHOR
Burak Gursoy
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2006 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
Sys-Info-Base-0.7810/t/slurp.txt 000644 000765 000024 00000000005 15056376347 016563 0 ustar 00burak staff 000000 000000 slurp Sys-Info-Base-0.7810/t/author-pod-coverage.t 000644 000765 000024 00000000567 15056376347 020732 0 ustar 00burak staff 000000 000000 #!perl
BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
print qq{1..0 # SKIP these tests are for testing by the author\n};
exit
}
}
# This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests.
use strict;
use warnings;
use Test::Pod::Coverage 1.08;
use Pod::Coverage::TrustPod;
all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });
Sys-Info-Base-0.7810/t/00-report-prereqs.t 000644 000765 000024 00000013601 15056376347 020257 0 ustar 00burak staff 000000 000000 #!perl
use strict;
use warnings;
# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.029
use Test::More tests => 1;
use ExtUtils::MakeMaker;
use File::Spec;
# from $version::LAX
my $lax_version_re =
qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )?
|
(?:\.[0-9]+) (?:_[0-9]+)?
) | (?:
v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )?
|
(?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)?
)
)/x;
# hide optional CPAN::Meta modules from prereq scanner
# and check if they are available
my $cpan_meta = "CPAN::Meta";
my $cpan_meta_pre = "CPAN::Meta::Prereqs";
my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic
# Verify requirements?
my $DO_VERIFY_PREREQS = 1;
sub _max {
my $max = shift;
$max = ( $_ > $max ) ? $_ : $max for @_;
return $max;
}
sub _merge_prereqs {
my ($collector, $prereqs) = @_;
# CPAN::Meta::Prereqs object
if (ref $collector eq $cpan_meta_pre) {
return $collector->with_merged_prereqs(
CPAN::Meta::Prereqs->new( $prereqs )
);
}
# Raw hashrefs
for my $phase ( keys %$prereqs ) {
for my $type ( keys %{ $prereqs->{$phase} } ) {
for my $module ( keys %{ $prereqs->{$phase}{$type} } ) {
$collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module};
}
}
}
return $collector;
}
my @include = qw(
);
my @exclude = qw(
);
# Add static prereqs to the included modules list
my $static_prereqs = do './t/00-report-prereqs.dd';
# Merge all prereqs (either with ::Prereqs or a hashref)
my $full_prereqs = _merge_prereqs(
( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ),
$static_prereqs
);
# Add dynamic prereqs to the included modules list (if we can)
my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml';
my $cpan_meta_error;
if ( $source && $HAS_CPAN_META
&& (my $meta = eval { CPAN::Meta->load_file($source) } )
) {
$full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs);
}
else {
$cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source)
$source = 'static metadata';
}
my @full_reports;
my @dep_errors;
my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs;
# Add static includes into a fake section
for my $mod (@include) {
$req_hash->{other}{modules}{$mod} = 0;
}
for my $phase ( qw(configure build test runtime develop other) ) {
next unless $req_hash->{$phase};
next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING});
for my $type ( qw(requires recommends suggests conflicts modules) ) {
next unless $req_hash->{$phase}{$type};
my $title = ucfirst($phase).' '.ucfirst($type);
my @reports = [qw/Module Want Have/];
for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) {
next if grep { $_ eq $mod } @exclude;
my $want = $req_hash->{$phase}{$type}{$mod};
$want = "undef" unless defined $want;
$want = "any" if !$want && $want == 0;
if ($mod eq 'perl') {
push @reports, ['perl', $want, $]];
next;
}
my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required";
my $file = $mod;
$file =~ s{::}{/}g;
$file .= ".pm";
my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC;
if ($prefix) {
my $have = MM->parse_version( File::Spec->catfile($prefix, $file) );
$have = "undef" unless defined $have;
push @reports, [$mod, $want, $have];
if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) {
if ( $have !~ /\A$lax_version_re\z/ ) {
push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)";
}
elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) {
push @dep_errors, "$mod version '$have' is not in required range '$want'";
}
}
}
else {
push @reports, [$mod, $want, "missing"];
if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) {
push @dep_errors, "$mod is not installed ($req_string)";
}
}
}
if ( @reports ) {
push @full_reports, "=== $title ===\n\n";
my $ml = _max( map { length $_->[0] } @reports );
my $wl = _max( map { length $_->[1] } @reports );
my $hl = _max( map { length $_->[2] } @reports );
if ($type eq 'modules') {
splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports;
}
else {
splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports;
}
push @full_reports, "\n";
}
}
}
if ( @full_reports ) {
diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports;
}
if ( $cpan_meta_error || @dep_errors ) {
diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n";
}
if ( $cpan_meta_error ) {
my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml';
diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n";
}
if ( @dep_errors ) {
diag join("\n",
"\nThe following REQUIRED prerequisites were not satisfied:\n",
@dep_errors,
"\n"
);
}
pass('Reported prereqs');
# vim: ts=4 sts=4 sw=4 et:
Sys-Info-Base-0.7810/t/lib/ 000755 000765 000024 00000000000 15056376347 015430 5 ustar 00burak staff 000000 000000 Sys-Info-Base-0.7810/t/author-pod-syntax.t 000644 000765 000024 00000000454 15056376347 020460 0 ustar 00burak staff 000000 000000 #!perl
BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
print qq{1..0 # SKIP these tests are for testing by the author\n};
exit
}
}
# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
use strict; use warnings;
use Test::More;
use Test::Pod 1.41;
all_pod_files_ok();
Sys-Info-Base-0.7810/t/03-basic.t 000644 000765 000024 00000002467 15056376347 016361 0 ustar 00burak staff 000000 000000 #!/usr/bin/env perl -w
use strict;
use warnings;
use lib qw( t/lib );
use Test::More qw( no_plan );
use File::Spec;
use constant FILE => File::Spec->catfile( qw( t slurp.txt ) );
use Sys::Info::Constants qw( OSID );
BEGIN {
my @fakes =
map { sprintf $_, OSID() }
qw(
Sys::Info::Driver::%s::Device::CPU
Sys::Info::Driver::%s::OS
);
foreach my $class ( @fakes ) {
(my $file = $class) =~ s{::}{/}xmsg;
$file .= q(.pm);
$INC{ $file } = $class;
}
}
# Sys::Info::Device::CPU
# Sys::Info::Device
# Sys::Info::OS
# ... can not be tested without a driver
# TODO: interface test for Sys::Info::Constants
use Sys::Info::Base;
use Sys::Info::Driver;
is( Sys::Info::Base->slurp(FILE), 'slurp', 'slurp() works' );
ok( Sys::Info::Base->load_module('MyLoadableThing'), 'load_module() works');
ok( defined &MyLoadableThing::fancy_sub, 'ExtUtils::MakeMaker::WriteMakefile is defined' );
is( Sys::Info::Base->trim(" \n\n Foo \n \t \n "), 'Foo', 'trim() works');
ok( my @f = Sys::Info::Base->read_file(FILE), 'read_file() works' );
is( $f[0], 'slurp', 'read_file() works' );
ok( my $t = Sys::Info::Base->date2time('1 Fri Jul 23 20:48:29 CDT 2004'),
'date2time() works');
like( scalar( localtime $t ), qr{Jul .+? 2004}xms, 'Got an approximate date' );
1;
Sys-Info-Base-0.7810/t/00-report-prereqs.dd 000644 000765 000024 00000002574 15056376347 020412 0 ustar 00burak staff 000000 000000 do { my $x = {
'configure' => {
'requires' => {
'ExtUtils::MakeMaker' => '0'
}
},
'develop' => {
'requires' => {
'Pod::Coverage::TrustPod' => '0',
'Test::CPAN::Meta' => '0',
'Test::Pod' => '1.41',
'Test::Pod::Coverage' => '1.08'
}
},
'runtime' => {
'requires' => {
'Sys::HostIP' => '0',
'Text::Template::Simple' => '0',
'parent' => '0',
'perl' => '5.010'
}
},
'test' => {
'recommends' => {
'CPAN::Meta' => '2.120900'
},
'requires' => {
'ExtUtils::MakeMaker' => '0',
'File::Spec' => '0',
'Test::More' => '0'
}
}
};
$x;
} Sys-Info-Base-0.7810/t/author-distmeta.t 000644 000765 000024 00000000425 15056376347 020162 0 ustar 00burak staff 000000 000000 #!perl
BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
print qq{1..0 # SKIP these tests are for testing by the author\n};
exit
}
}
# This file was automatically generated by Dist::Zilla::Plugin::MetaTests.
use strict;
use warnings;
use Test::CPAN::Meta;
meta_yaml_ok();
Sys-Info-Base-0.7810/t/lib/MyLoadableThing.pm 000644 000765 000024 00000000147 15056376347 020773 0 ustar 00burak staff 000000 000000 package MyLoadableThing;
use strict;
use warnings;
sub fancy_sub {
print "42\n";
}
1;
__END__