### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### EnvFile - psgconf action class for environment files ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Action::GenerateFile::EnvFile; use strict; use PSGConf::Action::GenerateFile; our @ISA = qw(PSGConf::Action::GenerateFile); ############################################################################### ### generate method ############################################################################### sub generate { my ($self, $fh, $psgconf) = @_; my ($var, $value); foreach $var (sort keys %{$self->{vars}}) { $value = $self->{vars}->{$var}; $value = '"' . $value . '"' if ($self->{quote_values}); print $fh $var; print $fh $self->{seperator}; print $fh $value; print $fh "\n"; } return 1; } ############################################################################### ### constructor ############################################################################### sub new { my ($class, %opts) = @_; $opts{quote_values} = 0 if (!exists($opts{quote_values})); $opts{seperator} = '=' if (!exists($opts{seperator})); return PSGConf::Action::GenerateFile::new($class, %opts); } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Action::GenerateFile::EnvFile - generate environment files =head1 SYNOPSIS use PSGConf::Action::GenerateFile::EnvFile; $psgconf->register_actions( PSGConf::Action::GenerateFile::EnvFile->new( 'name' => '/path/to/file', 'vars' => { 'var1' => 'value1', ... }, ... ), ... ); =head1 DESCRIPTION The B module provides a B action class for generating files containing environment variable definitions. The B class is derived from the B class, but it defines/overrides the following methods: =over 4 =item generate() Generates the environment file. =back In addition to the attributes supported by the B class, the B class supports the following attributes: =over 4 =item I An anonymous hash containing environment variable definitions. =item I A boolean to determine if the values are quoted. Default is false. =item I A string containing the seperator to use between variable and values. Defaults to C<=>. =back =head1 SEE ALSO L L L =cut