aboutsummaryrefslogtreecommitdiff
path: root/Plugin/Map.pm
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-04-10 15:20:24 +1200
committerDavid Phillips <david@sighup.nz>2018-04-10 15:20:24 +1200
commitcd1fc57841deab0e9b8bcfad49d527c6b263534c (patch)
tree83bc8874a4b6970e0850f9aaca3a8c801bce293c /Plugin/Map.pm
parentbb1808b1ef92af9a14a073f2e14973ac132b7e7e (diff)
downloadidalius-cd1fc57841deab0e9b8bcfad49d527c6b263534c.tar.xz
Correct capitalisation on module names
Diffstat (limited to 'Plugin/Map.pm')
-rw-r--r--Plugin/Map.pm34
1 files changed, 34 insertions, 0 deletions
diff --git a/Plugin/Map.pm b/Plugin/Map.pm
new file mode 100644
index 0000000..9ca8cef
--- /dev/null
+++ b/Plugin/Map.pm
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl
+
+package Plugin::Map;
+
+use strict;
+use warnings;
+
+my %config;
+my $run_command;
+
+
+sub configure {
+ my $self = shift;
+ my $cmdref = shift;
+ my $cref = shift;
+ %config = %$cref;
+ $run_command = shift;
+
+ $cmdref->("map", sub { $self->map(@_); } );
+
+ return $self;
+}
+
+sub map {
+ my ($self, $logger, $who, $where, $rest, @arguments) = @_;
+ my ($command, $subjects) = ($rest =~ /^(.+?)\s+(.*)$/);
+
+ return "[]" unless $subjects;
+
+ my @array = map { $run_command->("$command $_", $who, $where) } (split /,/, $subjects);
+
+ return "[" . (join ", ", @array). "]";
+}
+1;