| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Moonshine::Util; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 21364 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 32 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 38 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 654 | use String::Trim::More; | 
|  | 1 |  |  |  |  | 692 |  | 
|  | 1 |  |  |  |  | 53 |  | 
| 7 | 1 |  |  | 1 |  | 479 | use String::Elide::Parts 'elide'; | 
|  | 1 |  |  |  |  | 765 |  | 
|  | 1 |  |  |  |  | 54 |  | 
| 8 | 1 |  |  | 1 |  | 374 | use Exporter::Shiny; | 
|  | 1 |  |  |  |  | 3028 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 9 | 1 |  |  | 1 |  | 501 | use HTML::Valid::Tagset ':all'; | 
|  | 1 |  |  |  |  | 8991 |  | 
|  | 1 |  |  |  |  | 588 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | our @EXPORT = (qw/prepend_str append_str join_class/); | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | our @EXPORT_OK = (qw/left_trim_ws right_trim_ws trim_ws trim_ws_lines trim_blank_ws_lines ellipsis | 
| 14 |  |  |  |  |  |  | elide append_str prepend_str join_class assert_valid_html5_tag valid_attributes_for_tag/); | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | our %EXPORT_TAGS = ( | 
| 17 |  |  |  |  |  |  | base => \@EXPORT, | 
| 18 |  |  |  |  |  |  | all  => \@EXPORT_OK, | 
| 19 |  |  |  |  |  |  | ); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =head1 NAME | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | Moonshine::Util - Utils | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =head1 VERSION | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | Version 0.07 | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =cut | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | our $VERSION = '0.07'; | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head1 EXPORT | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | use Moonshine::Util "trim_blank_ws_lines" => { -as => "tbwl" }; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =head1 SUBROUTINES/METHODS | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =head2 assert_valid_html5_tag | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | assert_valid_html5_tag('span'); | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =cut | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | sub assert_valid_html5_tag { | 
| 48 | 0 | 0 |  | 0 | 1 |  | return $isHTML5{$_[0]} ? 1 : 0; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =head2 valid_attributes_for_tag | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | valid_attributes_for_tag('a'); | 
| 54 |  |  |  |  |  |  | valid_attributes_for_tag('a', standard => 'html5') | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | Returns an array reference containing all valid attributes for the specified html tag. | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =cut | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | sub valid_attributes_for_tag { | 
| 61 | 0 |  |  | 0 | 1 |  | return attributes(@_); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =head2 left_trim_ws | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | left_trim_ws($string) | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =cut | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | sub left_trim_ws { | 
| 71 | 0 |  |  | 0 | 1 |  | return String::Trim::More::ltrim(@_); | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head2 right_trim_ws | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | right_trim_ws($string) | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =cut | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | sub right_trim_ws { | 
| 81 | 0 |  |  | 0 | 1 |  | return String::Trim::More::rtrim(@_); | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | =head2 trim_ws | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | trim_ws($string) | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =cut | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | sub trim_ws { | 
| 91 | 0 |  |  | 0 | 1 |  | return String::Trim::More::trim(@_); | 
| 92 |  |  |  |  |  |  | } | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head2 trim_ws_lines | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | trim_ws_line($multi_line_str); | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =cut | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | sub trim_ws_lines { | 
| 101 | 0 |  |  | 0 | 1 |  | return String::Trim::More::trim_lines(@_); | 
| 102 |  |  |  |  |  |  | } | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =head2 trim_blank_ws_lines | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | trim_ws_line($multi_line_str); | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =cut | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | sub trim_blank_ws_lines { | 
| 111 | 0 |  |  | 0 | 1 |  | return String::Trim::More::trim_blank_lines(@_); | 
| 112 |  |  |  |  |  |  | } | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head2 ellipsis | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | ellipsis($str); | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | =cut | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | sub ellipsis { | 
| 121 | 0 |  |  | 0 | 1 |  | return String::Trim::More::ellipsis(@_); | 
| 122 |  |  |  |  |  |  | } | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head2 prepend_str | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | prepend_str($str_exists, $str_might_not); | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =cut | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | sub prepend_str { | 
| 131 | 0 | 0 |  | 0 | 1 |  | return defined $_[1] ? sprintf '%s %s', $_[1], $_[0] : $_[0]; | 
| 132 |  |  |  |  |  |  | } | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =head2 append_str | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | append_str($str_exists, $str_might_not); | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =cut | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | sub append_str { | 
| 141 | 0 | 0 |  | 0 | 1 |  | return defined $_[1] ? sprintf '%s %s', $_[0], $_[1] : $_[0]; | 
| 142 |  |  |  |  |  |  | } | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =head2 join_class | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | join_class($class_exists, $class_might_not); | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | =cut | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | sub join_class { | 
| 151 | 0 | 0 | 0 | 0 | 1 |  | defined $_[0] && defined $_[1] and return sprintf '%s%s', $_[0], $_[1]; | 
| 152 | 0 |  |  |  |  |  | return undef; | 
| 153 |  |  |  |  |  |  | } | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | =head2 elide | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | elide($text, 16, { truncate => 'left', marker => '...' }) | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | =cut | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | =head1 AUTHOR | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  | LNATION, C<<  >> | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  | =head1 BUGS | 
| 166 |  |  |  |  |  |  |  | 
| 167 |  |  |  |  |  |  | Please report any bugs or feature requests to C, or through | 
| 168 |  |  |  |  |  |  | the web interface at L.  I will be notified, and then you'll | 
| 169 |  |  |  |  |  |  | automatically be notified of progress on your bug as I make changes. | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  | =head1 SUPPORT | 
| 172 |  |  |  |  |  |  |  | 
| 173 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | perldoc Moonshine::Util | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | You can also look for information at: | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | =over 4 | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | =item * RT: CPAN's request tracker (report bugs here) | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | L | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | L | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | L | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | =item * Search CPAN | 
| 195 |  |  |  |  |  |  |  | 
| 196 |  |  |  |  |  |  | L | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  | =back | 
| 199 |  |  |  |  |  |  |  | 
| 200 |  |  |  |  |  |  | =head1 ACKNOWLEDGEMENTS | 
| 201 |  |  |  |  |  |  |  | 
| 202 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | Copyright 2017 Robert Acock. | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 207 |  |  |  |  |  |  | under the terms of the the Artistic License (2.0). You may obtain a | 
| 208 |  |  |  |  |  |  | copy of the full license at: | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | L | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | Any use, modification, and distribution of the Standard or Modified | 
| 213 |  |  |  |  |  |  | Versions is governed by this Artistic License. By using, modifying or | 
| 214 |  |  |  |  |  |  | distributing the Package, you accept this license. Do not use, modify, | 
| 215 |  |  |  |  |  |  | or distribute the Package, if you do not accept this license. | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | If your Modified Version has been derived from a Modified Version made | 
| 218 |  |  |  |  |  |  | by someone other than you, you are nevertheless required to ensure that | 
| 219 |  |  |  |  |  |  | your Modified Version complies with the requirements of this license. | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  | This license does not grant you the right to use any trademark, service | 
| 222 |  |  |  |  |  |  | mark, tradename, or logo of the Copyright Holder. | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  | This license includes the non-exclusive, worldwide, free-of-charge | 
| 225 |  |  |  |  |  |  | patent license to make, have made, use, offer to sell, sell, import and | 
| 226 |  |  |  |  |  |  | otherwise transfer the Package with respect to any patent claims | 
| 227 |  |  |  |  |  |  | licensable by the Copyright Holder that are necessarily infringed by the | 
| 228 |  |  |  |  |  |  | Package. If you institute patent litigation (including a cross-claim or | 
| 229 |  |  |  |  |  |  | counterclaim) against any party alleging that the Package constitutes | 
| 230 |  |  |  |  |  |  | direct or contributory patent infringement, then this Artistic License | 
| 231 |  |  |  |  |  |  | to you shall terminate on the date that such litigation is filed. | 
| 232 |  |  |  |  |  |  |  | 
| 233 |  |  |  |  |  |  | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | 
| 234 |  |  |  |  |  |  | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | 
| 235 |  |  |  |  |  |  | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | 
| 236 |  |  |  |  |  |  | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | 
| 237 |  |  |  |  |  |  | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | 
| 238 |  |  |  |  |  |  | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | 
| 239 |  |  |  |  |  |  | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | 
| 240 |  |  |  |  |  |  | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 241 |  |  |  |  |  |  |  | 
| 242 |  |  |  |  |  |  | =cut | 
| 243 |  |  |  |  |  |  |  | 
| 244 |  |  |  |  |  |  | 1; # End of Moonshine::Util |