sub structure {
my ($self, $data) = @_;
- if (ref($data) eq 'ARRAY') {
+ if (ref($data) eq 'HASH') {
+ $data = [ @{$data}{sort keys %$data} ];
my @cols = sort keys %{$data->[0]};
return [ {
columns => \@cols,
sub descend {
my ($self, $target, @path) = @_;
+ return $target unless @path;
my $step = shift @path;
if (blessed($target) and $target->isa('IO::All::File')) {
$target = $self->json->decode(scalar $target->all);
}
- $self->descend(::Dwarn($target->{$step}), @path);
+ $self->descend($target->{$step}, @path);
}
sub render_table {
<html>, <body>, "\n",
<table>, "\n",
(map {;
- ' ', <tr>, (map { <td>, $_, </td> } @$_), </tr>, "\n"
+ ' ', <tr>,
+ (map { <td>, $self->render_el($_), </td> } @$_),
+ </tr>, "\n"
} @rows),
</table>, "\n",
</body>, </html>, "\n",
] ];
}
+sub render_el { ref($_[1]) eq 'ARRAY' ? join(', ', @{$_[1]}) : $_[1] }
+
__PACKAGE__->run_if_script;