GitXplorerGitXplorer
z

perl6-Config-From

public
2 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
0739fdcadc836878201f6a20796f7e758c200b44

Update .travis.yml

zzoffixznet committed 8 years ago
Unverified
1c3baa02973f81225802b3f797386a2f275c8a91

Merge pull request #1 from samcv/SPDX-license

zzoffixznet committed 8 years ago
Verified
b79855e20f6e88932aa7c44d6a3e8238558fcf82

Use SPDX identifier in license field of META6.json

ssamcv committed 8 years ago
Unverified
b124dbda6c8742a8c2ff7a6c3153fbb662176643

List Test::META in prereqs

zzoffixznet committed 9 years ago
Unverified
7f084fcd2b34b1f4377781956487bfa82207adaa

Improve docs

zzoffixznet committed 9 years ago
Unverified
1c127eb9719a59bb4895961d167e6368220d810d

Fix typo

zzoffixznet committed 9 years ago

README

The README file for this repository.

Build Status

NAME

Config::From - Load configuration from file to variables via traits

SYNOPSIS

JSON config file my-config.json:

{
    "user"  : "zoffix",
    "pass"  : "s3cret",
    "groups": [ "foo", "bar", "ber" ]
}

Program that uses it:

use Config::From 'my-config.json'; # config file defaults to 'config.json'

# automatically load variables from config
my $user   is from-config;
my $pass   is from-config;
my @groups is from-config;

say "$user\'s password is $pass and they belong to @groups[]";
# Prints: zoffix's password is s3cret and they belong to foo, bar, ber

DESCRIPTION

This module lets you load a configuration file (in JSON format) and assign values from it to variables using traits.

EXPORTED TRAITS

is from-config

my $user         is from-config;
my @groups       is from-config;
my %replacements is from-config;

Tells the variable to get its values from the config file. The name of the variable will be used as the name of the key in the top-level object of the JSON config file.

The @ and % sigils on variables will coerce the JSON value into array or hash, respectively.

LIMITATIONS

Current implementation does not allow use of more than one configuration file per application and only lets you access values in a top-level object.

This may change in the future, if there's demand for such features.


REPOSITORY

Fork this module on GitHub: https://github.com/zoffixznet/perl6-Config-From

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/perl6-Config-From/issues

AUTHOR

Zoffix Znet (http://zoffix.com/)

LICENSE

You can use and distribute this module under the terms of the The Artistic License 2.0. See the LICENSE file included in this distribution for complete details.