Skip to content

Commit

Permalink
Item14237: Removing 'pluggable' sugar from the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
vrurg committed May 12, 2018
1 parent 4a6e541 commit b1b1e3e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 38 deletions.
3 changes: 3 additions & 0 deletions EmptyExtension/lib/Foswiki/Extension/Empty.pm
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ callbackHandler 'Foswiki::App::handleRequestException', sub {
#PluggableMethods
---+++ Method overriding
*NOTE* =pluggable= sugar has been deprecated. Any method of any class could be
overriden now. This section must be edited to reflect the change.
A core class may declare some of its methods as pluggable – i.e. let an
extension to have _before_, _around_, and _after_ handlers for the method –
similar (but not the same) to analogous functionality of =[[CPAN:Moo][Moo]]= or
Expand Down
4 changes: 2 additions & 2 deletions UnitTestContrib/test/unit/ExtensionsTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ has allowFlowControl => (
default => 0,
);

pluggable testPluggableMethod => sub {
sub testPluggableMethod {
my $this = shift;

return wantarray
? ( qw(This is a sample return array), @_ )
: "This is a sample string {" . join( "}{", @_ ) . "}";
};
}

package ExtensionsTests;

Expand Down
49 changes: 25 additions & 24 deletions core/lib/Foswiki/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ the =expandAll()= method.
=cut

pluggable read => sub {
sub read {
my $this = shift;
my %params = @_;

Expand Down Expand Up @@ -1078,7 +1078,7 @@ pluggable read => sub {
$data->{ConfigurationFinished} = 1;

return $data;
};
}

=begin TML
Expand All @@ -1102,7 +1102,7 @@ legacy code. Will be removed in release.
=cut

pluggable readLSCStart => sub {
sub readLSCStart {
my $this = shift;
my %params = @_;

Expand Down Expand Up @@ -1205,7 +1205,7 @@ pluggable readLSCStart => sub {
$this->_lscRecPos(0);

return 1;
};
}

=begin TML
Expand All @@ -1219,7 +1219,7 @@ was an attempt to read past last record.
=cut

pluggable readLSCRecord => sub {
sub readLSCRecord {
my $this = shift;
my %params = @_;

Expand All @@ -1230,7 +1230,7 @@ pluggable readLSCRecord => sub {
return ( 1, undef, undef ) if $curPos >= scalar( @{ $this->_lscRecords } );

return ( 1, @{ $this->_lscRecords->[$curPos] } );
};
}

=begin TML
Expand All @@ -1242,15 +1242,15 @@ Returns _true_ if everything is ok.
=cut

pluggable readLSCFinalize => sub {
sub readLSCFinalize {
my $this = shift;

$this->_clear_lscFileObj;
$this->_clear_lscRecords;
$this->_lscRecPos(0);

return 1;
};
}

=begin TML
Expand Down Expand Up @@ -1289,7 +1289,7 @@ useful for a extension.
=cut

pluggable readLSC => sub {
sub readLSC {
my $this = shift;
my %params = @_;

Expand All @@ -1314,7 +1314,7 @@ pluggable readLSC => sub {
my $finalRc = $this->readLSCFinalize( data => $cfgData );

return ( $rc && $finalRc );
};
}

=begin TML
Expand Down Expand Up @@ -1356,7 +1356,7 @@ Initiates LSC writing.
=cut

pluggable writeLSCStart => sub {
sub writeLSCStart {
my $this = shift;
my %params = @_;

Expand All @@ -1369,9 +1369,10 @@ pluggable writeLSCStart => sub {
path => $lscFile,
autoWrite => 1,
autoCreate => 1,
content => '',
)
);
};
}

=begin TML
Expand All @@ -1388,7 +1389,7 @@ This method is for low-level writing of a single key/value pair into LSC.
=cut

pluggable writeLSCRecord => sub {
sub writeLSCRecord {
my $this = shift;
my %params = @_;

Expand All @@ -1404,9 +1405,9 @@ pluggable writeLSCRecord => sub {
{
key => $params{key},
value => $params{value},
comment => $params{comment},
comment => $comment,
};
};
}

=begin TML
Expand All @@ -1420,7 +1421,7 @@ No parameters are used.
=cut

pluggable writeLSCFinalize => sub {
sub writeLSCFinalize {
my $this = shift;
my %params = @_;

Expand Down Expand Up @@ -1449,7 +1450,7 @@ pluggable writeLSCFinalize => sub {
$_lscFileObj->autoWrite(1);
$this->_clear_lscFileObj;
$this->_clear_lscRecords;
};
}

=begin TML
Expand Down Expand Up @@ -1487,7 +1488,7 @@ All user defined parameters are handled similar to the
=cut

pluggable writeLSC => sub {
sub writeLSC {
my $this = shift;
my %params = @_;

Expand Down Expand Up @@ -1516,7 +1517,7 @@ pluggable writeLSC => sub {
my $comment = $this->lscHeader . "\n";
foreach my $cfKey (@cfgKeys) {
unless ( $specKeys{$cfKey} ) {
$comment .= "This key is not defined in a spec file\n";
$comment .= "Key $cfKey is not defined in a spec file";

#say STDERR "Key $cfKey is not defined in specs";
}
Expand Down Expand Up @@ -1547,7 +1548,7 @@ pluggable writeLSC => sub {

$this->writeLSCFinalize( data => $cfgData, );
return;
};
}

=begin TML
Expand Down Expand Up @@ -1738,7 +1739,7 @@ Here we include *undef*...
=cut

pluggable expandStr => sub {
sub expandStr {
my $this = shift;
my %params = @_;

Expand Down Expand Up @@ -1780,7 +1781,7 @@ pluggable expandStr => sub {

return (
wantarray ? @estrs : ( @estrs > 1 || $isList ? [@estrs] : $estrs[0] ) );
};
}

=begin TML
---+++ ObjectMethod bootstrapSystemSettings()
Expand Down Expand Up @@ -3575,7 +3576,7 @@ See [[System.SpecFileFormat]],
=cut

pluggable spec => sub {
sub spec {
my $this = shift;
my %params = @_;

Expand Down Expand Up @@ -3650,7 +3651,7 @@ pluggable spec => sub {

$e->rethrow;
};
};
}

=begin TML
Expand Down
8 changes: 4 additions & 4 deletions core/lib/Foswiki/Config/Spec/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ sub setLocalizableAttributes {
return qw( data parsed localData );
}

pluggable guessFormat => sub {
sub guessFormat {
my $this = shift;

# If shebang is defined then it unambiguously defines spec format.
Expand Down Expand Up @@ -103,7 +103,7 @@ pluggable guessFormat => sub {
}

return 'data';
};
}

sub validCache {
my $this = shift;
Expand All @@ -120,7 +120,7 @@ sub validCache {
&& ( !defined $cf->fileSize || ( $cf->fileSize == $fstat->size ) );
}

pluggable parse => sub {
sub parse {
my $this = shift;

my $dataObj = tied %{ $this->data };
Expand Down Expand Up @@ -182,7 +182,7 @@ pluggable parse => sub {
}

return $dataObj;
};
}

sub refreshCache {
my $this = shift;
Expand Down
9 changes: 1 addition & 8 deletions core/lib/Foswiki/IncludeHandlers/doc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,9 @@ sub INCLUDE {
# Starting a non-suppressed method section.
$suppressedMethodLevel = 0;

my $pluggable = "";
if ( $methodText =~ /^\W*(?<methodName>\w+)\b/ ) {
my $methodName = $+{methodName};

# TODO Replace word Pluggable with a link to
# extensions documentaion when ready.
$pluggable =
$Foswiki::ExtManager::pluggables{$class}
{$methodName} ? "Pluggable " : "";

# SMELL methodName with underscores generates
# bad anchor name which is getting split by the
# first _. Should anchor name handling be fixed?
Expand All @@ -262,7 +255,7 @@ sub INCLUDE {
. "\n";
}
$pod .=
"\n$anchor$secDef =${pluggable}[[$methodAccess$methodType]]= ==$methodTextEncoded==\n";
"\n$anchor$secDef =[[$methodAccess$methodType]]= ==$methodTextEncoded==\n";
}
}
else { # Just plain simple heading.
Expand Down

0 comments on commit b1b1e3e

Please sign in to comment.