Sha256: 2f0553cac23bce249a5b059f876408f910a7bf722cef0199d13edb2441d4f2ee

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

module PolishGeeks
  module DevTools
    # Class used to execute appropriate commands based on config settings
    class Runner
      # Executes the whole tool
      # @param logger [PolishGeeks::DevTools::Logger] logger instance
      # @example Run all defined elements
      #   PolishGeeks::DevTools::Runner.new.execute(
      #     PolishGeeks::DevTools::Logger.new
      #   )
      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::Command::#{klass}").new
          cmd.stored_output = output
          cmd.execute
          output.public_send(:"#{command}=", cmd.output)
          logger.log(cmd)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polishgeeks-dev-tools-1.2.0 lib/polishgeeks/dev-tools/runner.rb
polishgeeks-dev-tools-1.1.3 lib/polishgeeks/dev-tools/runner.rb