| 1 | # vim: set ts=2 sts=2 sw=2 expandtab smarttab: | ||||||||||
| 2 | # | ||||||||||
| 3 | # This file is part of Dist-Zilla-Role-DynamicConfig | ||||||||||
| 4 | # | ||||||||||
| 5 | # This software is copyright (c) 2010 by Randy Stauner. | ||||||||||
| 6 | # | ||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||
| 9 | # | ||||||||||
| 10 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | package Dist::Zilla::Role::DynamicConfig; | ||||||||||
| 14 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | $Dist::Zilla::Role::DynamicConfig::VERSION = '1.002'; | |||||||||
| 16 | } | ||||||||||
| 17 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 2 | $Dist::Zilla::Role::DynamicConfig::AUTHORITY = 'cpan:RWSTAUNER'; | |||||||||
| 19 | } | ||||||||||
| 20 | # ABSTRACT: A Role that accepts a dynamic configuration | ||||||||||
| 21 | |||||||||||
| 22 | 2 | ▶ | use Dist::Zilla 4 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 2 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | has _config => ( | ||||||||||
| 27 | is => 'ro', | ||||||||||
| 28 | isa => 'HashRef', | ||||||||||
| 29 | 0 | ▶ | default => sub { +{} } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 30 | 2 | ); | |||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | # TODO: use around ? call $orig-> ? call super() ? | ||||||||||
| 34 | |||||||||||
| 35 | 3 | ▶ | sub BUILDARGS { | ||||||||
|
Subroutine
BUILDARGS: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||
| 36 | 3 | my ($class, @arg) = @_; | |||||||||
| 37 | 3 | ▶ | my %copy = ref $arg[0] ? %{$arg[0]} : @arg; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | |||||||||||
| 39 | 3 | my $zilla = delete $copy{zilla}; | |||||||||
| 40 | 3 | my $name = delete $copy{plugin_name}; | |||||||||
| 41 | |||||||||||
| 42 | confess 'do not try to pass _config as a build arg!' | ||||||||||
| 43 | 3 | ▶ | if $copy{_config}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | |||||||||||
| 45 | 3 | my $other = $class->separate_local_config(\%copy); | |||||||||
| 46 | |||||||||||
| 47 | return { | ||||||||||
| 48 | 3 | zilla => $zilla, | |||||||||
| 49 | plugin_name => $name, | ||||||||||
| 50 | _config => \%copy, | ||||||||||
| 51 | %$other | ||||||||||
| 52 | } | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | 2 | requires 'separate_local_config'; | |||||||||
| 57 | |||||||||||
| 58 | 2 | ▶ | no Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 59 | 2 | 1; | |||||||||
| 60 | |||||||||||
| 61 | |||||||||||
| 62 | __END__ | ||||||||||