File Coverage

blib/lib/Xerarch.pm
Criterion Covered Total %
statement 29 34 85.2
branch 6 6 100.0
condition n/a
subroutine 11 13 84.6
pod n/a
total 46 53 86.7


line stmt bran cond sub pod time code
1             package Xerarch;
2              
3 2     2   258506 use 5.006;
  2         6  
4 2     2   9 use strict;
  2         4  
  2         56  
5 2     2   27 use warnings;
  2         4  
  2         149  
6 2     2   1110 use meta;
  2         2333  
  2         914  
7              
8             our $VERSION = '0.05';
9              
10             sub import {
11 2     2   20 my $caller = caller();
12 2         165 my $metapkg = meta::get_package( $caller );
13              
14             my $callback = sub {
15 10     10   19 my ($is, $key) = @_;
16             return sub {
17 5     5   205633 my %symbols = $metapkg->list_symbols;
        5      
        5      
        5      
        5      
18 5         153 my @items;
19 5         40 for ( sort keys %symbols ) {
20 55 100       127 next if $_ =~ m/xerarch/;
21 25 100       104 if ($symbols{$_}->$is) {
22 5 100       28 push @items, $key ? (split "::", $symbols{$_}->$key)[1] : $_;
23             }
24             }
25              
26 5         66 return \@items;
27 10         62 };
28 2         15 };
29              
30 2         5 $metapkg->add_named_sub( 'xerarch_methods', $callback->('is_subroutine', 'subname') );
31            
32 2         17 $metapkg->add_named_sub( 'xerarch_scalars', $callback->('is_scalar') );
33            
34 2         6 $metapkg->add_named_sub( 'xerarch_arrays', $callback->('is_array') );
35              
36 2         5 $metapkg->add_named_sub( 'xerarch_hashes', $callback->('is_hash') );
37              
38 2         5 $metapkg->add_named_sub( 'xerarch_globs', $callback->('is_glob') );
39              
40             $metapkg->add_named_sub( 'xerarch', sub {
41 0     0     my %meta;
        0      
42 0           for (qw/methods scalars arrays hashes globs/) {
43 0           my $method = 'xerarch_' . $_;
44 0           $meta{$_} = $caller->$method;
45             }
46 0           return \%meta;
47 2         2244 });
48             }
49              
50             1;
51              
52             =head1 NAME
53              
54             Xerarch - Introspection
55              
56             =head1 VERSION
57              
58             Version 0.05
59              
60             =cut
61              
62             =head1 SYNOPSIS
63              
64             package My::Package;
65              
66             use Xerarch;
67              
68             ...
69              
70             1;
71              
72             my $pkg = My::Package->new();
73              
74             $pkg->xerarch();
75              
76             $pkg->xerarch_methods();
77             $pkg->xerarch_scalars();
78             $pkg->xerarch_arrays();
79             $pkg->xerarch_hashes();
80             $pkg->xerarch_globs();
81              
82             =head1 EXPORT
83              
84             =head2 xerarch
85              
86             List all methods, scalars, arrays, hashes and globs defined in the package.
87              
88             My::Package::xerarch();
89              
90             =cut
91              
92             =head2 xerarch_methods
93              
94             List all methods defined in the package.
95              
96             My::Package::xerarch_methods();
97              
98             =cut
99              
100             =head2 xerarch_scalars
101              
102             List all scalars defined in the package.
103              
104             My::Package::xerarch_scalars();
105              
106             =cut
107              
108             =head2 xerarch_arrays
109              
110             List all arrays defined in the package.
111              
112             My::Package::xerarch_arrays();
113              
114             =cut
115              
116             =head2 xerarch_hashes
117              
118             List all hashes defined in the package.
119              
120             My::Package::xerarch_hashes();
121              
122             =cut
123              
124             =head2 xerarch_globs
125              
126             List all globs for the package.
127              
128             My::Package::xerarch_globs();
129              
130             =cut
131              
132             =head1 AUTHOR
133              
134             LNATION, C<< >>
135              
136             =head1 BUGS
137              
138             Please report any bugs or feature requests to C, or through
139             the web interface at L. I will be notified, and then you'll
140             automatically be notified of progress on your bug as I make changes.
141              
142              
143             =head1 SUPPORT
144              
145             You can find documentation for this module with the perldoc command.
146              
147             perldoc Xerarch
148              
149              
150             You can also look for information at:
151              
152             =over 4
153              
154             =item * RT: CPAN's request tracker (report bugs here)
155              
156             L
157              
158             =item * Search CPAN
159              
160             L
161              
162             =back
163              
164              
165             =head1 ACKNOWLEDGEMENTS
166              
167              
168             =head1 LICENSE AND COPYRIGHT
169              
170             This software is Copyright (c) 2024 by LNATION.
171              
172             This is free software, licensed under:
173              
174             The Artistic License 2.0 (GPL Compatible)
175              
176              
177             =cut
178              
179             1; # End of Xerarch