[Bps-public-commit] r11230 - in WebChart: lib lib/WebChart/Renderer
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Mar 27 08:21:50 EDT 2008
Author: sunnavy
Date: Thu Mar 27 08:21:49 2008
New Revision: 11230
Modified:
WebChart/lib/WebChart.pm
WebChart/lib/WebChart/Renderer/Chart.pm
WebChart/t/chart.t
Log:
css_classes is renamed to css_class, and the value is a string instead of arrayref now.
Modified: WebChart/lib/WebChart.pm
==============================================================================
--- WebChart/lib/WebChart.pm (original)
+++ WebChart/lib/WebChart.pm Thu Mar 27 08:21:49 2008
@@ -9,7 +9,8 @@
use base qw/Class::Accessor::Fast/;
-__PACKAGE__->mk_accessors(qw/renderer img_dir web_img_dir css_classes/);
+__PACKAGE__->mk_accessors(
+ qw/renderer img_dir web_img_dir css_class/);
=head2 new
@@ -18,11 +19,10 @@
e.g.
%args = ( renderer => 'WebChart::Renderer::Chart', img_dir => '/tmp',
- web_img_dir => '/charts', css_classes => [ 'foo', 'bar' ] )
+ web_img_dir => '/charts', css_class => 'foo bar' )
=cut
-
sub new {
my $class = shift;
@@ -33,7 +33,6 @@
return $self;
}
-
=head2 init
init job is done here, you don't need to call this directly, C<new> will.
@@ -60,7 +59,7 @@
$self->web_img_dir( $args{web_img_dir} || '/charts' );
- $self->css_classes( $args{css_classes} || [] );
+ $self->css_class( $args{css_class} );
}
=head2 render
@@ -68,7 +67,7 @@
render pictures.
%args = ( width => 400, height => 300, data = [ ... ] )
-you can also supply img_dir, web_img_dir and css_classes args to overwrite
+you can also supply img_dir, web_img_dir and css_class args to overwrite
things the WebChart object already have
=cut
@@ -76,9 +75,11 @@
sub render {
my $self = shift;
return $self->renderer->render(
- img_dir => $self->img_dir,
- web_img_dir => $self->web_img_dir,
- css_classes => $self->css_classes,
+ (
+ map { $_ => $self->$_ } (
+ qw/img_dir web_img_dir css_class/
+ )
+ ),
@_,
);
}
Modified: WebChart/lib/WebChart/Renderer/Chart.pm
==============================================================================
--- WebChart/lib/WebChart/Renderer/Chart.pm (original)
+++ WebChart/lib/WebChart/Renderer/Chart.pm Thu Mar 27 08:21:49 2008
@@ -3,7 +3,6 @@
use warnings;
use Carp;
-package WebChart::Renderer::Chart;
use base qw/ WebChart::Renderer /;
=head2 render
@@ -58,8 +57,8 @@
my $seg = qq[<img src="$args{web_img_dir}/]
. ( File::Spec->splitpath($filename) )[2] . q{"};
- if ( @{ $args{css_classes} } ) {
- $seg .= q{ class="} . join( ' ', @{ $args{css_classes} } ) . q{"};
+ if ( $args{css_class} ) {
+ $seg .= qq{ class="$args{css_class}"};
}
$seg .= q[ />];
Modified: WebChart/t/chart.t
==============================================================================
--- WebChart/t/chart.t (original)
+++ WebChart/t/chart.t Thu Mar 27 08:21:49 2008
@@ -41,13 +41,13 @@
$seg = $wc->render(
type => 'bars',
data => $data,
- css_classes => [ 'foo', 'bar' ],
+ css_class => 'foo bar',
);
like(
$seg,
qr{<img src="/charts/.*png" class="foo bar" />},
- 'render bars with classes works'
+ 'render bars with css class works'
);
# Pie
More information about the Bps-public-commit
mailing list