Skip to content

Commit

Permalink
Make the punctuation prefix optional (not strictly gone)
Browse files Browse the repository at this point in the history
to fix plain bundle names ([@Bundle / @Bundle])
  • Loading branch information
rwstauner committed Mar 22, 2013
1 parent ad6bd4a commit 09312c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for Config-MVP-Writer-INI
{{$NEXT}}

- Don't leave a trailing space on a line where a config value is blank
- Try harder to match the name to the package moniker to avoid duplicates.
- Add 'strip_bundle_prefix' option to always remove the "@Foo/" part of
the section name (default true). This cuts down on the noise when the
name is actually different from the package moniker.
Expand Down
6 changes: 3 additions & 3 deletions lib/Config/MVP/Writer/INI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ sub _ini_section {

# this name matching junk could be better
{
# ignore leading punctuation for this comparison
(my $moniker = $package) =~ s/^\W+//;
# make leading punctuation optional for this comparison
my ($prefix, $moniker) = ($package =~ m/^(\W*)(.+)$/);

# Don't print the name if it's the same as the package moniker
# (ignoring possible bundle prefix and possible leading punctuation).
if( $name =~ m{^([^/]+/)*\Q$moniker\E$} ){
if( $name =~ m{^([^/]+/)*(\Q$prefix\E)?\Q$moniker\E$} ){
$name = ''
}
# else (if configured) just strip the whole prefix regardless
Expand Down
2 changes: 2 additions & 0 deletions t/ini.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ run_me(basic => {
[AllTheSame => ],
'EvenMore::TheSame' =>
'Mod::NoArray' =>
'@Bundle',
[EndWithConfig => EWC => {foo => [qw( bar baz )]}],
],
expected_ini => <<INI,
Expand Down Expand Up @@ -59,6 +60,7 @@ with = a config
[AllTheSame]
[EvenMore::TheSame]
[NoArray / Mod::NoArray]
[\@Bundle]
[EWC / EndWithConfig]
foo = bar
Expand Down

0 comments on commit 09312c9

Please sign in to comment.