如何将数组从weaver.ini传递到Pod :: Weaver插件

时间:2011-08-06 16:37:19

标签: perl moose pod

所以看来,为了传递weaver.ini中的内容,插件本身需要一个Moose属性。所以如果我在weaver.ini

中有这样的话
[Acknowledgements]
contributors = 'test foo' 'foo bar'

我的插件中需要一个相应的属性。

has contributors => (
    is      => 'rw',
    isa     => 'ArrayRef[Str]',
    traits  => [ 'Array' ],
    default => sub { [ ] },
    handles => {
        contributors_count => 'count',
    },
);

但是,我收到了错误

Attribute (contributors) does not pass the type constraint because: Validation failed for 'ArrayRef[Str]' with value 'test foo' 'foo bar' at /home/xenoterracide/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/Moose/Meta/Attribute.pm line 1248

我不确定我哪里出错了。我已尝试在weaver.ini中更改语法,但似乎不是这样。

1 个答案:

答案 0 :(得分:3)

.ini语法略有不同。

[Acknowledgements]
contributor = test foo
contributor = foo bar

除此之外,您还必须告诉Config::MVP,这是负责Dist::Zilla配置加载的内容,您的插件的contributor选项可能有多个值:

sub mvp_multivalue_args { qw(contributors) }
相关问题