MooX-File-ConfigDir

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


`config_identifier` can be initialized by specifying it as parameter
during object construction or via inheriting default builder
(`_build_config_identifier`).

## system\_cfg\_dir

Provides the configuration directory where configuration files of the
operating system resides. For details see ["system\_cfg\_dir" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#system_cfg_dir).

## desktop\_cfg\_dir

Provides the configuration directory where configuration files of the
desktop applications resides. For details see ["desktop\_cfg\_dir" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#desktop_cfg_dir).

## xdg\_config\_dirs

Alias for desktop\_cfg\_dir to support
[XDG Base Directory Specification](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)

## core\_cfg\_dir

Provides the configuration directory of the Perl5 core location.
For details see ["core\_cfg\_dir" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#core_cfg_dir).

## site\_cfg\_dir

Provides the configuration directory of the Perl5 sitelib location.
For details see ["site\_cfg\_dir" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#site_cfg_dir).

README.md  view on Meta::CPAN

Provides the path for the `etc` directory below the current working directory.
For details see ["here\_cfg\_dir" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#here_cfg_dir).

## user\_cfg\_dir

Provides the users home folder using [File::HomeDir](https://metacpan.org/pod/File::HomeDir).
For details see ["user\_cfg\_dir" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#user_cfg_dir).

## xdg\_config\_home

Returns the user configuration directory for desktop applications.
For details see ["xdg\_config\_home" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#xdg_config_home).

## config\_dirs

Tries to get all available configuration directories as described above.
Returns those who exists and are readable.
For details see ["config\_dirs" in File::ConfigDir](https://metacpan.org/pod/File::ConfigDir#config_dirs).

# AUTHOR

lib/MooX/File/ConfigDir.pm  view on Meta::CPAN

}

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 vendorapp_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,

lib/MooX/File/ConfigDir.pm  view on Meta::CPAN


C<config_identifier> 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<File::ConfigDir/system_cfg_dir>.

=head2 desktop_cfg_dir

Provides the configuration directory where configuration files of the
desktop applications resides. For details see L<File::ConfigDir/desktop_cfg_dir>.

=head2 xdg_config_dirs

Alias for desktop_cfg_dir to support
L<XDG Base Directory Specification|http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>

=head2 core_cfg_dir

Provides the configuration directory of the Perl5 core location.
For details see L<File::ConfigDir/core_cfg_dir>.

=head2 site_cfg_dir

Provides the configuration directory of the Perl5 sitelib location.
For details see L<File::ConfigDir/site_cfg_dir>.

lib/MooX/File/ConfigDir.pm  view on Meta::CPAN

Provides the path for the C<etc> directory below the current working directory.
For details see L<File::ConfigDir/here_cfg_dir>.

=head2 user_cfg_dir

Provides the users home folder using L<File::HomeDir>.
For details see L<File::ConfigDir/user_cfg_dir>.

=head2 xdg_config_home

Returns the user configuration directory for desktop applications.
For details see L<File::ConfigDir/xdg_config_home>.

=head2 config_dirs

Tries to get all available configuration directories as described above.
Returns those who exists and are readable.
For details see L<File::ConfigDir/config_dirs>.

=head1 AUTHOR

t/01-simple.t  view on Meta::CPAN

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 vendorapp_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));

t/02-build.t  view on Meta::CPAN

        );
    };
}

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 vendorapp_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)
{



( run in 0.332 second using v1.01-cache-2.11-cpan-299005ec8e3 )