This file is indexed.

/usr/share/perl5/Lire/Config/Plugin.pm is in lire 2:2.1.1-2.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
package Lire::Config::Plugin;

use strict;

use base qw/Lire::Config::Dictionary/;

use Lire::Config;
use Lire::Config::RecordSpec;
use Lire::Config::Dictionary;

use Carp;

=pod

=head1 NAME

Lire::Config::Plugin - Value object for plugin configuration.

=head1 SYNOPSIS

  use Lire::Config::Plugin;

=head1 DESCRIPTION

This configuration object hold the name of a selected plugin as
well as its options.

=cut

sub new {
    my $self = shift->SUPER::new( @_ );

    my %args = @_;

    $self->set_plugin( $args{'value'} )
      unless ( exists $self->{'_plugin'} && ! defined $args{'value'} );

    return $self;
}

=pod

=head2 get_plugin()

Returns the currently selected plugin.

=cut

sub get_plugin {
    return $_[0]{'_plugin'};
}

=pod

=head2 set_plugin( $plugin )

Changes the selected plugin. If the selected plugin is changed, a
new property set will be created from the plugin's defined properties.

=cut

sub set_plugin {
    my ( $self, $plugin ) = @_;

    my $old_plugin = $self->{'_plugin'};
    $self->{'_plugin'} = $plugin;
    my $spec = $self->get_properties_spec();
    $self->{'_properties'} = $spec->instance()
      unless ( defined $plugin && defined $old_plugin
               && $plugin eq $old_plugin );

    return;
}

=pod

=head2 get_properties_spec()

Returns the TypeSpec that is used to specify the plugin's properties.
This method will return an empty RecordSpec when the plugin didn't
define any properties. One can also use the has_properties() method to
check if the Plugin defined configuration properties.

=cut

sub get_properties_spec {
    my $self = $_[0];

    return $self->spec()->get_properties_spec( $self->{'_plugin'} );
}

=pod

=head2 has_properties()

Returns a boolean value indicating whether the current plugin is configurable.

=cut

sub has_properties {
    return  $_[0]->get_properties_spec()->components() > 0;
}

=pod

=head2 get_properties()

Returns the Lire::Config::Dictionary object which hold the
plugin configuration.

=cut

sub get_properties {
    return $_[0]{'_properties'};
}

=pod

=head2 as_value()

Returns an hash reference with two keys : 'plugin' which contains
the selected plugin and 'properties' which is an hash reference containing
the plugin's properties.

=cut

sub as_value {
    return { 'plugin' => $_[0]->{'_plugin'},
             'properties' => $_[0]->{'_properties'}->as_value() };
}

=pod

=head2 get( $name )

Delegates to the Dictionary which contains the plugin's properties.

=cut

sub get {
    return shift->{'_properties'}->get( @_ );
}

=pod

=head2 set( $name, $value )

Delegates to the Dictionary which contains the plugin's properties.

=cut

sub set {
    return shift->{'_properties'}->set( @_ );
}

=pod

=head2 is_set( $name )

Delegates to the Dictionary which contains the plugin's properties.

=cut

sub is_set {
    return shift->{'_properties'}->is_set( @_ );
}

sub is_equals {
    my ( $self, $other ) = @_;

    return 0 unless $self->Lire::Config::Value::is_equals( $other );

    no warnings 'uninitialized';
    return 0 unless $self->{'_plugin'} eq $other->{'_plugin'};

    return $self->{'_properties'}->is_equals( $other->{'_properties'} );
}

sub is_valid {
    my $self = $_[0];

    return ( $self->spec()->is_valid( $self->{'_plugin'} )
             && $self->get_properties()->is_valid() );
}

sub save_xml {
    my ( $self, $fh, $indent, $xmlns ) = @_;

    $indent ||= 0;
    $xmlns ||= '';
    return unless ( defined $self->{'_plugin'} );
    return if $self->is_default() || $self->spec()->obsolete();

    print $fh '  ' x $indent, "<${xmlns}param name=\"", $self->name(), '" value="',
      $self->{'_plugin'}, '">', "\n";
    my $spec = $self->get_properties_spec();
    foreach my $comp ( $spec->components() ) {
        $self->get( $comp->name() )->save_xml( $fh, $indent + 1, $xmlns );
    }
    print $fh '  ' x $indent, "</${xmlns}param>\n";
}

1;