class YleTf::TfHook::Runner
Attributes
config[R]
hook_env[R]
Public Class Methods
new(config, hook_env)
click to toggle source
# File lib/yle_tf/tf_hook/runner.rb, line 11 def initialize(config, hook_env) @config = config @hook_env = hook_env end
Public Instance Methods
hook_confs(hook_type)
click to toggle source
# File lib/yle_tf/tf_hook/runner.rb, line 32 def hook_confs(hook_type) config.fetch('hooks', hook_type).select do |hook| if hook['envs'] && !hook['envs'].include?(tf_env) Logger.debug("Skipping hook '#{hook['description']}' in env '#{tf_env}'") false else true end end end
hook_files(hook_type)
click to toggle source
# File lib/yle_tf/tf_hook/runner.rb, line 43 def hook_files(hook_type) Dir.glob("tf_hooks/#{hook_type}/*").select do |file| File.executable?(file) && !File.directory?(file) end end
hooks(hook_type)
click to toggle source
# File lib/yle_tf/tf_hook/runner.rb, line 27 def hooks(hook_type) hook_confs(hook_type).map { |conf| TfHook.from_config(conf, tf_env) } + hook_files(hook_type).map { |file| TfHook.from_file(file) } end
run(hook_type)
click to toggle source
# File lib/yle_tf/tf_hook/runner.rb, line 20 def run(hook_type) Logger.debug("Running #{hook_type} hooks") hooks(hook_type).each do |hook| hook.run(hook_env) end end
tf_env()
click to toggle source
# File lib/yle_tf/tf_hook/runner.rb, line 16 def tf_env @tf_env ||= config.tf_env end