Skip to content

CustomProcesses

Lukas Deutz edited this page Apr 2, 2020 · 2 revisions

Process

The toolchain uses a plugin system to extend the functionality. The pre and post stage plugins are called processes.

How to

First, some boilerplate code:

# frozen_string_literal: true

require 'base_process'
require 'utils/paths'
require 'log/log'

module Custom
  module Post
    class HelloWorld < ::Toolchain::BaseProcess
      def initialize(priority = 100)
        super(priority)
        @testvar = 'test'
      end

      def run
        log('HelloWorld', 'Test Post Process')
      end
    end
  end
end

::Toolchain::PostProcessManager.instance.register(
  Custom::Post::HelloWorld.new
)

First, create a class (CustomProcess here) which inherits from BaseProcess. This class overwrites the run method, which is the main action and should be placed under either the Toolchain::Pre or Toolchain::Post namespace. Additionally, you can overwrite the constructor and pass a priority (higher priority means run first).

Lastly, the extension needs to be registered with Toolchain::PreProcessManager or Toolchain::PostProcessManager, depending on whether or process is a Pre process or Post process.

Once this is done and the extension has been placed in the pre.d or post.d folder, the toolchain will use this extension during either the Pre or Post stage.

NOTE: The processes must be included in config.yaml in order to be loaded (see Config).

Clone this wiki locally