aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ManaTools
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-04-24 11:30:28 +0200
committerAngelo Naselli <anaselli@linux.it>2015-04-24 11:30:28 +0200
commitdc04b6fa29de3d98bdd8ada034ecb69fda0718ec (patch)
tree2876e961aa76a432ee1ce529f051900f5fb13796 /lib/ManaTools
parent71d980359bde6b4b0069e9a4069fb2695f302ea0 (diff)
downloadcolin-keep-dc04b6fa29de3d98bdd8ada034ecb69fda0718ec.tar
colin-keep-dc04b6fa29de3d98bdd8ada034ecb69fda0718ec.tar.gz
colin-keep-dc04b6fa29de3d98bdd8ada034ecb69fda0718ec.tar.bz2
colin-keep-dc04b6fa29de3d98bdd8ada034ecb69fda0718ec.tar.xz
colin-keep-dc04b6fa29de3d98bdd8ada034ecb69fda0718ec.zip
Moved localization object to base class
fixed documentation
Diffstat (limited to 'lib/ManaTools')
-rw-r--r--lib/ManaTools/Module.pm159
1 files changed, 129 insertions, 30 deletions
diff --git a/lib/ManaTools/Module.pm b/lib/ManaTools/Module.pm
index 1e13d92..85abd36 100644
--- a/lib/ManaTools/Module.pm
+++ b/lib/ManaTools/Module.pm
@@ -1,4 +1,6 @@
# vim: set et ts=4 sw=4:
+#
+# Copyright 2013-2015 Angelo Naselli
# Copyright 2012 Steven Tucker
#
# This file is part of ManaTools
@@ -28,18 +30,133 @@ Version 0.01
=cut
-our $VERSION = '1.0.0';
+our $VERSION = '1.0.1';
use yui;
+#=============================================================
+
+=head1 Attributes - Optional constructor parameters
+
+=head2 icon
+
+ icon attribute defines the Module icon, override this
+ attribute by using
+ has '+icon' => (
+ ...
+ )
+ into your module implementation.
+
+=cut
+
+#=============================================================
+has 'icon' => (
+ is => 'rw',
+ isa => 'Str',
+);
+
+#=============================================================
+
+=head2 name
+
+ name attribute defines the Module name, override this
+ attribute by using
+ has '+name' => (
+ ...
+ )
+ into your module implementation.
+
+=cut
+
+#=============================================================
+has 'name' => (
+ is => 'rw',
+ isa => 'Str',
+);
+
+#=============================================================
+
+=head2 launch
+
+ launch attribute defines the Module as external command
+ to be run, pass this attribute to the "create" to set it.
+
+=cut
+
+#=============================================================
+
+has 'launch' => (
+ is => 'rw',
+ isa => 'Str',
+);
+
+has 'button' => (
+ is => 'rw',
+ init_arg => undef,
+);
+
+#=============================================================
+
+=head2 loc
+
+ loc attribute defines localization object taht use "manatools"
+ domain as default. (see ManaTools::Shared::Locales for details).
+ To use your own Module domain, override this attribute by using
+ has '+loc' => (
+ ...
+ )
+ or assign it again to your ManaTools::Shared::Locales object into
+ the extension module implementation.
+
+=cut
+
+#=============================================================
+has 'loc' => (
+ is => 'rw',
+ init_arg => undef,
+ builder => '_localeInitialize'
+);
+
+sub _localeInitialize {
+ my $self = shift;
+
+ my $cmdline = new yui::YCommandLine;
+ my $locale_dir = undef;
+ my $pos = $cmdline->find("--locales-dir");
+ if ($pos > 0)
+ {
+ $locale_dir = $cmdline->arg($pos+1);
+ }
+ $self->loc(
+ ManaTools::Shared::Locales->new(
+ domain_name => 'manatools',
+ dir_name => $locale_dir,
+ )
+ );
+}
+
+#=============================================================
+
=head1 SUBROUTINES/METHODS
-=head2 create - returns a Module object such as a module
- launcher (this object) or an extension of
- this class
+=head2 create
+
+=head3 INPUT
+
+ %params: moudule extension construtcor parameters
+ --CLASS <name> name of the Class module extension name
+ in the case of acting as a launcher mandatory parameters
+ are name, icon and launch (see Attributes section of
+ this manual)
+
+=head3 DESCRIPTION
+
+ returns a Module instance, such as a module launcher
+ (this object) or an extension of this class
=cut
+#=============================================================
sub create {
my $class = shift;
$class = ref $class || $class;
@@ -67,25 +184,6 @@ sub create {
return $obj;
}
-has 'icon' => (
- is => 'rw',
- isa => 'Str',
-);
-
-has 'name' => (
- is => 'rw',
- isa => 'Str',
-);
-
-has 'launch' => (
- is => 'rw',
- isa => 'Str',
-);
-
-has 'button' => (
- is => 'rw',
- init_arg => undef,
-);
#=============================================================
@@ -94,12 +192,12 @@ has 'button' => (
=head3 INPUT
-$self: this object
-$button: yui push button to be assigned to this module
+ $self: this object
+ $button: yui push button to be assigned to this module
=head3 DESCRIPTION
-This method assignes a button to this module
+ This method assignes a button to this module
=cut
@@ -115,11 +213,11 @@ sub setButton {
=head3 INPUT
-$self: this object
+ $self: this object
=head3 DESCRIPTION
-This method remove the assigned button from this module
+ This method remove the assigned button from this module
=cut
@@ -137,11 +235,12 @@ sub removeButton {
=head3 INPUT
-$self: this object
+ $self: this object
=head3 DESCRIPTION
-This method is the base class launcher, run external modules.
+ This method is the base class launcher that runs an external
+ module, defined in launch attribute.
=cut