Module: InvokeGenerators

Included in:
MenuGenerator
Defined in:
lib/generators/invoke_generators.rb

Overview

:reek:FeatureEnvy { enabled: false } :reek:UtilityFunction { enabled: false }

Class Method Summary collapse

Class Method Details

.add_generator(generators, *gens) ⇒ Object



27
28
29
# File 'lib/generators/invoke_generators.rb', line 27

def add_generator(generators, *gens)
  gens.each { |generator| generators.push generator }
end

.generate_framework(structure = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/invoke_generators.rb', line 13

def generate_framework(structure = {})
  generators = %w[Automation Actions Common Helpers]
  framework = structure[:framework]
  add_generator(generators, framework.capitalize)
  generators.each do |generator|
    invoke_generator({
                       automation: structure[:automation],
                       framework:,
                       generator:,
                       name: structure[:name]
                     })
  end
end

.invoke_generator(structure = {}) ⇒ Object



31
32
33
34
35
36
# File 'lib/generators/invoke_generators.rb', line 31

def invoke_generator(structure = {})
  Object.const_get("#{structure[:generator]}Generator")
        .new([structure[:automation],
              structure[:framework],
              structure[:name]]).invoke_all
end

.to_bool(string) ⇒ Object



38
39
40
41
42
# File 'lib/generators/invoke_generators.rb', line 38

def to_bool(string)
  return unless string.is_a? String

  string.downcase == 'true'
end