Sha256: f0c80854dc98e279550844d2820086d4cb27dc233ddedcc3c7aea6497cd4396b

Contents?: true

Size: 1.1 KB

Versions: 19

Compression:

Stored size: 1.1 KB

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 find(key)
        @steps.find { |step| step.has?(:key) && step.key == key.to_s }
      end

      def find!(key)
        find(key) || raise(ArgumentError, "Can't find step with key: #{key}")
      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

19 entries across 19 versions & 1 rubygems

Version Path
buildkite-builder-3.8.3 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.8.2 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.8.1 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.8.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.7.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.6.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.5.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.4.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.3.2 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.3.1 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.3.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.2.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.1.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-3.0.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.4.1 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.4.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.3.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.2.0 lib/buildkite/builder/step_collection.rb
buildkite-builder-2.1.0 lib/buildkite/builder/step_collection.rb