class ForemanMaintain::Concerns::Metadata::DSL

Attributes

data[R]

Public Class Methods

eval_dsl(metadata, &block) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 107
def self.eval_dsl(metadata, &block)
  new(metadata).tap do |dsl|
    dsl.instance_eval(&block)
  end.data
end
new(data = {}) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 15
def initialize(data = {})
  @data = data
end

Public Instance Methods

advanced_run(advanced_run) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 99
def advanced_run(advanced_run)
  @data[:advanced_run] = advanced_run
end
after(*step_labels) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 40
def after(*step_labels)
  @data[:after].concat(step_labels)
end
before(*step_labels) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 35
def before(*step_labels)
  raise Error::MultipleBeforeDetected, step_labels if step_labels.count > 1
  @data[:before].concat(step_labels)
end
confine(&block) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 31
def confine(&block)
  @data[:confine_blocks] << block
end
description(description) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 27
def description(description)
  @data[:description] = description
end
do_not_whitelist() click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 103
def do_not_whitelist
  @data[:do_not_whitelist] = true
end
for_feature(feature_label) click to toggle source

Specify what feature the definition related to.

# File lib/foreman_maintain/concerns/metadata.rb, line 86
def for_feature(feature_label)
  @data[:for_feature] = feature_label
  confine do
    feature(feature_label)
  end
end
label(label) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 19
def label(label)
  @data[:label] = label
end
manual_detection() click to toggle source

Mark the class as manual: this means the instance of class will not be initialized by detector to check the confine block to determine if it's valid on the system or not. The classes marked for manual detect need to be initialized in from other places (such as `additional_features` in Feature)

# File lib/foreman_maintain/concerns/metadata.rb, line 75
def manual_detection
  @data[:autodetect] = false
end
param(name, descripiton_or_options = {}, options = {}, &block) click to toggle source

Parametrize the definition.

Arguments

+name+: Name (Symbol) of the attribute
+description_or_options+: Description string or a Hash with options
+options+: Hash with options (unless specified in +descriptions_or_options+)
+&block+: block to be called when processing the data: can be used for validation
   and type-casing of the value: expected to return the value to be used

Options

+:description+: String describing the parameter
+:required+: true if required
+:flag+: param is just a true/false value: not expecting other values
# File lib/foreman_maintain/concerns/metadata.rb, line 60
def param(name, descripiton_or_options = {}, options = {}, &block)
  case descripiton_or_options
  when String
    description = descripiton_or_options
  when Hash
    options = options.merge(descripiton_or_options) if descripiton_or_options.is_a?(Hash)
  end
  @data[:params][name] = Param.new(name, description, options, &block)
end
preparation_steps(&block) click to toggle source

in the block, define one or more preparation steps needed before executing this definition

# File lib/foreman_maintain/concerns/metadata.rb, line 81
def preparation_steps(&block)
  @data[:preparation_steps_blocks] << block
end
run_once() click to toggle source

Ensure to not run the step twice: expects the scenario to be persisted between runs to work properly

# File lib/foreman_maintain/concerns/metadata.rb, line 95
def run_once
  @data[:run_once] = true
end
tags(*tags) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 23
def tags(*tags)
  @data[:tags].concat(tags)
end