1 package TB_Temp_Packname;
4 use Scalar::Util qw(blessed);
8 has root => (is => 'lazy');
10 has json => (is => 'lazy');
13 io->dir("/home/matthewt/tmp/introspection-data/host/services-dev/stable/node/host/")
20 sub dispatch_request {
24 ref($_[0][0]) eq 'HASH' ? $self->render_table($_[0][0]) : $_[0]
28 $self->structure($self->descend($self->root, split '/', $_[1]));
33 my ($self, $data) = @_;
34 if (ref($data) eq 'ARRAY') {
35 my @cols = sort keys %{$data->[0]};
41 die "Confused by $data";
46 my ($self, $target, @path) = @_;
47 my $step = shift @path;
48 if (blessed($target) and $target->isa('IO::All::File')) {
49 $target = $self->json->decode(scalar $target->all);
51 $self->descend(::Dwarn($target->{$step}), @path);
55 my ($self, $data) = @_;
59 map [ @{$_}{@{$data->{columns}}} ], @{$data->{data}}
61 [ 200, [ 'Content-type' => 'text/html' ], [
62 HTML::Tags::to_html_string(
66 ' ', <tr>, (map { <td>, $_, </td> } @$_), </tr>, "\n"
69 </body>, </html>, "\n",
74 __PACKAGE__->run_if_script;