class TinyCI::ConfigTransformer

Transforms the configuration format from the condensed format to the more verbose format accepted by the rest of the system

Public Class Methods

new(input) click to toggle source

Constructor

@param [Hash] input The configuration object, in the condensed format

# File lib/tinyci/config_transformer.rb, line 10
def initialize(input)
  @input = input
end

Public Instance Methods

transform!() click to toggle source

Transforms the config object

@return [Hash] The config object in the verbose form

# File lib/tinyci/config_transformer.rb, line 17
def transform!
  @input.each_with_object({}) do |(key, value), acc|
    method_name = "transform_#{key}"

    if respond_to? method_name, true
      acc.merge! send(method_name, value)
    else
      acc[key] = value
    end
  end
end

Private Instance Methods

transform_build(value) click to toggle source
# File lib/tinyci/config_transformer.rb, line 31
def transform_build(value)
  {
    builder: {
      class: 'ScriptBuilder',
      config: {
        command: value
      }
    }
  }
end
transform_hooks(value) click to toggle source
# File lib/tinyci/config_transformer.rb, line 53
def transform_hooks(value)
  {
    hooker: {
      class: 'ScriptHooker',
      config: value
    }
  }
end
transform_test(value) click to toggle source
# File lib/tinyci/config_transformer.rb, line 42
def transform_test(value)
  {
    tester: {
      class: 'ScriptTester',
      config: {
        command: value
      }
    }
  }
end