From: Gordon Irving Date: Thu, 27 Aug 2009 12:22:24 +0000 (+0100) Subject: add attributes for extensions and plugins from Config::Any X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b9b58042bbd0cb0fabae5fdb4cdb3608315310e2;p=gitmo%2FMooseX-SimpleConfig.git add attributes for extensions and plugins from Config::Any --- diff --git a/lib/MooseX/SimpleConfig.pm b/lib/MooseX/SimpleConfig.pm index e12b104..9077c38 100644 --- a/lib/MooseX/SimpleConfig.pm +++ b/lib/MooseX/SimpleConfig.pm @@ -28,6 +28,26 @@ sub get_config_from_file { $raw_config; } +has extensions => ( + is => 'ro', + isa => 'ArrayRef', + lazy_build =>1, +); + +sub _build_extensions { + return Config::Any->extensions(); +} + +has plugins => ( + is => 'ro', + isa => 'ArrayRef', + lazy_build => 1 +); + +sub _build_plugins { + return [Config::Any->plugins()] ; +} + no Moose::Role; 1; __END__ diff --git a/t/12attributes.t b/t/12attributes.t new file mode 100644 index 0000000..2d44bfd --- /dev/null +++ b/t/12attributes.t @@ -0,0 +1,25 @@ +#!/usr/bin/perl +# vim: et + +use strict; +use warnings; + +use lib 't/lib'; +use lib '../t/lib'; + +use Test::More qw(no_plan); # last test to print +use Test::Moose; + +use_ok('MXSimpleConfigTest'); + +has_attribute_ok('MXSimpleConfigTest', 'extensions', 'extensions attribute is present'); + +has_attribute_ok('MXSimpleConfigTest', 'plugins', 'plugins attribute is present'); + +{ + my $config_test; + eval { $config_test = MXSimpleConfigTest->new(req_attr => 'foo') }; + isa_ok($config_test, "MXSimpleConfigTest", "test config created"); + isa_ok($config_test->plugins(), 'ARRAY', 'plugins is an array'); + isa_ok($config_test->extensions(), 'ARRAY', 'extentions is an array'); +}