File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ #
2
+ # (c) Jan Gehring <jan.gehring@gmail.com>
3
+ #
4
+ # vim: set ts=2 sw=2 tw=0:
5
+ # vim: set expandtab:
6
+
7
+ package Rex::Function::Common ;
8
+
9
+ use strict;
10
+ use warnings;
11
+
12
+ # VERSION
13
+
14
+ require Exporter;
15
+ require Rex::Config;
16
+ use Data::Dumper;
17
+ use base qw( Exporter) ;
18
+ use vars qw( @EXPORT) ;
19
+ use MooseX::Params::Validate;
20
+ use Rex::MultiSub::Function;
21
+
22
+ @EXPORT = qw( function) ;
23
+
24
+ sub function {
25
+ my ( $name , $options , $function ) = @_ ;
26
+ my $name_save = $name ;
27
+ if ( $name_save !~ m / ^[a-zA-Z_][a-zA-Z0-9_] +$ / ) {
28
+ Rex::Logger::info(
29
+ " Please use only the following characters for function names:" , " warn" );
30
+ Rex::Logger::info( " A-Z, a-z, 0-9 and _" , " warn" );
31
+ Rex::Logger::info( " Also the function should start with A-Z or a-z" ,
32
+ " warn" );
33
+ die " Wrong function name syntax." ;
34
+ }
35
+
36
+ my $sub = Rex::MultiSub::Function-> new(
37
+ name => $name_save ,
38
+ function => $function ,
39
+ params_list => $options -> {params_list },
40
+ test_wantarray => 1,
41
+ );
42
+
43
+ my ( $class , $file , @tmp ) = caller ;
44
+
45
+ $sub -> export( $class , $options -> {export } );
46
+ }
47
+
48
+ 1;
You can’t perform that action at this time.
0 commit comments