Sha256: 7ba0552839b015581fd1f2ca8ce7049b565451d3817f7a43bcb01f3226b35ba0

Contents?: true

Size: 919 Bytes

Versions: 4

Compression:

Stored size: 919 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
          elsif step.is_a?(Group)
            step.data.steps.each(*types) do |step|
              yield step
            end
          elsif types.empty?
            yield step
          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

4 entries across 4 versions & 1 rubygems

Version Path
buildkite-builder-2.0.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.0.0.beta4 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.0.0.beta3 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.0.0.beta2 lib/buildkite/builder/step_collection.rb