Sha256: 17fc5a15912b84f01d92374bdf061f2fdb0b1562fb8bb6c1fa0d9980d3f227ec

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require 'bundler'
require 'pathname'

module Buildkite
  module Builder
    autoload :Commands, File.expand_path('builder/commands', __dir__)
    autoload :Definition, File.expand_path('builder/definition', __dir__)
    autoload :FileResolver, File.expand_path('builder/file_resolver', __dir__)
    autoload :Github, File.expand_path('builder/github', __dir__)
    autoload :Loaders, File.expand_path('builder/loaders', __dir__)
    autoload :LoggingUtils, File.expand_path('builder/logging_utils', __dir__)
    autoload :Manifest, File.expand_path('builder/manifest', __dir__)
    autoload :Processors, File.expand_path('builder/processors', __dir__)
    autoload :Rainbow, File.expand_path('builder/rainbow', __dir__)
    autoload :Runner, File.expand_path('builder/runner', __dir__)

    BUILDKITE_DIRECTORY_NAME = '.buildkite/'

    class << self
      def root(start_path: Dir.pwd, reset: false)
        @root = nil if reset
        @root ||= find_buildkite_directory(start_path)
      end

      def find_buildkite_directory(start_path)
        path = Pathname.new(start_path)
        until path.join(BUILDKITE_DIRECTORY_NAME).exist? && path.join(BUILDKITE_DIRECTORY_NAME).directory?
          raise "Unable to find #{BUILDKITE_DIRECTORY_NAME} from #{start_path}" if path == path.parent

          path = path.parent
        end
        path.expand_path
      end

      def expand_path(path)
        path = Pathname.new(path)
        path.absolute? ? path : root.join(path)
      end

      def template(&block)
        Definition::Template.new(&block) if block_given?
      end

      def pipeline(&block)
        Definition::Pipeline.new(&block) if block_given?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildkite-builder-1.0.0 lib/buildkite/builder.rb