From: Will Budic Date: Wed, 26 Mar 2025 02:56:02 +0000 (+1100) Subject: PluginBase implemented for modern Perl. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=3362542157da20cffa42b3600e5d64ef3c0524bb;p=PerlCNF.git PluginBase implemented for modern Perl. --- diff --git a/system/modules/DataProcessorPlugin.pm b/system/modules/DataProcessorPlugin.pm index d7ed32e..9fa0523 100644 --- a/system/modules/DataProcessorPlugin.pm +++ b/system/modules/DataProcessorPlugin.pm @@ -1,15 +1,6 @@ package DataProcessorPlugin; - -use strict; -use warnings; no warnings qw(experimental::signatures); - -use feature qw(signatures); -use Scalar::Util qw(looks_like_number); -use Clone qw(clone); +use PluginBase; use Date::Manip; -use Syntax::Keyword::Try; -use Exception::Class ('PluginException'); - use constant VERSION => '1.0'; sub new ($class, $plugin){ diff --git a/system/modules/DataProcessorWorldCitiesPlugin.pm b/system/modules/DataProcessorWorldCitiesPlugin.pm index a6c3caf..52b1aa9 100644 --- a/system/modules/DataProcessorWorldCitiesPlugin.pm +++ b/system/modules/DataProcessorWorldCitiesPlugin.pm @@ -1,11 +1,5 @@ package DataProcessorWorldCitiesPlugin; - -use strict; -use warnings; no warnings "once"; - -use feature qw(signatures); -use Scalar::Util qw(looks_like_number); - +use PluginBase; # @Deprecated Plugin not needed anymore in script. sub new ($class,$plugin){ return bless {}, $class diff --git a/system/modules/DatabaseCentralPlugin.pm b/system/modules/DatabaseCentralPlugin.pm index 6e9b32b..b609cd6 100644 --- a/system/modules/DatabaseCentralPlugin.pm +++ b/system/modules/DatabaseCentralPlugin.pm @@ -3,22 +3,15 @@ # It also from script provided values to convert as data to basic CNF value types. Which can be meta directives. # This operate the premise of an column mapping functionality also, as a mapping via the CNF TREE instruction. # For speed direct here direct array referencing in a modal automation algorithmic approach is used. -# It implements also atomic's heavily like CNFData table header and CNFMeta for varios possible operations. +# It implements also atomic's heavily like CNFData table header and CNFMeta for various possible operations. ### package DatabaseCentralPlugin; - -use strict; -use warnings; no warnings qw(experimental::signatures); no warnings 'once'; - -use feature qw(signatures); +use PluginBase; +use Exception::Class ('DBCentralPluginException'); use Time::Piece; use DBI; -use Syntax::Keyword::Try; -use Exception::Class ('DBCentralPluginException'); -use Clone qw(clone); use Date::Manip; -use Scalar::Util qw(looks_like_number); require CNFDateTime; require CNFMeta; diff --git a/system/modules/GenericInstructionHandler.pm b/system/modules/GenericInstructionHandler.pm index 20e1b20..504b48c 100644 --- a/system/modules/GenericInstructionHandler.pm +++ b/system/modules/GenericInstructionHandler.pm @@ -1,8 +1,5 @@ package GenericInstructionHandler; - -use strict; -use warnings; no warnings qw(experimental::signatures); -use feature qw(signatures); +use PluginBase; sub new {my ($class, $args) = @_; bless $args, $class; diff --git a/system/modules/HTMLIndexProcessorPlugin.pm b/system/modules/HTMLIndexProcessorPlugin.pm index 95969f7..147d749 100644 --- a/system/modules/HTMLIndexProcessorPlugin.pm +++ b/system/modules/HTMLIndexProcessorPlugin.pm @@ -1,19 +1,12 @@ package HTMLIndexProcessorPlugin; - -use strict; -use warnings; -no warnings qw(experimental::signatures); -use Syntax::Keyword::Try; +use PluginBase; use Exception::Class ('HTMLIndexProcessorPluginException'); -use feature qw(signatures); -use Scalar::Util qw(looks_like_number); -use Clone qw(clone); + use CGI; use CGI::Session '-ip_match'; use constant VERSION => '1.0'; -our $TAB = ' 'x4; sub new ($class, $plugin){ my $settings; @@ -32,7 +25,8 @@ sub convert ($self, $parser, $property) { my $cgi_action = $cgi-> param('action'); my $cgi_doc = $cgi-> param('doc'); my $tree = $parser-> anon($property); - die "Tree property '$property' is not available!" if(!$tree or ref($tree) ne 'CNFNode'); + die "Tree property '$property' is not available! Parser
 ->\n".dumpParser($parser)."\n
\n" + if(!$tree or ref($tree) ne 'CNFNode'); try{ @@ -104,10 +98,18 @@ try{ } $parser->data()->{$property} = \$buffer; }catch($e){ - HTMLIndexProcessorPluginException->throw(error=>$e ,show_trace=>1); + HTMLIndexProcessorPluginException->throw(error=>$e, show_trace=>1); } } -# + +sub dumpParser($parser){ + my $ret = $parser ->writeOut(); + $ret =~ s//</g; + return $ret +} + +### sub loadDocument($parser, $doc) { my $slurp = do { open my $fh, '<:encoding(UTF-8)', $doc or HTMLIndexProcessorPluginException->throw("Document not avaliable: $doc"); diff --git a/system/modules/HTMLProcessorPlugin.pm b/system/modules/HTMLProcessorPlugin.pm index 062d80c..e1354ef 100644 --- a/system/modules/HTMLProcessorPlugin.pm +++ b/system/modules/HTMLProcessorPlugin.pm @@ -1,16 +1,10 @@ ### -# HTML converter Plugin from PerlCNF to HTML from TREE instucted properties. +# HTML converter Plugin from PerlCNF to HTML from TREE instructed properties. # Processing of these is placed in the data parsers data. ### package HTMLProcessorPlugin; - -use strict; -use warnings; -use Syntax::Keyword::Try; +use PluginBase; use Exception::Class ('HTMLProcessorPluginException'); -use feature qw(signatures); -use Scalar::Util qw(looks_like_number); -use Clone qw(clone); use constant VERSION => '1.0'; diff --git a/system/modules/MarkdownPlugin.pm b/system/modules/MarkdownPlugin.pm index b32acc6..f37c8e2 100644 --- a/system/modules/MarkdownPlugin.pm +++ b/system/modules/MarkdownPlugin.pm @@ -4,19 +4,12 @@ # Processing of these is placed in the data parsers data. # package MarkdownPlugin; - -use strict; -use warnings; -no warnings qw(experimental::signatures); -use Syntax::Keyword::Try; +use PluginBase; use Exception::Class ('MarkdownPluginException'); -use feature qw(signatures); -use Clone qw(clone); ##no critic ControlStructures::ProhibitMutatingListFunctions use constant VERSION => '1.1'; -our $TAB = ' 'x4; ### # Constances for CSS CNF tag parts. See end of this file for package internal provided defaults CSS. @@ -55,12 +48,12 @@ try{ $script = $item->{val}; $escaped = $item->{ins} eq 'ESCAPED' }elsif($script !~ /\n/ and -e $script ){ - my $file = $parser->anon($property); - $script = do { + my $file = $parser->anon($property); + $script = do { open my $fh, '<:encoding(UTF-8)', $script or MarkdownPluginException->throw("File not available: $script"); local $/; <$fh>; - }; + }; } if($escaped){ $script =~ s/\\import(':5.36'); + feature->import('signatures'); + warnings->import; + warnings->unimport('once'); + strict->import; + Syntax::Keyword::Try->import; + Module::Load->import; + Carp->import('confess'); + Exception::Class->import('PluginException'); + + + my $caller = caller(0); + + do { + no strict 'refs'; + *{"$caller\:\:clone"} = *{"Clone\:\:clone"}; + *{"$caller\:\:looks_like_number"} = *{"Scalar\:\:Util\:\:looks_like_number"}; + }; + + +} + + + +1; + +=begin copyright +Programed by : Will Budić +EContactHash : 990MWWLWM8C2MI8K (https://github.com/wbudic/EContactHash.md) +Source : git clone git://lifelog.hopto.org/PerlCNF + : https://github.com/wbudic/PerlCNF.git +Documentation : Specifications_For_CNF_ReadMe.md + This source file is copied and usually placed in a local directory, outside of its repository project. + So it could not be the actual or current version, can vary or has been modified for what ever purpose in another project. + Please leave source of origin in this file for future references. +Open Source Code License -> https://github.com/wbudic/PerlCNF/blob/master/ISC_License.md +=cut copyright \ No newline at end of file diff --git a/tests/testHTMLConversion.pl b/tests/testHTMLConversion.pl index a97876b..f9d92bc 100644 --- a/tests/testHTMLConversion.pl +++ b/tests/testHTMLConversion.pl @@ -54,6 +54,8 @@ use Syntax::Keyword::Try; try { ]row] >>)); + + my $plugin = HTMLProcessorPlugin -> new({Language=>'English',DateFormat=>'AU'}) -> convert($parser, 'test1'); my $html = $parser->data()->{'test1'}; my $tree = $parser->anon('test1');