Class: PolishGeeks::DevTools::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/runner.rb

Overview

Class used to execute appropriate commands based on config settings

Instance Method Summary collapse

Instance Method Details

#execute(logger) ⇒ Object

Executes the whole tool

Examples:

Run all defined elements

PolishGeeks::DevTools::Runner.new.execute(
  PolishGeeks::DevTools::Logger.new
)

Parameters:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/polish_geeks/dev_tools/runner.rb', line 11

def execute(logger)
  output = OutputStorer.new

  Config::COMMANDS.each do |command|
    next unless DevTools.config.public_send(:"#{command}?")

    klass = command.to_s.gsub(/(?<=_|^)(\w)/, &:upcase).gsub(/(?:_)(\w)/, '\1')
    cmd = Object.const_get("PolishGeeks::DevTools::Commands::#{klass}").new
    cmd.stored_output = output
    cmd.ensure_executable!
    cmd.execute
    output.public_send(:"#{command}=", cmd.output)
    logger.log(cmd)
  end
end