WiX3/XML/Feature.pm untested

filter: Statementstmt 0.0% 0 / 70 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 85 CC 2 SCAR 9.8
CC
2
Cov
0%
as_string
6.0
get_namespace
2.0
BEGIN
2.0
CRAP 2.7
1 package WiX3::XML::Feature;
2  
3 use 5.008003;
4  
5 # Must be done before Moose, or it won't get picked up.
6 use metaclass (
7 metaclass => 'Moose::Meta::Class',
8 error_class => 'WiX3::Util::Error',
9 );
10 use Moose 2;
11 use Params::Util qw( _IDENTIFIER _STRING );
12 use WiX3::Types qw( YesNoType );
13 use MooseX::Types::Moose qw( Str Int Maybe ArrayRef );
14 use WiX3::XML::TagTypes qw( FeatureChildTag );
15 use WiX3::Util::StrictConstructor;
16  
17 our $VERSION = '0.011';
18  
19 # http://wix.sourceforge.net/manual-wix3/wix_xsd_feature.htm
20  
21 with 'WiX3::XML::Role::TagAllowsChildTags';
22  
23 # Child tags allowed:
24 # Component, ComponentGroupRef, ComponentRef, Condition, Feature,
25 # FeatureGroupRef, FeatureRef, MergeRef
26  
27 ## FeatureChildTag allows Component, ComponentRef, Feature, FeatureRef,
28 ## and MergeRef at the moment.
29  
30 has '+child_tags' => ( isa => ArrayRef [FeatureChildTag] );
31  
32 #####################################################################
33 # Accessors:
34 # see new.
35  
36 has id => (
37 is => 'ro',
38 isa => Str,
39 reader => 'get_id',
40 required => 1,
41 );
42  
43 has _absent => (
44 is => 'ro',
45 isa => Maybe [Str], # enum
46 reader => '_get_absent',
47 init_arg => 'absent',
48 default => undef,
49 );
50  
51 has _allow_advertise => (
52 is => 'ro',
53 isa => Maybe [Str],
54 reader => '_get_allow_advertise',
55 init_arg => 'allow_advertise',
56 default => undef,
57 );
58  
59  
60 has _configurable_directory => (
61 is => 'ro',
62 isa => Maybe [Str],
63 reader => '_get_configurable_directory',
64 init_arg => 'configurable_directory',
65 default => undef,
66 );
67  
68 has _description => (
69 is => 'ro',
70 isa => Maybe [Str],
71 reader => '_get_description',
72 init_arg => 'description',
73 default => undef,
74 );
75  
76 has _display => (
77 is => 'ro',
78 isa => Maybe [Str],
79 reader => '_get_display',
80 init_arg => 'display',
81 default => undef,
82 );
83  
84 has _install_default => (
85 is => 'ro',
86 isa => Maybe [Str],
87 reader => '_get_install_default',
88 init_arg => 'install_default',
89 default => undef,
90 );
91  
92 has _level => (
93 is => 'ro',
94 isa => Maybe [Int],
95 reader => '_get_level',
96 init_arg => 'level',
97 default => undef,
98 );
99  
100 has _title => (
101 is => 'ro',
102 isa => Maybe [Str],
103 reader => '_get_title',
104 init_arg => 'title',
105 default => undef,
106 );
107  
108 has _typical_default => (
109 is => 'ro',
110 isa => Maybe [Str],
111 reader => '_get_typical_default',
112 init_arg => '_typical_default',
113 default => undef,
114 );
115  
116 #####################################################################
117 # Main Methods
118  
119 ########################################
120 # as_string
121 # Parameters:
122 # None.
123 # Returns:
124 # String containing <Fragment> tag defined by this object.
125  
126 sub as_string {
127 my $self = shift;
128  
129 my $children = $self->has_child_tags();
130 my $tags;
131  
132 # Print tag.
133 $tags .= $self->print_attribute( 'Id', 'Feat_' . $self->get_id() );
134 $tags .= $self->print_attribute( 'Absent', $self->_get_absent() );
135 $tags .=
136 $self->print_attribute( 'AllowAdvertise',
137 $self->_get_allow_advertise() );
138 $tags .=
139 $self->print_attribute( 'ConfigurableDirectory',
140 $self->_get_configurable_directory() );
141 $tags .=
142 $self->print_attribute( 'Description', $self->_get_description() );
143 $tags .= $self->print_attribute( 'Display', $self->_get_display() );
144 $tags .=
145 $self->print_attribute( 'InstallDefault',
146 $self->_get_install_default() );
147 $tags .= $self->print_attribute( 'Level', $self->_get_level() );
148 $tags .= $self->print_attribute( 'Title', $self->_get_title() );
149 $tags .=
150 $self->print_attribute( 'TypicalDefault',
151 $self->_get_typical_default() );
152  
153 if ($children) {
154 my $child_string = $self->as_string_children();
155 return qq{<Feature$tags>\n$child_string\n</Feature>\n};
156 } else {
157 return qq{<Feature$tags />\n};
158 }
159 } ## end sub as_string
160  
161 sub get_namespace {
162 return q{xmlns='http://schemas.microsoft.com/wix/2006/wi'};
163 }
164  
165 no Moose;
166 __PACKAGE__->meta->make_immutable;
167  
168 1;
169  
170 __END__