| Perl-Dist-WiX documentation | Contained in the Perl-Dist-WiX distribution. |
Perl::Dist::WiX::Fragment::Environment - A <Fragment> tag with environment variable handling.
This document describes Perl::Dist::WiX::Fragment::Environment version 1.500.
my $fragment = Perl::Dist::WiX::Fragment::Environment->new(
id => 'Environment',
);
# If there is only one parameter, it is considered to be the id.
my $fragment2 = Perl::Dist::WiX::Fragment::Environment->new('Environment');
$fragment->add_entry(
id => "Env_STRAWBERRY",
name => 'STRAWBERRY',
value => '1',
action => 'set',
part => 'all',
);
my $count = $fragment->get_entries_count();
This module implements the fragment that adds, deletes, and appends the environment variables required in a distribution.
This class inherits from WiX3::XML::Fragment and shares its API.
The new constructor takes a series of parameters, validates then
and returns a new Perl::Dist::WiX::Fragment::Environment object.
It inherits all the parameters described in the WiX3::XML::Fragment->new() method documentation.
If new has only one parameter, it is considered the ID to use for
the fragment.
$fragment_tag = $fragment_tag->add_entry(...);
The add_entry method creates an <Environment> tag (a
WiX3::XML::Environment (WiX3::XML::Environment) object) and adds it
as a child of the component this fragment contains.
It takes all parameters that WiX3::XML::Environment->new() (new in WiX3::XML::Environment) takes.
$count = $fragment_tag->get_entries_count();
The get_entries_count method returns the number of <Environment> tags
that this fragment contains.
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-Dist-WiX
For other issues, contact the author.
Curtis Jewell <csjewell@cpan.org>
Copyright 2009 - 2010 Curtis Jewell.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
| Perl-Dist-WiX documentation | Contained in the Perl-Dist-WiX distribution. |
package Perl::Dist::WiX::Fragment::Environment;
use 5.010; use Moose; require Perl::Dist::WiX::DirectoryTree; require WiX3::XML::Environment; require WiX3::XML::Component; require WiX3::XML::DirectoryRef; our $VERSION = '1.500'; $VERSION =~ s/_//ms; extends 'WiX3::XML::Fragment'; with 'WiX3::Role::Traceable';
# _component is the (one) component that this fragment contains. # It's easiest just to keep track of it as an attribute # than to have to search for it each time. has _component => ( is => 'bare', isa => 'WiX3::XML::Component', reader => '_get_component', required => 1, ); sub BUILDARGS { my $class = shift; my %args; # Process the arguments. ## no critic(CascadingIfElse) if ( @_ == 1 && !ref $_[0] ) { $args{'id'} = $_[0]; } elsif ( 0 == @_ ) { $args{'id'} = 'Environment'; } elsif ( @_ == 1 && 'HASH' eq ref $_[0] ) { %args = %{ $_[0] }; } elsif ( 0 == @_ % 2 ) { %args = (@_); } else { PDWiX->throw( 'Parameters incorrect (not a hashref, hash, or id) for ::Fragment::Environment' ); } # Default the ID to 'Environment'. my $id; if ( not exists $args{'id'} ) { $id = 'Environment'; } else { $id = $args{'id'}; } # Create the component and attach it to this fragment. my $tag1 = WiX3::XML::Component->new( id => $id ); return { id => $id, _component => $tag1, }; } ## end sub BUILDARGS sub BUILD { my $self = shift; # Add the component to a reference to the root directory. my $tag2 = WiX3::XML::DirectoryRef->new( directory_object => Perl::Dist::WiX::DirectoryTree->instance()->get_root(), ); $tag2->add_child_tag( $self->_get_component() ); # Add the root directory as a child of this fragment. $self->add_child_tag($tag2); $self->trace_line( 3, "Creating environment fragment.\n" ); return; } ## end sub BUILD
sub add_entry { my $self = shift; $self->_get_component() ->add_child_tag( WiX3::XML::Environment->new(@_) ); return $self; }
sub get_entries_count { my $self = shift; return $self->_get_component()->count_child_tags(); } # The fragment is already generated. No need to regenerate. sub _regenerate { ## no critic(ProhibitUnusedPrivateSubroutines) return; } # No duplicates will be here to check. sub _check_duplicates { ## no critic(ProhibitUnusedPrivateSubroutines) return; } no Moose; __PACKAGE__->meta->make_immutable; 1; __END__