aboutsummaryrefslogtreecommitdiff
path: root/lib/longboat
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2020-11-03 16:54:10 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2020-11-03 16:54:10 +0000
commitb859d0d0b638e03498d620dcfa09a6aacfe44f0e (patch)
tree126c60be8a836dcc6cba15ed41e03060d066fc8a /lib/longboat
parent4823c4515895714c118f6add8c5642bdcec228d5 (diff)
Initial new raider-specific config
Diffstat (limited to 'lib/longboat')
-rw-r--r--lib/longboat/config.rb18
-rw-r--r--lib/longboat/raiders.rb4
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/longboat/config.rb b/lib/longboat/config.rb
index f235154..3a54e92 100644
--- a/lib/longboat/config.rb
+++ b/lib/longboat/config.rb
@@ -3,7 +3,7 @@ require 'optimist'
module Longboat
module Config
def self.parse!
- Optimist::options do
+ parser = Optimist::Parser.new do
# Collection interval
opt :raid_every, "Collection interval", type: Integer, default: 60
@@ -18,6 +18,22 @@ module Longboat
# Testing
opt :test, "Output metrics to stdout and quit", type: TrueClass, default: false
end
+ parser.ignore_invalid_options = true
+
+ begin
+ parser.parse
+ rescue Optimist::HelpNeeded
+ parser.educate
+ exit
+ rescue Optimist::VersionNeeded
+ exit
+ end
+ end
+
+ def self.for_raider(&block)
+ parser = Optimist::Parser.new(&block)
+ parser.ignore_invalid_options = true
+ parser.parse
end
end
end
diff --git a/lib/longboat/raiders.rb b/lib/longboat/raiders.rb
index cd93858..f907f01 100644
--- a/lib/longboat/raiders.rb
+++ b/lib/longboat/raiders.rb
@@ -15,7 +15,9 @@ module Longboat
cname = reqname.split('_').map(&:capitalize).join
require "#{dir}/#{reqname}"
- @raiders[reqname] = Kernel.const_get(cname).new(@collector, raider_config)
+ raider = Kernel.const_get(cname).new(@collector, raider_config)
+ raider.configure! if raider.respond_to?(:configure!)
+ @raiders[reqname] = raider
end
end
end