Sha256: b22458ed686bb51b6c6c9976df9b754e7da7be9beb0720a72f939ac6b430099d

Contents?: true

Size: 1.02 KB

Versions: 59

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Buildkite
  module Pipelines
    module Helpers
      ATTRIBUTE_HELPERS = {
        block: :Block,
        command: :Command,
        depends_on: :DependsOn,
        key: :Key,
        label: :Label,
        plugins: :Plugins,
        retry: :Retry,
        skip: :Skip,
        soft_fail: :SoftFail,
        timeout_in_minutes: :TimeoutInMinutes,
      }.freeze

      ATTRIBUTE_HELPERS.each do |name, mod|
        autoload mod, File.expand_path("helpers/#{name}", __dir__)
      end

      def self.prepend_attribute_helper(step_class, attribute)
        if ATTRIBUTE_HELPERS[attribute]
          step_class.prepend(const_get(ATTRIBUTE_HELPERS[attribute]))
        end
      end

      def self.sanitize(obj)
        case obj
        when Hash
          obj.transform_keys(&:to_s).transform_values { |value| sanitize(value) }
        when Array
          obj.map { |value| sanitize(value) }
        when Symbol, Pathname
          obj.to_s
        else
          obj
        end
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
buildkite-builder-2.2.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-2.1.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-2.0.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-2.0.0.beta4 lib/buildkite/pipelines/helpers.rb
buildkite-builder-2.0.0.beta3 lib/buildkite/pipelines/helpers.rb
buildkite-builder-2.0.0.beta2 lib/buildkite/pipelines/helpers.rb
buildkite-builder-2.0.0.beta1 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.4.1 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.4.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.3.1 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.3.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.2.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.1.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.0.0 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.0.0.beta.5 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.0.0.beta.4 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.0.0.beta.3 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.0.0.beta.2 lib/buildkite/pipelines/helpers.rb
buildkite-builder-1.0.0.beta.1 lib/buildkite/pipelines/helpers.rb