Sha256: cce4bbaab66fc048083e9ae75281b1d580b97a26330d6c317af95d4da8c5d190

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 Bytes

Contents

# frozen_string_literal: true

module Buildkite
  module Builder
    class Extension
      class << self
        attr_reader :dsl

        def dsl(&block)
          @dsl = Module.new(&block) if block_given?
          @dsl
        end
      end

      attr_reader :context
      attr_reader :options

      def initialize(context, **options)
        @context = context
        @options = options

        prepare
      end

      def build
        # Override to provide extra functionality.
      end

      private

      def buildkite
        @buildkite ||= begin
          unless Buildkite.env
            raise 'Must be in Buildkite environment to access the Buildkite API'
          end

          Buildkite::Pipelines::Api.new(Buildkite.env.api_token)
        end
      end

      def prepare
        # Override to provide extra functionality.
      end

      def pipeline(&block)
        context.dsl.instance_eval(&block) if block_given?
        context
      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/extension.rb