Zoom-Meeting

 view release on metacpan or  search on metacpan

local/lib/perl5/Config/INI/Writer.pm  view on Meta::CPAN


  return $value;
}

#pod =head2 stringify_section_header
#pod
#pod   my $string = $writer->stringify_section_header($section_name);
#pod
#pod This method returns the string (a line) that represents the given section name.
#pod Basically, this returns:
#pod
#pod   [section_name]
#pod
#pod =cut

sub stringify_section_header {
  my ($self, $section_name) = @_;

  my $output  = '';
     $output .= "\n" if $self->done_sections;
     $output .= "[$section_name]\n";

  return $output;
}

#pod =head2 starting_section
#pod
#pod This method returns the name of the starting section.  If this section appears
#pod first (as it will, when given a hashref as input) and if
#pod C<L</explicit_starting_header>> returns false, its section header can be
#pod omitted.
#pod
#pod =cut

sub starting_section { return '_' }

#pod =head2 explicit_starting_header
#pod
#pod If this method returns true (which it does I<not>, by default), then the
#pod section header for the starting section will be emitted, even if it appears
#pod first.
#pod
#pod =cut

sub explicit_starting_header { 0 }

#pod =head2 new
#pod
#pod
#pod   my $reader = Config::INI::Writer->new;
#pod
#pod This method returns a new writer.  This generally does not need to be called by
#pod anything but the various C<write_*> methods, which create a writer object only
#pod ephemerally.
#pod
#pod =cut

sub new {
  my ($class) = @_;

  my $self = bless { did_section => {} } => $class;

  return $self;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Config::INI::Writer - a subclassable .ini-file emitter

=head1 VERSION

version 0.029

=head1 SYNOPSIS

If C<$hash> contains:

  {
    '_'  => { admin => 'rjbs' },
    rjbs => {
      awesome => 'yes',
      height  => q{5' 10"},
    },
    mj   => {
      awesome => 'totally',
      height  => '23"',
    },
  }

Then when your program contains:

  Config::INI::Writer->write_file($hash, 'family.ini');

F<family.ini> will contains:

  admin = rjbs

  [rjbs]
  awesome = yes
  height = 5' 10"

  [mj]
  awesome = totally
  height = 23"

=head1 DESCRIPTION

Config::INI::Writer is I<yet another> config module implementing I<yet another>
slightly different take on the undeniably easy to read L<".ini" file
format|Config::INI>.  Its default behavior is quite similar to that of
L<Config::Tiny>, on which it is based.

The chief difference is that Config::INI::Writer is designed to be subclassed

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.466 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )