Sha256: 419130509d96cc346e1282c787364323f71f29f9a1550771b993919047454297

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

module Buildkite
  module Builder
    class StepCollection
      attr_reader :templates
      attr_reader :plugins
      attr_reader :steps

      def initialize(templates, plugins)
        @templates = templates
        @plugins = plugins
        @steps = []
      end

      def each(*types)
        types = types.flatten

        @steps.each do |step|
          if types.include?(step.class.to_sym)
            yield step
          end

          if step.is_a?(Group)
            step.data.steps.each(*types) do |step|
              yield step
            end
          end
        end
      end

      def add(step_class, template = nil, **args, &block)
        @steps.push(step_class.new(self, template, **args, &block)).last
      end

      def push(step)
        @steps.push(step)
      end

      def to_definition
        @steps.map(&:to_h)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildkite-builder-2.0.0.beta1 lib/buildkite/builder/step_collection.rb