Quiq/Css/Snippets.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 92.1% 35 / 38 CC 4 SCAR 8.5
CC
4
Cov
90%
snippets
4.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« Quiq/LineProcessor/Line.pm ↑ Summary Quiq/Html/Image.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Css::Snippets - CSS-Code für die Seiten einer Web-Applikation
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Hash>
12  
13 =head1 DESCRIPTION
14  
15 Ein Objekt der Klasse ist ein Speicher für Gruppen von CSS-Definitionen,
16 die auf den Webseiten einer Applikation selektiv genutzt werden können.
17 Eine Gruppe ("Snippet") wird unter einem Schlüssel $key, z.B. 'page'
18 oder 'menubar' im Objekt gespeichert und kann über diesen abgefragt
19 werden.
20  
21 =head1 EXAMPLE
22  
23 use Quiq::Css::Snippets;
24
25 # Instantiiere Objekt (hier am Beispiel der der Gruppen 'page'
26 # und 'menubar')
27
28 my $sty = Quiq::Css::Snippets->new(
29 page => q~
30 body {
31 font-family: sans-serif;
32 font-size: 11pt;
33 }
34 ~,
35 menubar => q~
36 #menubar {
37 font-size: 14pt;
38 }
39 #menubar li {
40 padding-left: 18px;
41 padding-right: 18px;
42 }
43 ~
44 );
45
46 my $cssCode = $sty->snippets('page','menuber');
47 ==>
48 body {
49 font-family: sans-serif;
50 font-size: 11pt;
51 }
52 #menubar {
53 font-size: 14pt;
54 }
55 #menubar li {
56 padding-left: 18px;
57 padding-right: 18px;
58 }
59  
60 =cut
61  
62 # -----------------------------------------------------------------------------
63  
64 package Quiq::Css::Snippets;
65 1 ▶use base qw/Quiq::Hash/;
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
70  
71 1 our $VERSION = '1.240';
72  
73 1 ▶use Quiq::Unindent;
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 # -----------------------------------------------------------------------------
76  
77 =head1 METHODS
78  
79 =head2 Konstruktor
80  
81 =head3 new() - Instantiiere Objekt
82  
83 =head4 Synopsis
84  
85 $sty = $class->new($key=>\%typeArr,...);
86  
87 =head4 Description
88  
89 Instantiiere ein Objekt der Klasse und liefere eine Referenz auf
90 dieses Objekt zurück.
91  
92 =cut
93  
94 # -----------------------------------------------------------------------------
95  
96 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
97 1 my $class = shift;
98 # @_: $key=>\%typeArr,...
99 1 return $class->SUPER::new({@_});
100 }
101  
102 # -----------------------------------------------------------------------------
103  
104 =head2 Objektmethoden
105  
106 =head3 snippets() - Liefere Liste der CSS-Gruppen
107  
108 =head4 Synopsis
109  
110 @arr | $arr = $res->snippets(@keys);
111  
112 =head4 Arguments
113  
114 =over 4
115  
116 =item @keys
117  
118 Liste von Schlüsseln, z.B. 'page', 'menubar'.
119  
120 =back
121  
122 =head4 Description
123  
124 Liefere die Liste der Gruppen mit den Schlüsseln @keys.
125  
126 =cut
127  
128 # -----------------------------------------------------------------------------
129  
130 1 ▶sub snippets {
Subroutine snippets: called CC=4 SCAR=14.6
Pod documented
131 1 my $self = shift;
132 # @_: @keys
133  
134 1 my @arr;
135 1 for my $key (@_) {
136 2 ▶ if (!exists $self->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{$key}) 0 2 2
137 0 $self->throw(
138 'CSS-00001: Snippet not defined',
139 Resource => $key,
140 );
141 }
142 2 push @arr,Quiq::Unindent->string($self->{$key});
143 }
144  
145 1 ▶ return wantarray? @arr: join('',@arr);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
146 }
147  
148 # -----------------------------------------------------------------------------
149  
150 =head1 VERSION
151  
152 1.240
153  
154 =head1 AUTHOR
155  
156 Frank Seitz, L<http://fseitz.de/>
157  
158 =head1 COPYRIGHT
159  
160 Copyright (C) 2026 Frank Seitz
161  
162 =head1 LICENSE
163  
164 This code is free software; you can redistribute it and/or modify
165 it under the same terms as Perl itself.
166  
167 =cut
168  
169 # -----------------------------------------------------------------------------
170  
171 1 1;
172  
173 # eof
« Quiq/LineProcessor/Line.pm ↑ Summary Quiq/Html/Image.pm »