blib/lib/Syntax/Feature/Io.pm

filter: Statementstmt 94.8% 37 / 39 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 100% 1 / 1 totaltotal 85.7% 54 / 63 CC 7 SCAR 14.2
CC
7
Cov
84%
install
8.4
__ANON__
2.0
BEGIN
1.0
CRAP 4.1
↑ Summary
1 1 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 # ABSTRACT: Provides IO::All
4  
5 package Syntax::Feature::Io;
6 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $Syntax::Feature::Io::VERSION = '0.001';
8 }
9 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 $Syntax::Feature::Io::AUTHORITY = 'cpan:PHAYLON';
11 }
12  
13 1 ▶use Params::Classify 0.013 qw( is_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Sub::Install 0.925 qw( install_sub );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use IO::All 0.41 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use B::Hooks::EndOfScope 0.09;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 $Carp::Internal{ +__PACKAGE__ }++;
22  
23  
24  
25 1 ▶sub install {
Subroutine install: called CC=7 SCAR=21.3
Pod documented
26 1 my ($class, %args) = @_;
27 1 my $target = $args{into};
28 1 my $options = $args{options};
29 1 ▶ $options = { -import => $options }
Branch: 1 branch
BranchTrueFalseTotal
if rand $options 0 1 1
30 if is_ref $options, 'ARRAY';
31 1 ▶ $options = {}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options 1 0 1
32 unless defined $options;
33 1 ▶ croak qq{Options for $class have to be in array or hash ref}
Branch: 1 branch
BranchTrueFalseTotal
unless rand $options 0 1 1
34 unless is_ref $options, 'HASH';
35 $options->{ -import } = []
36 1 ▶ unless defined $options->{ -import };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options->{"-import"} 1 0 1
37 croak qq{Option -import for $class has to be array ref}
38 1 ▶ unless is_ref $options->{ -import }, 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless rand $options->{"-import"} 0 1 1
39 1 my $name = $options->{ -as };
40 1 ▶ $name = 'io'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 1 0 1
41 unless defined $name;
42 install_sub {
43 into => $target,
44 as => $name,
45 code => IO::All
46 1 ->generate_constructor(@{ $options->{ -import } }),
47 };
48 0 ▶ on_scope_end {
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 namespace::clean->clean_subroutines($name);
50 0 };
51 }
52  
53  
54 1 1;
55  
56  
57  
58 =pod
59  
60 =head1 NAME
61  
62 Syntax::Feature::Io - Provides IO::All
63  
64 =head1 VERSION
65  
66 version 0.001
67  
68 =head1 SYNOPSIS
69  
70 use syntax qw( io );
71  
72 my @own_lines = io(__FILE__)->getlines;
73  
74 =head1 DESCRIPTION
75  
76 This is a syntax feature extension for L<syntax> providing L<IO::All>.
77  
78 Not much additional use is provided, besides much easier access if you are
79 already using L<syntax> in one way or another.
80  
81 =head1 METHODS
82  
83 =head2 install
84  
85 $class->install( %arguments )
86  
87 Used by L<syntax> to install the extension in the requesting namespace.
88 Only the arguments C<into> and C<options> are recognized.
89  
90 =head1 OPTIONS
91  
92 =head2 -import
93  
94 use syntax io => { -import => [-strict] };
95  
96 You can use this option to pass import flags to L<IO::All>. Since this is
97 the option you'll most likely use, if any, you can skip the hash reference
98 and provide the import list directly if you wish:
99  
100 use syntax io => [-strict];
101  
102 Please see L<IO::All/USAGE> for documentation on the import arguments.
103  
104 =head2 -as
105  
106 use syntax io => { -as => 'IO' };
107  
108 my @own_lines = IO(__FILE)->getlines;
109  
110 Set the name of the import.
111  
112 =head1 SEE ALSO
113  
114 =over
115  
116 =item * L<IO::All>
117  
118 =item * L<syntax>
119  
120 =back
121  
122 =head1 BUGS
123  
124 Please report any bugs or feature requests to bug-syntax-feature-io@rt.cpan.org or through the web interface at:
125 http://rt.cpan.org/Public/Dist/Display.html?Name=Syntax-Feature-Io
126  
127 =head1 AUTHOR
128  
129 Robert 'phaylon' Sedlacek <rs@474.at>
130  
131 =head1 COPYRIGHT AND LICENSE
132  
133 This software is copyright (c) 2011 by Robert 'phaylon' Sedlacek.
134  
135 This is free software; you can redistribute it and/or modify it under
136 the same terms as the Perl 5 programming language system itself.
137  
138 =cut
139  
140  
141 __END__
↑ Summary