Skip Menu |

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

Report information
The Basics
Id: 27791
Status: new
Priority: 0/
Queue: Config-YAML

People
Owner: mdxi [...] cpan.org
Requestors: sendwade [...] hotmail.com
Cc:
AdminCc:

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



Subject: Config::YAML::AUTOLOAD causes incompatibility with Template::Toolkit
Hi, I had to remove Config::YAML::AUTOLOAD to get Config::YAML to work in Template::Toolkit. Please see the attached patch (that includes tests). Without the patch to the module, test 12 fails. Of course with the patch t/04.get-set.t fails, so unfortunately it is not a fix. The tests prove its not a problem with YAML.pm, but it very well may be a problem with TT. If decide this is the case and would prefer that I follow up with TT, please let me know. $ perl -v This is perl, v5.8.7 built for i686-linux $ perl -MTemplate -e 'print "$Template::VERSION\n"' 2.18 Thank you, Todd W.
Subject: tt.diff
diff -r -u -N Config-YAML-1.42/lib/Config/YAML.pm Config-YAML-tt/lib/Config/YAML.pm --- Config-YAML-1.42/lib/Config/YAML.pm 2005-09-25 12:49:55.000000000 -0400 +++ Config-YAML-tt/lib/Config/YAML.pm 2007-06-28 05:40:37.000000000 -0400 @@ -6,8 +6,6 @@ use strict; use YAML; -use vars qw( $AUTOLOAD ); - =head1 NAME Config::YAML - Simple configuration automation @@ -115,41 +113,6 @@ return $self; } -=head2 get_*/set_* - -If you'd prefer not to directly molest the object to store and -retrieve configuration data, autoloading methods of the forms -C<get_[param]> and C<set_[param]> are provided. Continuing from the -previous example: - - print $c->get_foo; # prints "abc" - my $val = $c->get_quux; # $c->{quux} doesn't exist; returns undef - - $c->set_bar(30); # $c->{bar} now equals 30, not "xyz" - my @list = qw(alpha beta gamma); - $c->set_baz(\@list); # $c->{baz} now a reference to @list - -=cut - -sub Config::YAML::AUTOLOAD { - no strict 'refs'; - my ($self, $newval) = @_; - - if ($AUTOLOAD =~ /.*::get_(\w+)/) { - my $attr = $1; - return undef if (!defined $self->{$attr}); - *{$AUTOLOAD} = sub { return $_[0]->{$attr} }; - return $self->{$attr}; - } - - if ($AUTOLOAD =~ /.*::set_(\w+)/) { - my $attr = $1; - *{$AUTOLOAD} = sub { $_[0]->{$attr} = $_[1]; return }; - $self->{$attr} = $newval; - return; - } -} - =head2 fold Convenience method for folding multiple values into the config object diff -r -u -N Config-YAML-1.42/t/07.tt.t Config-YAML-tt/t/07.tt.t --- Config-YAML-1.42/t/07.tt.t 1969-12-31 19:00:00.000000000 -0500 +++ Config-YAML-tt/t/07.tt.t 2007-06-28 05:34:24.000000000 -0400 @@ -0,0 +1,67 @@ +use warnings; +use strict; + +use Test::More tests => 15; + +use_ok('Template'); + +isa_ok( + my $tt = Template->new, + Template => '$tt' +); + +my $text = "foo: [% config.foo %]"; + +{ + use_ok('YAML'); + + isa_ok( + my $c = YAML::LoadFile('t/tt.yaml'), + HASH => '$c' + ); + + is( $c->{foo} => bar => 'have expected data' ); + + my $output; + + ok( $tt->process(\$text, { config => $c }, \$output), 'processed template' ); + + is( + $output, + 'foo: bar', + 'YAML data in processed template' + ); +} + +{ + use_ok('Config::YAML'); + + isa_ok( + my $c = Config::YAML->new(config => 't/tt.yaml'), + 'Config::YAML' => '$c' + ); + + is( $c->{foo} => bar => 'have expected data' ); + + my $output; + + ok( $tt->process(\$text, { config => $c }, \$output), 'processed template' ); + + is( + $output, + 'foo: bar', + 'Config::YAML data in processed template' + ); + + isa_ok($c = {%$c}, 'HASH', 'now $c'); + + $output = ''; + + ok( $tt->process(\$text, { config => $c }, \$output), 'processed template' ); + + is( + $output, + 'foo: bar', + 'Config::YAML data in processed template' + ); +} diff -r -u -N Config-YAML-1.42/t/tt.yaml Config-YAML-tt/t/tt.yaml --- Config-YAML-1.42/t/tt.yaml 1969-12-31 19:00:00.000000000 -0500 +++ Config-YAML-tt/t/tt.yaml 2007-06-28 03:20:24.000000000 -0400 @@ -0,0 +1,3 @@ +--- #YAML:1.0 +foo: bar +
From: sendwade [...] hotmail.com
Grrr! Apologies for the double submit, RT gave me a 500 error.