Skip Menu |

This queue is for tickets about the Config-Simple CPAN distribution.

Report information
The Basics
Id: 18210
Status: new
Priority: 0/
Queue: Config-Simple

People
Owner: Nobody in particular
Requestors: ask [...] develooper.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: [patch] get_blocks method (and POD)
When setting out to add this I found out that get_block does (almost) the same thing, so I used that internally. Having an explicit documented method is worthwhile though, I think. diff -ru Config-Simple-4.58/Simple.pm Config-Simple-ask/Simple.pm --- Config-Simple-4.58/Simple.pm 2005-02-10 10:57:16.000000000 -0800 +++ Config-Simple-ask/Simple.pm 2006-03-16 18:05:17.000000000 -0800 @@ -498,8 +498,9 @@ return $rv; } - - +sub get_blocks { + sort shift->get_block(); +} sub set_block { @@ -1214,6 +1215,10 @@ $cfg->param('Project.Count', 3); +=item get_blocks() + +returns an ordered list of all blocks in ini-styled configuration files. + =item as_string() - returns the configuration file as a chunk of text. It is the same text used by diff -ru Config-Simple-4.58/t/ini.t Config-Simple-ask/t/ini.t --- Config-Simple-4.58/t/ini.t 2003-04-27 14:40:32.000000000 -0700 +++ Config-Simple-ask/t/ini.t 2006-03-16 18:04:22.000000000 -0800 @@ -5,12 +5,12 @@ ######################### use strict; -use Test; +use Test::More; use Data::Dumper; use FindBin '$RealBin'; use File::Spec; BEGIN { - plan tests => 18; + plan tests => 20; } use Config::Simple; @@ -48,6 +48,10 @@ my $names = $cfg->param('Project\100.Names'); ok(ref($names) eq 'ARRAY'); + +ok(my @blocks = $cfg->get_blocks, "get blocks"); +is_deeply(\@blocks, ['Project', 'Project\\0', 'Project\\1', 'Project\\100', 'Project\\2'], 'blocks list'); + ok($cfg->write());
Subject: Config-Simple.patch
diff -ru Config-Simple-4.58/Simple.pm Config-Simple-ask/Simple.pm --- Config-Simple-4.58/Simple.pm 2005-02-10 10:57:16.000000000 -0800 +++ Config-Simple-ask/Simple.pm 2006-03-16 18:05:17.000000000 -0800 @@ -498,8 +498,9 @@ return $rv; } - - +sub get_blocks { + sort shift->get_block(); +} sub set_block { @@ -1214,6 +1215,10 @@ $cfg->param('Project.Count', 3); +=item get_blocks() + +returns an ordered list of all blocks in ini-styled configuration files. + =item as_string() - returns the configuration file as a chunk of text. It is the same text used by diff -ru Config-Simple-4.58/t/ini.t Config-Simple-ask/t/ini.t --- Config-Simple-4.58/t/ini.t 2003-04-27 14:40:32.000000000 -0700 +++ Config-Simple-ask/t/ini.t 2006-03-16 18:04:22.000000000 -0800 @@ -5,12 +5,12 @@ ######################### use strict; -use Test; +use Test::More; use Data::Dumper; use FindBin '$RealBin'; use File::Spec; BEGIN { - plan tests => 18; + plan tests => 20; } use Config::Simple; @@ -48,6 +48,10 @@ my $names = $cfg->param('Project\100.Names'); ok(ref($names) eq 'ARRAY'); + +ok(my @blocks = $cfg->get_blocks, "get blocks"); +is_deeply(\@blocks, ['Project', 'Project\\0', 'Project\\1', 'Project\\100', 'Project\\2'], 'blocks list'); + ok($cfg->write());