summaryrefslogtreecommitdiff
path: root/lib/oxidized/manager.rb
diff options
context:
space:
mode:
authorAnton Aksola <anton.aksola@nebula.fi>2015-08-28 11:05:18 +0300
committerAnton Aksola <anton.aksola@nebula.fi>2015-08-28 11:05:18 +0300
commit0906e02a8538b698ed8bd7c72e6a09d3e809b67a (patch)
treed494ee43f71d41034efa98f5b5ab59ab5500207a /lib/oxidized/manager.rb
parent18cf96b36e54cb52c678e4e6395e595b6f9b4159 (diff)
Initial implementation of the hook feature
The current implementation is modular and allows users to define hooks in several ways: * Use one of the built-in hook types (currently only 'exec') * Define their own Hook classes inside ~/.config/oxidized/hook Exec hook type runs a user defined command with or without shell. It populates a bunch of environment variables with metadata. The command can either be run as synchronous or asynchronous. The default is synchronous.
Diffstat (limited to 'lib/oxidized/manager.rb')
-rw-r--r--lib/oxidized/manager.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb
index b4eaecd..bf28ae7 100644
--- a/lib/oxidized/manager.rb
+++ b/lib/oxidized/manager.rb
@@ -23,12 +23,13 @@ module Oxidized
end
end
end
- attr_reader :input, :output, :model, :source
+ attr_reader :input, :output, :model, :source, :hook
def initialize
@input = {}
@output = {}
@model = {}
@source = {}
+ @hook = {}
end
def add_input method
method = Manager.load Config::InputDir, method
@@ -53,5 +54,13 @@ module Oxidized
return false if _source.empty?
@source.merge! _source
end
+ def add_hook _hook
+ return nil if @hook.key? _hook
+ name = _hook
+ _hook = Manager.load File.join(Config::Root, 'hook'), name
+ _hook = Manager.load Config::HookDir, name if _hook.empty?
+ return false if _hook.empty?
+ @hook.merge! _hook
+ end
end
end