Module: Legion::Extensions::Builder::Runners

Includes:
Base
Included in:
Core
Defined in:
lib/legion/extensions/builders/runners.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#const_defined_two?, #define_constant_two, #define_get, #find_files, #require_files

Instance Attribute Details

#runnersObject (readonly)

Returns the value of attribute runners.



9
10
11
# File 'lib/legion/extensions/builders/runners.rb', line 9

def runners
  @runners
end

Instance Method Details

#build_runner_listObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/legion/extensions/builders/runners.rb', line 18

def build_runner_list
  runner_files.each do |file|
    runner_name = file.split('/').last.sub('.rb', '')
    runner_class =  "#{lex_class}::Runners::#{runner_name.split('_').collect(&:capitalize).join}"
    loaded_runner = Kernel.const_get(runner_class)

    @runners[runner_name.to_sym] = {
      extension:       lex_class.to_s.downcase,
      extension_name:  extension_name,
      extension_class: lex_class,
      runner_name:     runner_name,
      runner_class:    runner_class,
      runner_path:     file,
      class_methods:   {}
    }

    @runners[runner_name.to_sym][:scheduled_tasks] = loaded_runner.scheduled_tasks if loaded_runner.method_defined? :scheduled_tasks

    if settings.key?(:runners) && settings[:runners].key?(runner_name.to_sym)
      @runners[runner_name.to_sym][:desc] = settings[:runners][runner_name.to_sym][:desc]
    end

    loaded_runner.public_instance_methods(false).each do |runner_method|
      @runners[runner_name.to_sym][:class_methods][runner_method] = {
        args: loaded_runner.instance_method(runner_method).parameters
      }
    end

    loaded_runner.methods(false).each do |runner_method|
      next if %i[scheduled_tasks runner_description].include? runner_method

      @runners[runner_name.to_sym][:class_methods][runner_method] = {
        args: loaded_runner.method(runner_method).parameters
      }
    end
  end
end

#build_runnersObject



11
12
13
14
15
16
# File 'lib/legion/extensions/builders/runners.rb', line 11

def build_runners
  @runners = {}
  lex_class.const_set('Runners', Module.new) unless lex_class.const_defined?('Runners')
  require_files(runner_files)
  build_runner_list
end

#runner_filesObject



56
57
58
# File 'lib/legion/extensions/builders/runners.rb', line 56

def runner_files
  @runner_files ||= find_files('runners')
end