📄 extension.pm
字号:
# vim:ts=4 sw=4
# ----------------------------------------------------------------------------------------------------
# Name : ETL::Pequel3::Type::Section::Extension.pm
# Created : 22 June 2006
# Author : Mario Gaffiero (gaffie)
#
# Copyright 1999-2007 Mario Gaffiero.
#
# This file is part of Pequel(TM).
#
# Pequel is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# Pequel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pequel; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ----------------------------------------------------------------------------------------------------
# Modification History
# When Version Who What
# ----------------------------------------------------------------------------------------------------
package ETL::Pequel3::Type::Section::Extension;
require 5.005_62;
use strict;
use warnings;
use ETL::Pequel3::Type::Section;
# ----------------------------------------------------------------------------------------------------
{
package ETL::Pequel3::Type::Section::Extension;
use base qw(ETL::Pequel3::Type::Section::Abstract);
use Class::STL::ClassMembers
Class::STL::ClassMembers::DataMember->new(name => 'target_mem_name', default => 'section_name'),
Class::STL::ClassMembers::DataMember->new(name => 'section_name', default => 'extension'),
Class::STL::ClassMembers::DataMember->new(name => 'item_type', default => 'ETL::Pequel3::Type::Section::Extension::Item'),
Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => "@{[ __PACKAGE__ ]}"),
Class::STL::ClassMembers::DataMember->new(name => 'description', default => "This section is used to declare any required pequel-extension packages. The extension will be loaded and added to the appropriate F<type catalogue>. Set the F<package_name> attribute to the fully qualified package name (eg: C<ETL::Pequel3::Type::DataSet::Apache>).\n\n\nFor detailed instructions in building a I<pequel type extension> please refer to the F<Pequel Programmers Reference> manual.");
use Class::STL::ClassMembers::Constructor;
sub add_item
{
my $self = shift;
$self->SUPER::add_item(@_);
foreach my $i ($self->items()->back())
{
#TODO: eval "@{[ defined($i->lib_path) ? qq{use lib '';} : '' ]}"
#NOTE: this eval needs to happen early (not in prepare) so new names will be available
#when referenced by other sections' add_item();
eval "use @{[ $i->package_name() ]};"; #NOTE: need to 'use' so import() function is called;
$self->err()->trace_msg(10, "@{[ $self->pequel_ref()->pequel_name() ]} -->"
. "Extension:"
. $i->package_name()
. " --> "
. ($@ ? "($@)" : "Loaded OK") # --> TODO:print the version...
);
}
$self->err()->user_error(10256, "$@") if ($@);
return $self;
}
sub prepare
{
my $self = shift;
}
package ETL::Pequel3::Type::Section::Extension::Item;
use base qw(ETL::Pequel3::Type::Section::Item::Abstract);
use Class::STL::ClassMembers;
use Class::STL::ClassMembers::Constructor;
sub new_extra
{
my $self = shift;
$self->attributes()->push_back(
$self->attributes()->factory(name => 'package_name', required => 1),
);
}
}
# ----------------------------------------------------------------------------------------------------
1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -