MooX-File-ConfigDir-0.005/000755 000765 000024 00000000000 12475622060 015065 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/calc/000755 000765 000024 00000000000 12475622060 015767 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/Changes000644 000765 000024 00000001702 12475616333 016366 0ustar00snostaff000000 000000 Revision history for Perl module MooX::File::ConfigDir 0.005 2015-03-04 - bump copyright year to 2015 - simplify construction - increase test coverage - splash out for attribute clearer ;) - update meta-data and older eumm-support 0.004 2014-11-25 - improve Makefile.PL for better distribution kwalitee - add README.md 0.003 2014-01-06 - move from Build.PL to Makefile.PL because of development dependencies - change dependency from namespace::autoclean to namespace::clean (Fixes PR#91890) - prefer BAIL_OUT over printf in loading test - update copyright period 0.002 2013-09-26 - improve initialization support (builder for config_identifier) - improve builders for the config dir attributes to call them from within BUILDARGS - fix singleapp_cfg_dir builder (using it with config_identifier is tautologous) 0.001 2013-09-21 - First version, released on an unsuspecting world. MooX-File-ConfigDir-0.005/etc/000755 000765 000024 00000000000 12475622060 015640 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/lib/000755 000765 000024 00000000000 12475622060 015633 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/Makefile.PL000644 000765 000024 00000010762 12475616221 017047 0ustar00snostaff000000 000000 use strict; use warnings; use 5.008001; use ExtUtils::MakeMaker; my %RUN_DEPS = ( 'namespace::clean' => 0, 'Moo::Role' => '1.003000', 'File::ConfigDir' => '0.011', ); my %CONFIGURE_DEPS = ( 'ExtUtils::MakeMaker' => 0, ); my %BUILD_DEPS = (); my %TEST_DEPS = ( 'Test::More' => 0.90, ); WriteMakefile1( MIN_PERL_VERSION => '5.008001', META_ADD => { 'meta-spec' => { version => 2 }, resources => { homepage => 'https://metacpan.org/release/MooX-File-ConfigDir', repository => { url => 'https://github.com:perl5-utils/MooX-File-ConfigDir.git', web => 'https://github.com/perl5-utils/MooX-File-ConfigDir', type => 'git', }, bugtracker => { web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=MooX-File-ConfigDir', mailto => 'bug-MooX-File-ConfigDir@rt.cpan.org', }, license => 'http://dev.perl.org/licenses/', }, prereqs => { develop => { requires => { 'Test::CPAN::Changes' => 0, 'Test::CheckManifest' => 0, 'Module::CPANTS::Analyse' => '0.96', 'Test::Kwalitee' => 0, 'Test::Pod' => 0, 'Test::Pod::Coverage' => 0, 'Test::Pod::Spelling::CommonMistakes' => 0, 'Test::Spelling' => 0, }, }, configure => { requires => {%CONFIGURE_DEPS}, }, build => { requires => {%BUILD_DEPS} }, test => { requires => {%TEST_DEPS} }, runtime => { requires => { %RUN_DEPS, perl => '5.8.1', }, }, }, }, NAME => 'MooX::File::ConfigDir', VERSION_FROM => 'lib/MooX/File/ConfigDir.pm', ABSTRACT_FROM => 'lib/MooX/File/ConfigDir.pm', LICENSE => 'perl', AUTHOR => q{Jens Rehsack }, PREREQ_PM => \%RUN_DEPS, CONFIGURE_REQUIRES => \%CONFIGURE_DEPS, BUILD_REQUIRES => \%BUILD_DEPS, TEST_REQUIRES => \%TEST_DEPS, test => { TESTS => 't/*.t xt/*.t' }, ); sub WriteMakefile1 { # originally written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade. my %params = @_; my $eumm_version = $ExtUtils::MakeMaker::VERSION; $eumm_version = eval $eumm_version; die "EXTRA_META is deprecated" if ( exists( $params{EXTRA_META} ) ); die "License not specified" if ( !exists( $params{LICENSE} ) ); $params{TEST_REQUIRES} and $eumm_version < 6.6303 and $params{BUILD_REQUIRES} = { %{ $params{BUILD_REQUIRES} || {} }, %{ delete $params{TEST_REQUIRES} } }; #EUMM 6.5502 has problems with BUILD_REQUIRES $params{BUILD_REQUIRES} and $eumm_version < 6.5503 and $params{PREREQ_PM} = { %{ $params{PREREQ_PM} || {} }, %{ delete $params{BUILD_REQUIRES} } }; ref $params{AUTHOR} and "ARRAY" eq ref $params{AUTHOR} and $eumm_version < 6.5702 and $params{AUTHOR} = join( ", ", @{ $params{AUTHOR} } ); delete $params{CONFIGURE_REQUIRES} if ( $eumm_version < 6.52 ); delete $params{MIN_PERL_VERSION} if ( $eumm_version < 6.48 ); delete $params{META_MERGE} if ( $eumm_version < 6.46 ); delete $params{META_ADD}{prereqs} if ( $eumm_version < 6.58 ); delete $params{META_ADD}{'meta-spec'} if ( $eumm_version < 6.58 ); delete $params{META_ADD} if ( $eumm_version < 6.46 ); delete $params{LICENSE} if ( $eumm_version < 6.31 ); delete $params{AUTHOR} if ( $] < 5.005 ); delete $params{ABSTRACT_FROM} if ( $] < 5.005 ); delete $params{BINARY_LOCATION} if ( $] < 5.005 ); # more or less taken from Moose' Makefile.PL if ( $params{CONFLICTS} ) { my $ok = CheckConflicts(%params); exit(0) if ( $params{PREREQ_FATAL} and not $ok ); my $cpan_smoker = grep { $_ =~ m/(?:CR_SMOKER|CPAN_REPORTER|AUTOMATED_TESTING)/ } keys %ENV; unless ( $cpan_smoker || $ENV{PERL_MM_USE_DEFAULT} ) { sleep 4 unless ($ok); } delete $params{CONFLICTS}; } WriteMakefile(%params); } MooX-File-ConfigDir-0.005/MANIFEST000644 000765 000024 00000000332 12475607047 016224 0ustar00snostaff000000 000000 calc/etc/operands.json Changes etc/calc-operands.json lib/MooX/File/ConfigDir.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP META.json META.yml README.md t/00-load.t t/01-simple.t t/02-build.t t/03-mxcff.t MooX-File-ConfigDir-0.005/MANIFEST.SKIP000644 000765 000024 00000000506 12475602753 016773 0ustar00snostaff000000 000000 \B\.svn\b \B\.git\b \.gitignore$ \.[Bb][Aa][Kk]$ \.orig$ \.old$ \.tdy$ \.tmp$ \..*swp ^Makefile$ ^Build$ ^Build\.bat$ \.Inline/.* _Inline/.* \.bak$ \.tar$ \.tgz$ \.tar\.gz$ ^mess/ ^tmp/ ^testdata/ ^blib/ ^sandbox/ ^pm_to_blib$ ^cover_db/ ^_build/.* ~$ .*\.planner ^\..* MooX-File-ConfigDir-.* \bxt ^MYMETA\.json$ ^MYMETA\..*$ MooX-File-ConfigDir-0.005/META.json000644 000765 000024 00000003704 12475622060 016512 0ustar00snostaff000000 000000 { "abstract" : "Moo eXtension for File::ConfigDir", "author" : [ "Jens Rehsack " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "MooX-File-ConfigDir", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Module::CPANTS::Analyse" : "0.96", "Test::CPAN::Changes" : "0", "Test::CheckManifest" : "0", "Test::Kwalitee" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "Test::Pod::Spelling::CommonMistakes" : "0", "Test::Spelling" : "0" } }, "runtime" : { "requires" : { "File::ConfigDir" : "0.011", "Moo::Role" : "1.003000", "namespace::clean" : "0", "perl" : "v5.8.1" } }, "test" : { "requires" : { "Test::More" : "0.9" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-MooX-File-ConfigDir@rt.cpan.org", "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=MooX-File-ConfigDir" }, "homepage" : "https://metacpan.org/release/MooX-File-ConfigDir", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "https://github.com:perl5-utils/MooX-File-ConfigDir.git", "web" : "https://github.com/perl5-utils/MooX-File-ConfigDir" } }, "version" : "0.005" } MooX-File-ConfigDir-0.005/META.yml000644 000765 000024 00000001510 12475622060 016333 0ustar00snostaff000000 000000 --- abstract: 'Moo eXtension for File::ConfigDir' author: - 'Jens Rehsack ' build_requires: Test::More: '0.9' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MooX-File-ConfigDir no_index: directory: - t - inc requires: File::ConfigDir: '0.011' Moo::Role: '1.003000' namespace::clean: '0' perl: v5.8.1 resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=MooX-File-ConfigDir homepage: https://metacpan.org/release/MooX-File-ConfigDir license: http://dev.perl.org/licenses/ repository: https://github.com:perl5-utils/MooX-File-ConfigDir.git version: '0.005' MooX-File-ConfigDir-0.005/README.md000644 000765 000024 00000002254 12435065236 016351 0ustar00snostaff000000 000000 ## Name MooX::File::ConfigDir ## Description This module is a helper for easily find configuration file locations. Whether to use this information for find a suitable place for installing them or looking around for finding any piece of settings, heavily depends on the requirements. ## Build/Installation cpan MooX::File::ConfigDir ## Copyright/License Copyright (C) 2013-2014 Jens Rehsack This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See for more information. ## Documentation/Support After installing, you can find documentation for this module with the perldoc command. perldoc MooX::File::ConfigDir You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooX-File-ConfigDir AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/MooX-File-ConfigDir CPAN Ratings http://cpanratings.perl.org/d/MooX-File-ConfigDir Search CPAN http://search.cpan.org/dist/MooX-File-ConfigDir/ MooX-File-ConfigDir-0.005/t/000755 000765 000024 00000000000 12475622060 015330 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/t/00-load.t000644 000765 000024 00000000414 12475605775 016666 0ustar00snostaff000000 000000 #!perl -T use strict; use warnings FATAL => "all"; use Test::More tests => 1; BEGIN { use_ok( 'MooX::File::ConfigDir' ) || BAIL_OUT "Couldn't load MooX::File::ConfigDir"; } diag( "Testing MooX::File::ConfigDir $MooX::File::ConfigDir::VERSION, Perl $], $^X" ); MooX-File-ConfigDir-0.005/t/01-simple.t000644 000765 000024 00000002521 12475605775 017242 0ustar00snostaff000000 000000 #!perl use strict; use warnings FATAL => "all"; eval { require local::lib; #local::lib->import(); }; package # My; use Moo; with "MooX::File::ConfigDir"; 1; package # main; use Test::More; my @supported_functions = ( qw(config_dirs system_cfg_dir desktop_cfg_dir), qw(core_cfg_dir site_cfg_dir vendor_cfg_dir), qw(local_cfg_dir here_cfg_dir singleapp_cfg_dir), qw(xdg_config_dirs xdg_config_home user_cfg_dir), ); my $mxfcd = My->new(); foreach my $fn (@supported_functions) { my @dirs = @{ $mxfcd->$fn }; note( "$fn: " . join( ",", @dirs ) ); if ( $fn =~ m/(?:xdg_)?config_dirs/ or $fn =~ m/(?:machine|desktop)_cfg_dir/ ) { ok( scalar @dirs >= 1, "config_dirs" ) or diag( join( ",", @dirs ) ); # we expect at least system_cfg_dir } elsif ( $fn =~ m/(?:local|user)_cfg_dir/ || $fn eq "xdg_config_home" ) { ok( scalar @dirs <= 1, $fn ) or diag( join( ",", @dirs ) ); # probably we do not have local::lib or File::HomeDir } elsif( $^O eq "MSWin32" and $fn eq "local_cfg_dir" ) { ok( scalar @dirs == 0, $fn ) or diag( join( ",", @dirs ) ); } else { ok( scalar @dirs == 1, $fn ) or diag( join( ",", @dirs ) ); } } done_testing(); MooX-File-ConfigDir-0.005/t/02-build.t000644 000765 000024 00000003033 12475613314 017034 0ustar00snostaff000000 000000 #!perl use strict; use warnings FATAL => "all"; eval { require local::lib; #local::lib->import(); }; use FindBin qw/$Script/; { package # My; use Moo; with "MooX::File::ConfigDir"; } { package # Mine; use Moo; sub _build_config_identifier { $FindBin::Script } with "MooX::File::ConfigDir"; } { package # Fail; use Moo; with "MooX::File::ConfigDir"; around BUILDARGS => sub { my $next = shift; my $class = shift; $class->$next( @_, config_dirs => $class->_build_config_dirs, ); }; } use Test::More; my $mxfcd_ = My->new(config_identifier => $FindBin::Script); my $_mxfcd = Mine->new(); my @supported_functions = ( qw(system_cfg_dir desktop_cfg_dir), qw(core_cfg_dir site_cfg_dir vendor_cfg_dir), qw(local_cfg_dir here_cfg_dir singleapp_cfg_dir), qw(xdg_config_dirs xdg_config_home user_cfg_dir), ); my $diag = Test::More->can('diag'); my $note = Test::More->can('note'); foreach my $fn (@supported_functions) { my $dirs_ = $mxfcd_->$fn; my $_dirs = $_mxfcd->$fn; my $report = is_deeply( $dirs_, $_dirs, "$fn" ) ? $note : $diag; $report->( "$fn", explain($dirs_), explain($_dirs) ); } eval { my $fail = Fail->new; }; # either $self or $params must be valid my $err = $@; like( $err, qr/either \$self or \$params must be valid/, "Load fails expectedly" ); done_testing(); MooX-File-ConfigDir-0.005/t/03-mxcff.t000644 000765 000024 00000004056 12475611557 017056 0ustar00snostaff000000 000000 #!perl use strict; use warnings FATAL => "all"; use Test::More; my $moodel; BEGIN { $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; eval "use MooX::ConfigFromFile 0.006;"; $@ and plan skip_all => "Need MooX::ConfigFromFile 0.006 -- $@"; } eval sprintf( <<'EOCDECL', ($moodel) x 3 ); { package # Calc::Role::BinaryOperation; use %s::Role; has a => ( is => "ro", required => 1, ); has b => ( is => "ro", required => 1, ); } { package # Calc::add; use %s; use MooX::ConfigFromFile config_prefix => "calc-operands"; with "Calc::Role::BinaryOperation"; sub execute { my $self = shift; return $self->a + $self->b; } } { package # Calc::sub; use %s; use MooX::ConfigFromFile config_prefix => "operands", config_identifier => "calc"; with "Calc::Role::BinaryOperation"; sub execute { my $self = shift; return $self->a - $self->b; } } EOCDECL my $adder = Calc::add->new; ok( defined( $adder->a ), "read \"a\" from add config" ); ok( defined( $adder->b ), "read \"b\" from add config" ); cmp_ok( $adder->execute, "==", 5, "read right adder config" ); my $adderly = Calc::add->new(config_prefix => "operands", config_identifier => "calc"); ok( defined( $adderly->a ), "read \"a\" from adderly config" ); ok( defined( $adderly->b ), "read \"b\" from adderly config" ); cmp_ok( $adderly->execute, "==", 25, "read right adderly config" ); my $subber = Calc::sub->new; ok( defined( $subber->a ), "read \"a\" from sub config" ); ok( defined( $subber->b ), "read \"b\" from sub config" ); cmp_ok( $subber->execute, "==", 17, "read right subber config" ); my $subberly = Calc::sub->new(config_identifier => undef, config_prefix => "calc-operands"); ok( defined( $subberly->a ), "read \"a\" from subberly config" ); ok( defined( $subberly->b ), "read \"b\" from subberly config" ); cmp_ok( $subberly->execute, "==", -1, "read right subberly config" ); done_testing(); MooX-File-ConfigDir-0.005/lib/MooX/000755 000765 000024 00000000000 12475622060 016515 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/lib/MooX/File/000755 000765 000024 00000000000 12475622060 017374 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/lib/MooX/File/ConfigDir.pm000644 000765 000024 00000013473 12475621765 021621 0ustar00snostaff000000 000000 package MooX::File::ConfigDir; use strict; use warnings; our $VERSION = "0.005"; use Carp qw/croak/; use Scalar::Util qw(blessed); use File::ConfigDir (); use namespace::clean; use Moo::Role; has 'config_identifier' => ( is => 'lazy', ); sub _build_config_identifier { } sub _fetch_file_config_dir { my ( $self, $attr, $params ) = @_; croak "either \$self or \$params must be valid" unless blessed $self or "HASH" eq ref $params; my $app_name = blessed($self) ? $self->config_identifier : defined $params->{config_identifier} ? $params->{config_identifier} : $self->_build_config_identifier($params); my @app_names = $app_name ? ($app_name) : (); my $sub = File::ConfigDir->can($attr); my @dirs = &{$sub}(@app_names); return \@dirs; } has singleapp_cfg_dir => ( is => 'ro', lazy => 1, clearer => 1, builder => sub { [File::ConfigDir::singleapp_cfg_dir] }, ); my @file_config_dir_attrs = ( qw(system_cfg_dir xdg_config_dirs desktop_cfg_dir), qw(core_cfg_dir site_cfg_dir vendor_cfg_dir ), qw(local_cfg_dir locallib_cfg_dir here_cfg_dir user_cfg_dir), qw(xdg_config_home config_dirs) ); foreach my $attr (@file_config_dir_attrs) { has $attr => ( is => 'ro', lazy => 1, clearer => 1, builder => sub { my $self = shift; $self->_fetch_file_config_dir( $attr, @_ ) }, ); } =head1 NAME MooX::File::ConfigDir - Moo eXtension for File::ConfigDir =head1 SYNOPSIS my App; use Moo; with MooX::File::ConfigDir; 1; package main; my $app = App->new(); $app->config_identifier('MyProject'); my @cfgdirs = @{ $app->config_dirs }; # install support my $site_cfg_dir = $app->site_cfg_dir->[0]; my $vendor_cfg_dir = $app->site_cfg_dir->[0]; =head1 DESCRIPTION This module is a helper for easily find configuration file locations. Whether to use this information for find a suitable place for installing them or looking around for finding any piece of settings, heavily depends on the requirements. =head1 ATTRIBUTES =head2 config_identifier Allows to deal with a global unique identifier passed to the functions of L. Using it encapsulates configuration files from the other ones (eg. C vs. C). C can be initialized by specifying it as parameter during object construction or via inheriting default builder (C<_build_config_identifier>). =head2 system_cfg_dir Provides the configuration directory where configuration files of the operating system resides. For details see L. =head2 desktop_cfg_dir Provides the configuration directory where configuration files of the desktop applications resides. For details see L. =head2 xdg_config_dirs Alias for desktop_cfg_dir to support L =head2 core_cfg_dir Provides the configuration directory of the Perl5 core location. For details see L. =head2 site_cfg_dir Provides the configuration directory of the Perl5 sitelib location. For details see L. =head2 vendor_cfg_dir Provides the configuration directory of the Perl5 vendorlib location. For details see L. =head2 singleapp_cfg_dir Provides the configuration directory of C<$0> if it's installed as a separate package - either a program bundle (TSM, Oracle DB) or an independent package combination (eg. via L For details see L. =head2 local_cfg_dir Returns the configuration directory for distribution independent, 3rd party applications. For details see L. =head2 locallib_cfg_dir Provides the configuration directory of the Perl5 L environment location. For details see L. =head2 here_cfg_dir Provides the path for the C directory below the current working directory. For details see L. =head2 user_cfg_dir Provides the users home folder using L. For details see L. =head2 xdg_config_home Returns the user configuration directory for desktop applications. For details see L. =head2 config_dirs Tries to get all available configuration directories as described above. Returns those who exists and are readable. For details see L. =head1 AUTHOR Jens Rehsack, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc MooX::File::ConfigDir You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 LICENSE AND COPYRIGHT Copyright 2013-2015 Jens Rehsack. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut 1; MooX-File-ConfigDir-0.005/etc/calc-operands.json000644 000765 000024 00000000035 12221023560 021231 0ustar00snostaff000000 000000 { "a" : 2, "b" : 3 } MooX-File-ConfigDir-0.005/calc/etc/000755 000765 000024 00000000000 12475622060 016542 5ustar00snostaff000000 000000 MooX-File-ConfigDir-0.005/calc/etc/operands.json000644 000765 000024 00000000036 12475551574 021262 0ustar00snostaff000000 000000 { "a" : 21, "b" : 4 }