File Coverage

blib/lib/Rest/HtmlVis/Key.pm
Criterion Covered Total %
statement 8 33 24.2
branch 0 2 0.0
condition 0 6 0.0
subroutine 3 14 21.4
pod 11 11 100.0
total 22 66 33.3


line stmt bran cond sub pod time code
1             package Rest::HtmlVis::Key;
2              
3 1     1   2333 use 5.006;
  1         3  
4 1     1   3 use strict;
  1         1  
  1         18  
5 1     1   3 use warnings FATAL => 'all';
  1         1  
  1         261  
6              
7             =head1 NAME
8              
9             Rest::HtmlVis::Key - Base class for easy-to-use html vis
10              
11             =head1 VERSION
12              
13             Version 0.01
14              
15             =cut
16              
17             our $VERSION = '0.11';
18              
19              
20             =head1 SYNOPSIS
21              
22             All you have to do is to inherit from Rest::HtmlVis::Key and then implement the callback html.
23              
24             Example:
25              
26             package Rest::HtmlVis::MyGraph;
27             use parent qw( Rest::HtmlVis::Key );
28            
29             use YAML::Syck;
30              
31             sub html {
32             my ($self) = @_;
33              
34             local $Data::Dumper::Indent=1;
35             local $Data::Dumper::Quotekeys=0;
36             local $Data::Dumper::Terse=1;
37             local $Data::Dumper::Sortkeys=1;
38              
39             return '
'.Dump($self->getStruct).'
';
40             }
41              
42             =head1 SUBROUTINES/METHODS
43              
44             =head2 new
45              
46             =cut
47              
48             sub new {
49 0     0 1   my ($class, $baseurl) = @_;
50 0           return bless {baseurl => $baseurl}, $class;
51             }
52              
53             =head2 baseurl
54              
55             =cut
56              
57             sub baseurl {
58 0     0 1   return $_[0]->{baseurl};
59             }
60              
61             =head2 setStruct
62              
63             =cut
64              
65             sub setStruct {
66 0     0 1   my ($self, $key, $struct, $env) = @_;
67 0 0 0       if ($struct && ref $struct eq 'HASH' && exists $struct->{$key}){
      0        
68 0           $self->{struct} = $struct->{$key};
69 0           $self->{env} = $env;
70 0           return 1;
71             }else{
72 0           $self->{struct} = undef;
73             }
74 0           return undef;
75             }
76              
77             =head2 getStruct
78              
79             Return html hash with input structure.
80              
81             =cut
82              
83             sub getStruct {
84 0     0 1   my ($self) = @_;
85 0           return $self->{struct};
86             }
87              
88             =head2 getEnv
89              
90             Return env variables.
91              
92             =cut
93              
94             sub getEnv {
95 0     0 1   my ($self) = @_;
96 0           return $self->{env};
97             }
98              
99             =head2 getOrder
100              
101             Return wight on elemnt on html page. Default 1 means in middle;
102              
103             =cut
104              
105             sub getOrder {
106 0     0 1   return 1;
107             }
108              
109             =head2 blocks
110              
111             Number of blocks in row. Max 12. (ala bootstrap)
112              
113             Default is 12;
114              
115             =cut
116              
117             sub blocks {
118 0     0 1   my ($self) = @_;
119 0           return 12;
120             }
121              
122             =head2 newRow
123              
124             Define if element is on new row or is the part of previous row.
125              
126             Default is 0 - no new row;
127              
128             =cut
129              
130             sub newRow {
131 0     0 1   my ($self) = @_;
132 0           return 0;
133             }
134              
135             =head2 head
136              
137             Return head of page as HTML string.
138              
139             Default empty.
140              
141             =cut
142              
143             sub head {
144 0     0 1   my ($self) = @_;
145 0           return;
146             }
147              
148             =head2 onload
149              
150             Return onload javascript function of onload attr in body. It must ends with ;
151              
152             Default empty.
153              
154             =cut
155              
156             sub onload {
157 0     0 1   my ($self) = @_;
158 0           return;
159             }
160              
161             =head2 html
162              
163             Return body part of HTML.
164              
165             Default empty.
166              
167             =cut
168              
169             sub html {
170 0     0 1   my ($self) = @_;
171 0           return;
172             }
173              
174             =encoding utf-8
175              
176             =head1 AUTHOR
177              
178             Václav Dovrtěl Evaclav.dovrtel@gmail.comE
179              
180             =head1 BUGS
181              
182             Please report any bugs or feature requests to github repository.
183              
184             =head1 ACKNOWLEDGEMENTS
185              
186             Inspired by L
187              
188             =head1 REPOSITORY
189              
190             L
191              
192             =head1 LICENSE AND COPYRIGHT
193              
194             Copyright 2015 Vaclav Dovrtel.
195              
196             This program is free software; you can redistribute it and/or modify it
197             under the terms of either: the GNU General Public License as published
198             by the Free Software Foundation; or the Artistic License.
199              
200             See L for more information.
201              
202             =cut
203              
204             1; # End of Rest::HtmlVis::Key