Zucchini/Config/Create.pm

filter: Statementstmt 91.3% 21 / 23 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 90.6% 29 / 32 CC 3 SCAR 7.2
CC
3
Cov
89%
write_default_config
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Zucchini/Types.pm ↑ Summary
1 package Zucchini::Config::Create;
2 10 $Zucchini::Config::Create::VERSION = '0.0.21';
3 {
4 10 $Zucchini::Config::Create::DIST = 'Zucchini';
5 }
6 # ABSTRACT: write a sample configuration file
7 # vim: ts=8 sts=4 et sw=4 sr sta
8 10 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use strict; # for kwalitee testing
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 10 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶sub write_default_config {
Subroutine write_default_config: called CC=3 SCAR=11.3
Pod documented
14 1 my $self = shift;
15 1 my $filename = shift;
16  
17 1 ▶ if (-e $filename) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $filename) 0 1 1
18 # TODO - copy file to file.TIMESTAMP and create new
19 0 warn "$filename already exists\n";
20 0 return;
21 }
22  
23 # create a filehandle to write to
24 1 my $fh = IO::File->new($filename, 'w');
25  
26 # loop through the __DATA__ for this module
27 # and print it to the filehandle
28 1 ▶ while (my $line = <DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline DATA)) 1 1 2
29 1 print $fh <DATA>;
30 }
31 1 $fh->close;
32 1 close DATA;
33 }
34  
35 10 1;
36  
37 =pod
38  
39 =encoding UTF-8
40  
41 =head1 NAME
42  
43 Zucchini::Config::Create - write a sample configuration file
44  
45 =head1 VERSION
46  
47 version 0.0.21
48  
49 =head1 SYNOPSIS
50  
51 # create a new object
52 $zucchini_cfg_create = Zucchini::Config::Create->new();
53  
54 # write out a default config file
55 $zucchini_cfg_create->write_default_config(
56 file($ENV{HOME}, q{.zucchini})
57 );
58  
59 =head1 DESCRIPTION
60  
61 It's mean to expect people to pluck a configuration file out if thin air.
62  
63 This module's sole purpose is to write out a default .zucchini file to give
64 users a fighting chance.
65  
66 =head1 NAME
67  
68 Zucchini::Config::Create - write a sample configuration file
69  
70 =head1 METHODS
71  
72 =head2 new
73  
74 Creates a new instance of the top-level Zucchini object:
75  
76 # create a new object
77 $zucchini_cfg_create = Zucchini::Config::Create->new();
78  
79 =head2 write_default_config
80  
81 Given a filename, write out the default/sample configuration file. If the file
82 already exists it I<will not> be overwritten.
83  
84 # write out a default config file
85 $zucchini_cfg_create->write_default_config(
86 file($ENV{HOME}, q{.zucchini})
87 );
88  
89 =head1 SAMPLE CONFIGURATION FILE
90  
91 The sample configuration file is supposed to be a reasonable example of how a
92 functioning configuration file should look.
93  
94 You should be able to get up and running with Zucchini by creating the default
95 file, and modifying the following variables:
96 I<source_dir>, I<includes_dir>, I<output_dir>.
97  
98 You might also like to edit some of the values in the C<< <tags> >> section.
99  
100 =head1 SEE ALSO
101  
102 L<Zucchini>,
103 L<Zucchini::Config>
104  
105 =head1 AUTHOR
106  
107 Chisel Wright C<< <chiselwright@users.berlios.de> >>
108  
109 =head1 LICENSE
110  
111 Copyright 2008-2009 by Chisel Wright
112  
113 This program is free software; you can redistribute it and/or modify it under
114 the same terms as Perl itself.
115  
116 See <http://www.perl.com/perl/misc/Artistic.html>
117  
118 =head1 AUTHOR
119  
120 Chisel <chisel@chizography.net>
121  
122 =head1 COPYRIGHT AND LICENSE
123  
124 This software is copyright (c) 2012 by Chisel Wright.
125  
126 This is free software; you can redistribute it and/or modify it under
127 the same terms as the Perl 5 programming language system itself.
128  
129 =cut
130  
131 __DATA__
« Zucchini/Types.pm ↑ Summary