File Coverage

blib/lib/Dev/Util/Syntax.pm
Criterion Covered Total %
statement 39 39 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 12 12 100.0
pod 1 1 100.0
total 56 56 100.0


line stmt bran cond sub pod time code
1             package Dev::Util::Syntax;
2              
3 8     8   1408154 use 5.018;
  8         34  
4              
5 8     8   698 use utf8;
  8         332  
  8         51  
6 8     8   218 use strict;
  8         16  
  8         182  
7 8     8   36 use warnings;
  8         21  
  8         470  
8 8     8   4305 use autodie;
  8         168281  
  8         36  
9 8     8   74509 use version;
  8         15888  
  8         51  
10 8     8   5545 use Readonly;
  8         40446  
  8         665  
11 8     8   4429 use open qw(:std :utf8);
  8         11789  
  8         65  
12              
13 8     8   5209 use Import::Into;
  8         26719  
  8         320  
14 8     8   61 use Module::Runtime;
  8         19  
  8         31  
15              
16             our $VERSION = version->declare("v2.19.35");
17              
18             sub importables {
19 24     24 1 51 my ($class) = @_;
20             return (
21 24         221 [ 'feature', ':5.18' ], 'utf8',
22             'strict', 'warnings',
23             'autodie', [ 'open', ':std', ':utf8' ],
24             'version', 'Readonly',
25             'Carp', [ 'English', '-no_match_vars' ]
26             );
27             }
28              
29             sub import {
30 24     24   153 my (@args) = @_;
31 24         59 my $class = shift @args;
32 24         103 my $caller = caller;
33              
34 24         97 foreach my $import_proto ( $class->importables ) {
35 240         223686 my $module;
36 240 100 100     1423 ( $module, @args )
37             = ( ref($import_proto) || '' ) eq 'ARRAY'
38             ? @$import_proto
39             : ( $import_proto, () );
40 240         688 Module::Runtime::use_module($module)->import::into( $caller, @args );
41             }
42 24         47611 return;
43             }
44              
45             1; # End of Dev::Util::Syntax
46              
47             =pod
48              
49             =encoding utf-8
50              
51             =head1 NAME
52              
53             Dev::Util::Syntax - Provide consistent feature setup.
54              
55             =head1 VERSION
56              
57             Version v2.19.35
58              
59             =head1 SYNOPSIS
60              
61             Provide consistent feature setup. Put all of the "use" setup cmds in one place.
62             Then import them into other modules.
63              
64             Use this in other modules:
65              
66             package Dev::Util::Example;
67              
68             use Dev::Util::Syntax;
69              
70             # Rest of Code...
71              
72             This is equivalent to:
73              
74             package Dev::Util::Example;
75              
76             use feature :5.18;
77             use utf8;
78             use strict;
79             use warnings;
80             use autodie;
81             use open qw(:std :utf8);
82             use version;
83             use Readonly;
84             use Carp;
85             use English qw( -no_match_vars );
86              
87             # Rest of Code...
88              
89             =head1 SUBROUTINES/METHODS
90              
91             =head2 importables
92              
93             Define the items to be imported.
94              
95             =head2 import
96              
97             Do the import.
98              
99             =head1 AUTHOR
100              
101             Matt Martini, C<< <matt at imaginarywave.com> >>
102              
103             =head1 BUGS
104              
105             Please report any bugs or feature requests to C<bug-dev-util at rt.cpan.org>, or through
106             the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dev-Util>. I will
107             be notified, and then you'll automatically be notified of progress on your bug as I make changes.
108              
109             =head1 SUPPORT
110              
111             You can find documentation for this module with the perldoc command.
112              
113             perldoc Dev::Util::Syntax
114              
115             You can also look for information at:
116              
117             =over 4
118              
119             =item * RT: CPAN's request tracker (report bugs here)
120              
121             L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Dev-Util>
122              
123             =item * Search CPAN
124              
125             L<https://metacpan.org/release/Dev-Util>
126              
127             =back
128              
129             =head1 ACKNOWLEDGMENTS
130              
131             =head1 LICENSE AND COPYRIGHT
132              
133             This software is Copyright © 2024-2025 by Matt Martini.
134              
135             This is free software, licensed under:
136              
137             The GNU General Public License, Version 3, June 2007
138              
139             =cut
140              
141             __END__