Module: MiGA::Project::Hooks

Includes:
Common::Hooks
Included in:
MiGA::Project
Defined in:
lib/miga/project/hooks.rb

Overview

Helper module including specific functions to handle project hooks. Supported events:

  • on_create(): When created

  • on_load(): When loaded

  • on_save(): When saved

  • on_add_dataset(dataset): When a dataset is added, with name dataset

  • on_unlink_dataset(dataset): When dataset with name dataset is unlinked

  • on_result_ready(result): When any result is ready, with key result

  • on_result_ready_Common::WithResult#result(): When result is ready

  • on_processing_ready(): When preprocessing is complete

Supported hooks:

  • run_lambda(lambda, argsā€¦)

  • run_cmd(cmd)

Internal hooks:

  • _pull_result_hooks()

Instance Method Summary collapse

Methods included from Common::Hooks

#add_hook, #hook_run_lambda, #hooks, #pull_hook

Instance Method Details

#default_hooksObject



22
23
24
25
26
# File 'lib/miga/project/hooks.rb', line 22

def default_hooks
  {
    on_result_ready: [[:_pull_result_hooks]]
  }
end

#hook__pull_result_hooks(_hook_args, event_args) ⇒ Object

Dataset Action :pull_result_hooks([], [res]) Pull the hook specific to the type of result



45
46
47
48
# File 'lib/miga/project/hooks.rb', line 45

def hook__pull_result_hooks(_hook_args, event_args)
  pull_hook(:"on_result_ready_#{event_args.first}", *event_args)
  pull_hook(:on_processing_ready) if next_task(nil, false).nil?
end

#hook_run_cmd(hook_args, event_args) ⇒ Object

Run cmd in the command-line with {variables}: project, project_name, miga, object (if defined by the event)

  • hook_args: [cmd]

  • event_args: [object (optional)]



33
34
35
36
37
38
39
40
# File 'lib/miga/project/hooks.rb', line 33

def hook_run_cmd(hook_args, event_args)
  Process.wait(
    spawn hook_args.first.miga_variables(
      project: path, project_name: name,
      miga: MiGA::MiGA.root_path, object: event_args.first
    )
  )
end