Sys-Info-Base-0.7804000755000765000024 012457601220 13522 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/.perlcriticrc000444000765000024 212112457601220 16341 0ustar00burakstaff000000000000# disable these [-Miscellanea::RequireRcsKeywords] [-ValuesAndExpressions::ProhibitConstantPragma] [-ValuesAndExpressions::ProhibitLeadingZeros] [-Variables::RequireInitializationForLocalVars] [-Modules::ProhibitMultiplePackages] [-ControlStructures::ProhibitPostfixControls] [-Modules::ProhibitAutomaticExportation] [-CodeLayout::RequireTidyCode] [-Documentation::RequirePodSections] [-Variables::ProhibitPunctuationVars] [-Modules::RequireExplicitPackage] [-BuiltinFunctions::ProhibitStringyEval] [-Modules::RequireVersionVar] [-ValuesAndExpressions::RequireInterpolationOfMetachars] [-Documentation::RequirePodLinksIncludeText] # configurable parts [TestingAndDebugging::ProhibitNoStrict] allow = refs [Subroutines::ProhibitManyArgs] max_arguments = 8 [Variables::RequireLocalizedPunctuationVars] allow = %ENV %INC $| [RegularExpressions::RequireBracesForMultiline] allow_all_brackets = 1 [RegularExpressions::ProhibitUnusualDelimiters] allow_all_brackets = 1 [Variables::ProhibitPackageVars] packages = Data::Dumper File::Find FindBin Log::Log4perl Config Sys-Info-Base-0.7804/Build.PL000444000765000024 44412457601220 15135 0ustar00burakstaff000000000000#!/usr/bin/env perl # This file was created automatically use 5.006; use strict; use warnings; use lib qw( builder/lib ); use Build; my $mb = Build->new; $mb->add_pod_author_copyright_license( 1 ); $mb->copyright_first_year( 2006 ); $mb->change_versions( 1 ); $mb->create_build_script; 1; Sys-Info-Base-0.7804/Changes000444000765000024 233612457601220 15156 0ustar00burakstaff000000000000Revision history for Perl extension Sys::Info::Base. 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.7804/LICENSE000444000765000024 4373612457601220 14721 0ustar00burakstaff000000000000This software is copyright (c) 2015 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) 2015 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. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA 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 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2015 by Burak Gursoy . This is free software, licensed under: The 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. - "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 ftp.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) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting 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. 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 whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Sys-Info-Base-0.7804/Makefile.PL000444000765000024 100012457601220 15620 0ustar00burakstaff000000000000#!/usr/bin/env perl # This file was created automatically use 5.006; use strict; use warnings; use lib qw( builder/lib ); use Build::Spec qw( mm_spec ); use ExtUtils::MakeMaker; my %spec = mm_spec; WriteMakefile( NAME => $spec{module_name}, VERSION_FROM => $spec{VERSION_FROM}, PREREQ_PM => $spec{PREREQ_PM}, PL_FILES => {}, ($] >= 5.005 ? ( AUTHOR => $spec{dist_author}, ABSTRACT => $spec{ABSTRACT}, EXE_FILES => $spec{EXE_FILES}, ) : ()), ); Sys-Info-Base-0.7804/MANIFEST000444000765000024 133512457601220 15012 0ustar00burakstaff000000000000.perlcriticrc Build.PL Generated automatically builder/lib/Build.pm builder/lib/Build/Constants.pm builder/lib/Build/Spec.pm builder/lib/Build/Util.pm builder/templates/pod/author.pod builder/templates/pod/monolith-warning.pod builder/templates/tools/Build.PL builder/templates/tools/builder.header builder/templates/tools/Makefile.PL builder/templates/tools/Makefile.PL.hook Changes 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 LICENSE Makefile.PL Generated automatically MANIFEST META.json META.yml README SPEC t/03-basic.t t/lib/MyLoadableThing.pm t/slurp.txt xt/author/201-pod.t xt/author/202-pod-coverage.t Sys-Info-Base-0.7804/META.json000444000765000024 343412457601220 15304 0ustar00burakstaff000000000000{ "abstract" : "Base class for Sys::Info", "author" : [ "Burak Gursoy " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4005, CPAN::Meta::Converter version 2.131560", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Sys-Info-Base", "no_index" : { "directory" : [ "monolithic_version", "builder", "t", "xt" ] }, "prereqs" : { "build" : { "requires" : { "Test::More" : "0.40" } }, "configure" : { "requires" : { "Module::Build" : "0.40" } } }, "provides" : { "Sys::Info::Base" : { "file" : "lib/Sys/Info/Base.pm", "version" : "0.7804" }, "Sys::Info::Constants" : { "file" : "lib/Sys/Info/Constants.pm", "version" : "0.7804" }, "Sys::Info::Device" : { "file" : "lib/Sys/Info/Device.pm", "version" : "0.7804" }, "Sys::Info::Device::CPU" : { "file" : "lib/Sys/Info/Device/CPU.pm", "version" : "0.7804" }, "Sys::Info::Driver" : { "file" : "lib/Sys/Info/Driver.pm", "version" : "0.7804" }, "Sys::Info::Helper" : { "file" : "lib/Sys/Info/Helper.pm", "version" : "0.7804" }, "Sys::Info::OS" : { "file" : "lib/Sys/Info/OS.pm", "version" : "0.7804" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://github.com/burak/cpan-sys-info-base/" } }, "version" : "0.7804" } Sys-Info-Base-0.7804/META.yml000444000765000024 214412457601220 15131 0ustar00burakstaff000000000000--- abstract: 'Base class for Sys::Info' author: - 'Burak Gursoy ' build_requires: Test::More: 0.40 configure_requires: Module::Build: 0.40 dynamic_config: 1 generated_by: 'Module::Build version 0.4005, CPAN::Meta::Converter version 2.131560' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Sys-Info-Base no_index: directory: - monolithic_version - builder - t - xt provides: Sys::Info::Base: file: lib/Sys/Info/Base.pm version: 0.7804 Sys::Info::Constants: file: lib/Sys/Info/Constants.pm version: 0.7804 Sys::Info::Device: file: lib/Sys/Info/Device.pm version: 0.7804 Sys::Info::Device::CPU: file: lib/Sys/Info/Device/CPU.pm version: 0.7804 Sys::Info::Driver: file: lib/Sys/Info/Driver.pm version: 0.7804 Sys::Info::Helper: file: lib/Sys/Info/Helper.pm version: 0.7804 Sys::Info::OS: file: lib/Sys/Info/OS.pm version: 0.7804 resources: license: http://dev.perl.org/licenses/ repository: http://github.com/burak/cpan-sys-info-base/ version: 0.7804 Sys-Info-Base-0.7804/README000444000765000024 113712457601220 14541 0ustar00burakstaff000000000000Sys::Info::Base =============== Base classes for Sys::Info. Read the module's POD for documentation. See the tests for examples. INSTALLATION Don't try to install this module directly. Install the Sys::Info module instead, which'll fetch this module as well. Just use the cpan shell to install this module. From a command prompt, type: cpan or perl -MCPAN -e shell to enter the cpan shell. And then enter: install Sys::Info If you don't have the cpan shell available, then you have a broken perl installation. COPYRIGHT & LICENSE See the LICENSE file bundled with this distribution. Sys-Info-Base-0.7804/SPEC000444000765000024 77212457601220 14322 0ustar00burakstaff000000000000{ module_name => 'Sys::Info::Base', requires => {}, meta_merge => { resources => { repository => 'http://github.com/burak/cpan-sys-info-base/', }, }, meta_merge => { resources => { repository => 'http://github.com/burak/cpan-sys-info-base/', }, }, BUILDER => { change_versions => 1, copyright_first_year => 2006, add_pod_author_copyright_license => 1, }, } Sys-Info-Base-0.7804/builder000755000765000024 012457601220 15150 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/builder/lib000755000765000024 012457601220 15716 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/builder/lib/Build.pm000444000765000024 4275112457601220 17501 0ustar00burakstaff000000000000package Build; use strict; use warnings; use base qw( Module::Build ); ## no critic (InputOutput::ProhibitBacktickOperators) our $VERSION = '0.81'; use Carp qw( croak ); use Cwd qw( getcwd ); use File::Find; use File::Spec; use File::Path; use constant { CURRENT_DIR => getcwd, }; use Build::Constants qw( :all ); use Build::Spec; use Build::Util qw( slurp trim ); BEGIN { my %default = ( add_pod_author_copyright_license => 0, build_monolith => 0, change_versions => 0, copyright_first_year => 0, initialization_hook => q(), monolith_add_to_top => [], taint_mode_tests => 0, vanilla_makefile_pl => 1, ); foreach my $meth ( keys %default ) { __PACKAGE__->add_property( $meth => $default{ $meth } ); } } sub new { my $class = shift; my %opt = spec; my %def = DEFAULTS; foreach my $key ( keys %def ) { $opt{ $key } = $def{ $key } if ! defined $opt{ $key }; } $opt{no_index} ||= {}; $opt{no_index}{directory} ||= []; push @{ $opt{no_index}{directory} }, NO_INDEX; return $class->SUPER::new( %opt ); } sub create_build_script { my $self = shift; $self->_add_vanilla_makefile_pl if $self->vanilla_makefile_pl; if ( my $hook = $self->initialization_hook ) { my $eok = eval $hook; croak "Error compiling initialization_hook: $@" if $@; } return $self->SUPER::create_build_script( @_ ); } sub ACTION_dist { ## no critic (NamingConventions::Capitalization) my $self = shift; my $msg = sprintf q{RUNNING 'dist' Action from subclass %s v%s}, ref($self), $VERSION; warn "$msg\n"; my @modules; find { wanted => sub { my $file = $_; return if $file !~ m{ [.] pm \z }xms; $file = File::Spec->catfile( $file ); push @modules, $file; warn "FOUND Module: $file\n"; }, no_chdir => 1, }, 'lib'; $self->_create_taint_mode_tests if $self->taint_mode_tests; $self->_change_versions( \@modules ) if $self->change_versions; $self->_build_monolith( \@modules ) if $self->build_monolith; return $self->SUPER::ACTION_dist( @_ ); } sub ACTION_extratest { # Stolen from # http://elliotlovesperl.com/2009/11/24/explicitly-running-author-tests # my($self) = @_; $self->depends_on( 'build' ); $self->depends_on( 'manifest' ); $self->depends_on( 'distmeta' ); $self->test_files( qw< xt > ); $self->recursive_test_files(1); $self->depends_on( 'test' ); return; } sub ACTION_distdir { my ($self) = @_; $self->depends_on( 'extratest' ); return $self->SUPER::ACTION_distdir(); } sub _create_taint_mode_tests { my $self = shift; my @tests = glob 't/*.t'; my @taints; require File::Basename; foreach my $t ( @tests ) { my($num,$rest) = split /\-/xms, File::Basename::basename( $t ), 2; push @taints, "t/$num-taint-mode-$rest"; } for my $i ( 0..$#tests ) { next if $tests[$i] =~ m{ pod[.]t \z }xms; next if $tests[$i] =~ m{ pod\-coverage[.]t \z }xms; next if $tests[$i] =~ m{ all\-modules\-have\-the\-same\-version[.]t \z }xms; next if -e $taints[$i]; # already created! open my $ORIG, '<:raw', $tests[$i] or croak "Can not open file($tests[$i]): $!"; open my $DEST, '>:raw', $taints[$i] or croak "Can not open file($taints[$i]): $!"; print {$DEST} TAINT_SHEBANG or croak "Can not print to destination: $!"; while ( defined( my $line = readline $ORIG ) ) { print {$DEST} $line or croak "Can not print to destination: $!"; } close $ORIG or croak "Can not close original: $!"; close $DEST or croak "Can not close destination: $!"; $self->_write_file( '>>', 'MANIFEST', "$taints[$i]\n"); } return; } sub _change_versions_pod { my($self, $mod) = @_; my $dver = $self->dist_version; my($mday, $mon, $year) = (localtime time)[3..5]; my $date = join q{ }, $mday, [MONTHS]->[$mon], $year + YEAR_ADD; my $ns = $mod; $ns =~ s{ [\\/] }{::}xmsg; $ns =~ s{ \A lib :: }{}xms; $ns =~ s{ [.] pm \z }{}xms; my $pod = "\nThis document describes version C<$dver> of C<$ns>\n" . "released on C<$date>.\n" ; if ( $dver =~ m{[_]}xms ) { $pod .= join qq{\n}, "\nB: This version of the module is part of a", "developer (beta) release of the distribution and it is", "not suitable for production use.", ; } return $pod; } sub _change_versions { my($self, $files) = @_; my $dver = $self->dist_version; warn "CHANGING VERSIONS\n"; warn "\tDISTRO Version: $dver\n"; foreach my $mod ( @{ $files } ) { warn "\tPROCESSING $mod\n"; my $new = $mod . '.new'; open my $RO_FH, '<:raw', $mod or croak "Can not open file($mod): $!"; open my $W_FH , '>:raw', $new or croak "Can not open file($new): $!"; CHANGE_VERSION: while ( defined( my $line = readline $RO_FH ) ) { if ( $line =~ RE_VERSION_LINE ) { my $prefix = $1 || q{}; my $oldv = $2; my $remainder = $3; warn "\tCHANGED Version from $oldv to $dver\n"; printf {$W_FH} VTEMP . $remainder, $prefix, $dver; last CHANGE_VERSION; } print {$W_FH} $line or croak "Unable to print to FH: $!"; } $self->_change_pod( $RO_FH, $W_FH, $mod ); close $RO_FH or croak "Can not close file($mod): $!"; close $W_FH or croak "Can not close file($new): $!"; unlink($mod) || croak "Can not remove original module($mod): $!"; rename( $new, $mod ) || croak "Can not rename( $new, $mod ): $!"; warn "\tRENAME Successful!\n"; } return; } sub _change_pod { my($self, $RO_FH, $W_FH, $mod) = @_; my $acl = $self->add_pod_author_copyright_license; my $acl_buf; CHANGE_POD: while ( defined( my $line = readline $RO_FH ) ) { if ( $acl && $line =~ m{ \A =cut }xms ) { $acl_buf = $line; # buffer the last line last; } print {$W_FH} $line or croak "Unable to print to FH: $!"; if ( $line =~ RE_POD_LINE ) { print {$W_FH} $self->_change_versions_pod( $mod ) or croak "Unable to print to FH: $!"; } } if ( $acl && defined $acl_buf ) { warn "\tADDING AUTHOR COPYRIGHT LICENSE TO POD\n"; print {$W_FH} $self->_pod_author_copyright_license, $acl_buf or croak "Unable to print to FH: $!"; while ( defined( my $line = readline $RO_FH ) ) { print {$W_FH} $line or croak "Unable to print to FH: $!"; } } return; } sub _build_monolith { my $self = shift; my $files = shift; my @mono_dir = ( monolithic_version => split /::/xms, $self->module_name ); my $mono_file = pop(@mono_dir) . '.pm'; my $dir = File::Spec->catdir( @mono_dir ); my $mono = File::Spec->catfile( $dir, $mono_file ); my $buffer = File::Spec->catfile( $dir, 'buffer.txt' ); my $readme = File::Spec->catfile( qw( monolithic_version README ) ); my $copy = $mono . '.tmp'; mkpath $dir; warn "STARTING TO BUILD MONOLITH\n"; my(@files, $c); foreach my $f ( @{ $files }) { my(undef, undef, $base) = File::Spec->splitpath($f); if ( $base eq 'Constants.pm' ) { $c = $f; next; } push @files, $f; } push @files, $c; my $POD = $self->_monolith_merge(\@files, $mono_file, $mono, $buffer); $self->_monolith_add_pre( $mono, $copy, \@files, $buffer ); if ( $POD ) { open my $MONOX, '>>:raw', $mono or croak "Can not open file($mono): $!"; foreach my $line ( split /\n/xms, $POD ) { print {$MONOX} $line, "\n" or croak "Unable to print to FH: $!"; if ( "$line\n" =~ RE_POD_LINE ) { print {$MONOX} $self->_monolith_pod_warning or croak "Unable to print to FH: $!"; } } close $MONOX or croak "Unable to close FH: $!";; } unlink $buffer or croak "Can not delete $buffer $!"; unlink $copy or croak "Can not delete $copy $!"; print "\t" or croak "Unable to print to STDOUT: $!"; system( $^X, '-wc', $mono ) && die "$mono does not compile!\n"; $self->_monolith_prove; warn "\tADD README\n"; $self->_write_file('>', $readme, $self->_monolith_readme); warn "\tADD TO MANIFEST\n"; (my $monof = $mono ) =~ s{\\}{/}xmsg; (my $readmef = $readme) =~ s{\\}{/}xmsg; my $name = $self->module_name; $self->_write_file( '>>', 'MANIFEST', "$readmef\n", "$monof\tThe monolithic version of $name", " to ease dropping into web servers. Generated automatically.\n" ); return; } sub _monolith_merge { my($self, $files, $mono_file, $mono, $buffer) = @_; my %add_pod; my $pod = q{}; open my $MONO , '>:raw', $mono or croak "Can't open file($mono): $!"; open my $BUFFER, '>:raw', $buffer or croak "Can't open file($buffer): $!"; MONO_FILES: foreach my $mod ( reverse @{ $files } ) { warn "\tMERGE $mod\n"; my(undef, undef, $base) = File::Spec->splitpath( $mod ); my $is_eof = 0; my $is_pre = $self->_monolith_add_to_top( $base ); my $TARGET = $is_pre ? $BUFFER : $MONO; open my $RO_FH, '<:raw', $mod or croak "Can not open file($mod): $!"; MONO_MERGE: while ( defined( my $line = readline $RO_FH ) ) { chomp( my $chomped = $line ); $is_eof++ if $chomped eq '1;'; last MONO_MERGE if $is_eof && $base ne $mono_file; if ( $is_eof ) { warn "\tADD POD FROM $mod\n" if ! $add_pod{ $mod }++; $pod .= $line; next; } print { $TARGET } $line or croak "Unable to print to FH: $!"; } close $RO_FH or croak "Unable to close FH: $!"; } close $MONO or croak "Unable to close FH: $!"; close $BUFFER or croak "Unable to close FH: $!"; return $pod; } sub _monolith_prove { my($self) = @_; warn "\tTESTING MONOLITH\n"; local $ENV{AUTHOR_TESTING_MONOLITH_BUILD} = 1; require File::Basename; require File::Spec; my $pbase = File::Basename::dirname( $^X ); my $prove; find { wanted => sub { my $file = $_; return if $file !~ m{ prove }xms; $prove = $file; }, no_chdir => 1, }, $pbase; if ( ! $prove || ! -e $prove ) { croak "No `prove command found related to $^X`"; } if ( ! -x $prove ) { croak "Found prove at `$prove` but it is not executable!"; } warn "\n\tFOUND `prove` at $prove\n\n"; require IPC::Open3; my $prove_pid = IPC::Open3::open3( my($prove_in, $prove_out, $prove_err), $prove, '-I', File::Spec->catdir( CURRENT_DIR, 'lib' ), '-r', ( map { File::Spec->catdir( CURRENT_DIR, $_) } qw( t xt ) ) ); my $prove_status; while ( defined( my $result = <$prove_out> ) ) { chomp $result; $prove_status = $result; print "\t$result\n" or croak "Unable to print to STDOUT: $!"; } waitpid( $prove_pid, 0 ); my $prove_failed = $? >> 8; if ( $prove_failed || $prove_status ne 'Result: PASS' ) { croak MONOLITH_TEST_FAIL; } return; } sub _monolith_add_pre { my($self, $mono, $copy, $files, $buffer) = @_; require File::Copy; File::Copy::copy( $mono, $copy ) or croak "Copy failed: $!"; my $clean_file = sub { my $f = shift; $f =~ s{ \\ }{/}xmsg; $f =~ s{ \A lib/ }{}xms; return $f; }; my $clean_module = sub { my $m = shift; $m =~ s{ [.]pm \z }{}xms; $m =~ s{ / }{::}xmsg; return $m; }; my @inc_files = map { $clean_file->( $_ ) } @{ $files }; my @packages = map { $clean_module->( $_ ) } @inc_files; open my $W, '>:raw', $mono or croak "Can not open file($mono): $!"; printf {$W} q/BEGIN { $INC{$_} = 1 for qw(%s); }/, join q{ }, @inc_files or croak "Can not print to MONO file: $!"; print {$W} "\n" or croak "Can not print to MONO file: $!"; foreach my $name ( @packages ) { print {$W} qq/package $name;\nsub ________monolith {}\n/ or croak "Can not print to MONO file: $!"; } open my $TOP, '<:raw', $buffer or croak "Can not open file($buffer): $!"; while ( defined( my $line = <$TOP> ) ) { print {$W} $line or croak "Can not print to BUFFER file: $!"; } close $TOP or croak 'Can not close BUFFER file'; open my $COPY, '<:raw', $copy or croak "Can not open file($copy): $!"; while ( defined( my $line = <$COPY> ) ) { print {$W} $line or croak "Can not print to COPY file: $!"; } close $COPY or croak "Can't close COPY file: $!"; close $W or croak "Can't close MONO file: $!"; return; } sub _write_file { my($self, $mode, $file, @data) = @_; $mode = $mode . ':raw'; open my $FH, $mode, $file or croak "Can not open file($file): $!"; print {$FH} @data or croak "Can not print to FH: $!"; close $FH or croak "Can not close $file $!"; return; } sub _monolith_add_to_top { my $self = shift; my $base = shift; my $list = $self->monolith_add_to_top || croak 'monolith_add_to_top not set'; croak 'monolith_add_to_top is not an ARRAY' if ref $list ne 'ARRAY'; return grep { $_ eq $base } @{ $list }; } sub _monolith_readme { my $self = shift; (my $pod = $self->_monolith_pod_warning) =~ s{B<(.+?)>}{$1}xmsg; return $pod; } sub _monolith_pod_warning { my $self = shift; return $self->_compile_template( 'pod/monolith-warning.pod' => { module => $self->module_name, }, ); } sub _automatic_build_file_header { return shift->_compile_template( 'tools/builder.header' ); } sub _add_automatic_build_pl { my $self = shift; my $file = 'Build.PL'; return if -e $file; # do not overwrite $self->_write_file( '>', $file => $self->_automatic_build_pl ); $self->_write_file( '>>', MANIFEST => "$file\tGenerated automatically\n"); warn "ADDED AUTOMATIC $file\n"; return; } sub _automatic_build_pl { my $self = shift; my %spec = Build::Spec::spec( builder => 1 ); my $build = delete $spec{BUILDER} || croak 'SPEC does not have a BUILDER key'; my $methods = join ";\n", map { sprintf q{$mb->%s( %s )}, $_, $build->{ $_ } } keys %{ $build }; return join q{}, $self->_automatic_build_file_header, $self->_compile_template( 'tools/Build.PL' => { methods => $methods, }, ), ; } sub _add_vanilla_makefile_pl { my $self = shift; my $file = 'Makefile.PL'; return if -e $file; # don't overwrite $self->_write_file( '>', $file => $self->_vanilla_makefile_pl ); $self->_write_file( '>>', MANIFEST => "$file\tGenerated automatically\n"); warn "ADDED VANILLA $file\n"; return; } sub _vanilla_makefile_pl { my $self = shift; my $hook = $self->initialization_hook; if ( $hook ) { $hook = $self->_compile_template( 'tools/Makefile.PL.hook' => { hook => $hook, }, ), } return join q{}, $self->_automatic_build_file_header, $self->_compile_template( 'tools/Makefile.PL' => { hook => $hook || q{}, }, ), ; } sub _pod_author_copyright_license { my $self = shift; my $da = $self->dist_author; # support only 1 author for now my $cfy = $self->copyright_first_year; my $year = (localtime time)[YEAR_SLOT] + YEAR_ADD; my($author, $email) = $da->[0] =~ m{ (.+?) < (.+?) > }xms; $author = trim( $author ) if $author; $email = trim( $email ) if $email; $year = "$cfy - $year" if $cfy && $cfy != $year && $cfy < $year; return $self->_compile_template( 'pod/author.pod' => { author => $author, email => $email, year => $year, perl => sprintf( '%vd', $^V ), }, ); } sub _compile_template { my($self, $path, $param) = @_; my $full_path = File::Spec->catfile( qw( builder templates ), $path ); die "Can't locate template $path: $!" if ! -e $full_path; $param ||= {}; my $raw = slurp( $full_path ); my %p = map { uc( $_ ) => $param->{ $_ } } keys %{ $param }; my %seen; my $key_value = sub { my $match = shift; my $key = trim( $match ); my $value = $p{ $key }; if ( ! defined $value ) { if ( ! $seen{ $key }++ ) { warn "$path: Bogus or no value for template key '$key'"; } return q(); } return $value; }; $raw =~ s{[[][%](.+?)[%][]]}{$key_value->($1)}xmsge; return $raw; } 1; __END__ Sys-Info-Base-0.7804/builder/lib/Build000755000765000024 012457601220 16755 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/builder/lib/Build/Constants.pm000444000765000024 220212457601220 21420 0ustar00burakstaff000000000000package Build::Constants; use strict; use warnings; our $VERSION = '0.80'; use base qw( Exporter ); use constant TAINT_SHEBANG => "#!perl -Tw\nuse constant TAINTMODE => 1;\n"; use constant RE_VERSION_LINE => qr{ \A (our\s+)? \$VERSION \s+ = \s+ ["'] (.+?) ['"] ; (.+?) \z }xms; use constant RE_POD_LINE => qr{ \A =head1 \s+ DESCRIPTION \s+ \z }xms; use constant VTEMP => q{%s$VERSION = '%s';}; use constant MONTHS => qw( January February March April May June July August September October November December ); use constant MONOLITH_TEST_FAIL => "\nFAILED! Building the monolithic version failed during unit testing\n\n"; use constant NO_INDEX => qw( monolithic_version builder t xt ); use constant DEFAULTS => qw( license perl create_license 1 sign 0 ); use constant YEAR_ADD => 1900; use constant YEAR_SLOT => 5; our @EXPORT_OK = qw( TAINT_SHEBANG RE_VERSION_LINE RE_POD_LINE VTEMP MONTHS MONOLITH_TEST_FAIL NO_INDEX DEFAULTS YEAR_ADD YEAR_SLOT ); our %EXPORT_TAGS = ( all => \@EXPORT_OK, ); 1; __END__ Sys-Info-Base-0.7804/builder/lib/Build/Spec.pm000444000765000024 533012457601220 20343 0ustar00burakstaff000000000000package Build::Spec; use strict; use warnings; use Exporter (); use Carp qw( croak ); use constant DEFAULT_AUTHOR => 'Burak Gursoy '; use constant OS_ERROR => qr{OS \s+ unsupported}xms; use base qw( Exporter ); BEGIN { our $VERSION = '0.80'; our @EXPORT = qw( spec ); our @EXPORT_OK = qw( mm_spec ); } sub spec { my %opt = @_; my $file = 'SPEC'; my $spec = do $file; my %rv = $@ ? do { croak $@ =~ OS_ERROR ? $@ : "Couldn't parse $file: $@" } : ! defined $spec && $! ? croak "Couldn't do $file: $!" : ! $spec ? croak "$file did not return a true value" : ref($spec) ne 'HASH' ? croak "Return type of $file is not HASH" : ! $spec->{module_name} ? croak "The specification returned from $file does" .q{ not have the mandatory 'module_name' key} : %{ $spec }; ; # these needs to be set here $rv{dist_author} ||= DEFAULT_AUTHOR; $rv{recommends} ||= {}; $rv{requires} ||= {}; my $breq = $rv{build_requires} ||= {}; $breq->{'Test::More'} = '0.40' if ! exists $breq->{'Test::More'}; delete $rv{BUILDER} if ! $opt{builder}; return %rv; } sub trim { my $s = shift; return $s if ! $s; $s =~ s{ \A \s+ }{}xms; $s =~ s{ \s+ \z }{}xms; return $s; } # Makefile.PL related things sub mm_spec { my %spec = spec(); (my $file = $spec{module_name}) =~ s{::}{/}xmsg; $spec{VERSION_FROM} = "lib/$file.pm"; $spec{PREREQ_PM} = { %{ $spec{requires} }, %{ $spec{build_requires} } }; _mm_recommend( %spec ); $spec{ABSTRACT} = _mm_abstract( $spec{VERSION_FROM} ); $spec{EXE_FILES} = $spec{script_files} ? $spec{script_files} : []; return %spec; } sub _mm_recommend { my %spec = @_; return if ! $spec{recommends}; my %rec = %{ $spec{recommends} } or return; my $info = "\nRecommended Modules:\n\n"; foreach my $m ( sort keys %rec ) { $info .= sprintf "\t%s\tv%s\n", $m, $rec{$m}; } my $pok = print "$info\n"; return; } sub _mm_abstract { my $file = shift; require IO::File; my $fh = IO::File->new; $fh->open( $file, 'r' ) || croak "Can not read $file: $!"; binmode $fh; while ( my $line = <$fh> ) { chomp $line; last if $line eq '=head1 NAME'; } my $buf; while ( my $line = <$fh> ) { chomp $line; last if $line =~ m{ \A =head }xms; $buf .= $line; } $fh->close || croak "Can not close $file: $!"; croak 'Unable to get ABSTRACT' if ! $buf; $buf = trim( $buf ); my($mod, $desc) = split m{\-}xms, $buf, 2; $desc = trim( $desc ) || croak 'Unable to get ABSTRACT'; return $desc; } 1; __END__ Sys-Info-Base-0.7804/builder/lib/Build/Util.pm000444000765000024 127112457601220 20366 0ustar00burakstaff000000000000package Build::Util; use strict; use warnings; use base qw( Exporter ); use Carp (); our $VERSION = '0.80'; our @EXPORT_OK = qw( slurp trim ); sub slurp { my $path = shift || Carp::croak( 'No file path specified' ); if ( ! -e $path ) { Carp::croak( "The specified file path $path does not exist" ); } open my $FH, '<', $path or Carp::croak( "Can not open file($path): $!" ); my $rv = do { local $/; <$FH> }; close $FH or Carp::croak( "Can't close($path): $!" ); return $rv; } sub trim { my($s, $extra) = @_; return $s if ! $s; $extra ||= q{}; $s =~ s{\A \s+ }{$extra}xms; $s =~ s{ \s+ \z}{$extra}xms; return $s; } 1; __END__ Sys-Info-Base-0.7804/builder/templates000755000765000024 012457601220 17146 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/builder/templates/pod000755000765000024 012457601220 17730 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/builder/templates/pod/author.pod000444000765000024 52112457601220 22051 0ustar00burakstaff000000000000=head1 AUTHOR [%AUTHOR%] <[%EMAIL%]>. =head1 COPYRIGHT Copyright [%YEAR%] [%AUTHOR%]. All rights reserved. =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version [%PERL%] or, at your option, any later version of Perl 5 you may have available. Sys-Info-Base-0.7804/builder/templates/pod/monolith-warning.pod000444000765000024 35112457601220 24044 0ustar00burakstaff000000000000 B! This is the monolithic version of [%MODULE%] generated with an automatic build tool. If you experience problems with this version, please install and use the supported standard version. This version is B. Sys-Info-Base-0.7804/builder/templates/tools000755000765000024 012457601220 20306 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/builder/templates/tools/Build.PL000444000765000024 11512457601220 21714 0ustar00burakstaff000000000000use Build; my $mb = Build->new; [%METHODS%]; $mb->create_build_script; 1; Sys-Info-Base-0.7804/builder/templates/tools/builder.header000444000765000024 17212457601220 23223 0ustar00burakstaff000000000000#!/usr/bin/env perl # This file was created automatically use 5.006; use strict; use warnings; use lib qw( builder/lib ); Sys-Info-Base-0.7804/builder/templates/tools/Makefile.PL000444000765000024 61612457601220 22400 0ustar00burakstaff000000000000use Build::Spec qw( mm_spec ); use ExtUtils::MakeMaker; my %spec = mm_spec; [%HOOK%] WriteMakefile( NAME => $spec{module_name}, VERSION_FROM => $spec{VERSION_FROM}, PREREQ_PM => $spec{PREREQ_PM}, PL_FILES => {}, ($] >= 5.005 ? ( AUTHOR => $spec{dist_author}, ABSTRACT => $spec{ABSTRACT}, EXE_FILES => $spec{EXE_FILES}, ) : ()), ); Sys-Info-Base-0.7804/builder/templates/tools/Makefile.PL.hook000444000765000024 20512457601220 23331 0ustar00burakstaff000000000000my $eok = eval <<'THIS_IS_SOME_IDENTIFIER'; [%HOOK%] THIS_IS_SOME_IDENTIFIER die "Error compiling initialization_hook: $@\n" if $@; Sys-Info-Base-0.7804/lib000755000765000024 012457601220 14270 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/lib/Sys000755000765000024 012457601220 15046 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/lib/Sys/Info000755000765000024 012457601220 15741 5ustar00burakstaff000000000000Sys-Info-Base-0.7804/lib/Sys/Info/Base.pm000444000765000024 1206312457601220 17330 0ustar00burakstaff000000000000package Sys::Info::Base; use strict; use warnings; use vars qw( $VERSION ); 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; $VERSION = '0.7804'; 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__ =head1 NAME Sys::Info::Base - Base class for Sys::Info =head1 SYNOPSIS use base qw(Sys::Info::Base); #... sub foo { my $self = shift; my $data = $self->slurp("/foo/bar.txt"); } =head1 DESCRIPTION This document describes version C<0.7804> of C released on C<21 January 2015>. Includes some common methods. =head1 METHODS =head2 load_module CLASS Loads the module named with C. =head2 load_subclass TEMPLATE Loads the specified class via C