File Coverage

blib/lib/LaTeX/TikZ/Interface.pm
Criterion Covered Total %
statement 55 55 100.0
branch 6 6 100.0
condition 6 6 100.0
subroutine 7 7 100.0
pod 2 2 100.0
total 76 76 100.0


line stmt bran cond sub pod time code
1             package LaTeX::TikZ::Interface;
2              
3 10     10   39 use strict;
  10         12  
  10         251  
4 10     10   31 use warnings;
  10         12  
  10         301  
5              
6             =head1 NAME
7              
8             LaTeX::TikZ::Interface - LaTeX::TikZ public interface register and loader.
9              
10             =head1 VERSION
11              
12             Version 0.03
13              
14             =cut
15              
16             our $VERSION = '0.03';
17              
18 10     10   3848 use Sub::Name ();
  10         4536  
  10         959  
19              
20             =head1 METHODS
21              
22             =head2 C
23              
24             LaTeX::Tikz::Interface->register($keyword => $code)
25              
26             Registers C<$code> to be available with C<< Tikz->$keyword >>.
27              
28             =cut
29              
30             sub register {
31 217     217 1 10894 shift;
32              
33 217         528 while (@_ >= 2) {
34 248         505 my ($name, $code) = splice @_, 0, 2;
35              
36 248 100 100     1701 unless (defined $name and $name =~ /^[a-z_][a-z0-9_]+$/i) {
37 2         9 require Carp;
38 2         212 Carp::confess('Invalid interface name');
39             }
40              
41 10 100   10   45 if (do { no strict 'refs'; defined &{__PACKAGE__."::$name"} }) {
  10         12  
  10         744  
  246         204  
  246         183  
  246         1400  
42 1         5 require Carp;
43 1         98 Carp::confess("'$name' is already defined in the interface");
44             }
45              
46 245 100 100     939 unless (defined $code and ref $code eq 'CODE') {
47 3         12 require Carp;
48 3         289 Carp::confess('Invalid code reference');
49             }
50              
51 242         738 Sub::Name::subname($name => $code);
52              
53             {
54 10     10   36 no strict 'refs';
  10         12  
  10         1481  
  242         263  
55 242         200 *{__PACKAGE__.'::'.$name} = $code;
  242         1100  
56             }
57             }
58              
59 211         306 return;
60             }
61              
62             =head2 C
63              
64             Load all the modules of the L official suite that register a keyword in the interface.
65              
66             =cut
67              
68             sub load {
69 11     11 1 2962 require LaTeX::TikZ::Formatter; # formatter
70 11         3177 require LaTeX::TikZ::Functor; # functor
71              
72 11         3003 require LaTeX::TikZ::Set::Raw; # raw
73              
74 11         3151 require LaTeX::TikZ::Set::Union; # union, path
75 11         3198 require LaTeX::TikZ::Set::Sequence; # seq
76 11         3225 require LaTeX::TikZ::Set::Chain; # chain, join
77              
78 11         60 require LaTeX::TikZ::Set::Point; # point
79 11         3204 require LaTeX::TikZ::Set::Line; # line
80 11         3013 require LaTeX::TikZ::Set::Polyline; # polyline, closed_polyline
81 11         3260 require LaTeX::TikZ::Set::Rectangle; # rectangle
82 11         3132 require LaTeX::TikZ::Set::Circle; # circle
83 11         3179 require LaTeX::TikZ::Set::Arc; # arc
84 11         3158 require LaTeX::TikZ::Set::Arrow; # arrow
85              
86 11         2892 require LaTeX::TikZ::Mod::Raw; # raw_mod
87              
88 11         65 require LaTeX::TikZ::Mod::Clip; # clip
89 11         36 require LaTeX::TikZ::Mod::Layer; # layer
90              
91 11         2911 require LaTeX::TikZ::Mod::Scale; # scale
92 11         2897 require LaTeX::TikZ::Mod::Width; # width
93 11         2863 require LaTeX::TikZ::Mod::Color; # color
94 11         3361 require LaTeX::TikZ::Mod::Fill; # fill
95 11         2997 require LaTeX::TikZ::Mod::Pattern; # pattern
96             }
97              
98             =head1 SEE ALSO
99              
100             L.
101              
102             =head1 AUTHOR
103              
104             Vincent Pit, C<< >>, L.
105              
106             You can contact me by mail or on C (vincent).
107              
108             =head1 BUGS
109              
110             Please report any bugs or feature requests to C, or through the web interface at L.
111             I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
112              
113             =head1 SUPPORT
114              
115             You can find documentation for this module with the perldoc command.
116              
117             perldoc LaTeX::TikZ
118              
119             =head1 COPYRIGHT & LICENSE
120              
121             Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved.
122              
123             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
124              
125             =cut
126              
127             1; # End of LaTeX::TikZ::Interface