Sha256: 2df222d32abff147b4b6d8b1c4327a66516506a02db498ba7b820bf562e58b8f

Contents?: true

Size: 937 Bytes

Versions: 5

Compression:

Stored size: 937 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::Commands::#{klass}").new
          cmd.stored_output = output
          cmd.ensure_executable!
          cmd.execute
          output.public_send(:"#{command}=", cmd.output)
          logger.log(cmd)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
polishgeeks-dev-tools-1.4.0 lib/polish_geeks/dev_tools/runner.rb
polishgeeks-dev-tools-1.3.2 lib/polish_geeks/dev_tools/runner.rb
polishgeeks-dev-tools-1.3.1 lib/polish_geeks/dev_tools/runner.rb
polishgeeks-dev-tools-1.3.0 lib/polish_geeks/dev_tools/runner.rb
polishgeeks-dev-tools-1.2.1 lib/polishgeeks/dev-tools/runner.rb