| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Config::MySQL::Writer; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 3339 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 90 |  | 
| 4 | 2 |  |  | 2 |  | 12 | use strict; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 79 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 2 |  |  | 2 |  | 11 | use base 'Config::INI::Writer'; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 1957 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 NAME | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | Config::MySQL::Writer - Write MySQL-style configuration files | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 VERSION | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | Version 0.01 | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | =cut | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | our $VERSION = '0.02'; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | If C<$config> contains | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | { | 
| 25 |  |  |  |  |  |  | 'mysqld' => { | 
| 26 |  |  |  |  |  |  | 'datadir'      => '/var/lib/mysql', | 
| 27 |  |  |  |  |  |  | 'skip-locking' => undef, | 
| 28 |  |  |  |  |  |  | }, | 
| 29 |  |  |  |  |  |  | 'mysqldump' => { | 
| 30 |  |  |  |  |  |  | 'quick'              => undef, | 
| 31 |  |  |  |  |  |  | 'max_allowed_packet' => '16M', | 
| 32 |  |  |  |  |  |  | }, | 
| 33 |  |  |  |  |  |  | '_' => { | 
| 34 |  |  |  |  |  |  | '!include' => [ | 
| 35 |  |  |  |  |  |  | '/etc/my_extra.cnf', | 
| 36 |  |  |  |  |  |  | '/etc/my_other.cnf', | 
| 37 |  |  |  |  |  |  | ], | 
| 38 |  |  |  |  |  |  | '!includedir' => [ | 
| 39 |  |  |  |  |  |  | '/etc/my.cnf.d', | 
| 40 |  |  |  |  |  |  | ], | 
| 41 |  |  |  |  |  |  | }, | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | Then when your program contains | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | my $config = Config::MySQL::Writer->write_file( $config, 'my.cnf' ); | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | F will contain | 
| 49 |  |  |  |  |  |  | !include /etc/my_extra.cnf | 
| 50 |  |  |  |  |  |  | !include /etc/my_other.cnf | 
| 51 |  |  |  |  |  |  | !includedir /etc/my.cnf.d | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | [mysqld] | 
| 54 |  |  |  |  |  |  | datadir=/var/lib/mysql | 
| 55 |  |  |  |  |  |  | skip-locking | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | [mysqldump] | 
| 58 |  |  |  |  |  |  | quick | 
| 59 |  |  |  |  |  |  | max_allowed_packet = 16M | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | This module extends L to support writing | 
| 64 |  |  |  |  |  |  | MySQL-style configuration files.  Although deceptively similar to | 
| 65 |  |  |  |  |  |  | standard C<.INI> files, they can include bare boolean options with no | 
| 66 |  |  |  |  |  |  | value assignment and additional features like C and C. | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head1 METHODS FOR WRITING CONFIG | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =head2 write_file, write_string, and write_handle | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | See L for usage | 
| 73 |  |  |  |  |  |  | details. | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | =head1 OVERRIDDEN METHODS | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =head2 stringify_value_assignment | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | Copes with MySQL-style include directives and boolean properties that have no | 
| 80 |  |  |  |  |  |  | value assignment | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =cut | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | sub stringify_value_assignment { | 
| 85 | 12 |  |  | 12 | 1 | 238540 | my ( $self, $name, $value ) = @_; | 
| 86 | 12 | 100 |  |  |  | 45 | return "$name\n" unless defined $value; | 
| 87 | 9 | 100 | 66 |  |  | 134 | if ( $name =~ /^!include(?:dir)?$/ && ref $value eq 'ARRAY' ) { | 
| 88 | 3 |  |  |  |  | 28 | return $name . ' ' . join( "\n$name ", @$value ) . "\n"; | 
| 89 |  |  |  |  |  |  | } else { | 
| 90 | 6 |  |  |  |  | 33 | return $self->SUPER::stringify_value_assignment( $name, $value ); | 
| 91 |  |  |  |  |  |  | } | 
| 92 |  |  |  |  |  |  | } | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =over 4 | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =item L | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | =item L | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =item L | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =back | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =head1 AUTHOR | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | Iain Arnell, C<<  >> | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | =head1 BUGS | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | Please report any bugs or feature requests to C, or through | 
| 113 |  |  |  |  |  |  | the web interface at L.  I will be notified, and then you'll | 
| 114 |  |  |  |  |  |  | automatically be notified of progress on your bug as I make changes. | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =head1 SUPPORT | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | perldoc Config::MySQL::Writer | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | You can also look for information at: | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =over 4 | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =item * RT: CPAN's request tracker | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | L | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | L | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | L | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =item * Search CPAN | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | L | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =back | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =head1 ACKNOWLEDGEMENTS | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | Thanks to Ricardo Signes for Config-INI. | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | Copyright 2010 Iain Arnell. | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 156 |  |  |  |  |  |  | under the terms of either: the GNU General Public License as published | 
| 157 |  |  |  |  |  |  | by the Free Software Foundation; or the Artistic License. | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | See http://dev.perl.org/licenses/ for more information. | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | =cut | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | 1;    # End of Config::MySQL::Writer |