Class: Buildkite::Builder::ExtensionManager

Inherits:
Object
  • Object
show all
Includes:
LoggingUtils
Defined in:
lib/buildkite/builder/extension_manager.rb

Instance Method Summary collapse

Methods included from LoggingUtils

#benchmark, #pluralize

Constructor Details

#initialize(context) ⇒ ExtensionManager

Returns a new instance of ExtensionManager.



7
8
9
10
11
12
# File 'lib/buildkite/builder/extension_manager.rb', line 7

def initialize(context)
  @context = context
  @extensions = {}

  Loaders::Extensions.load(@context.root)
end

Instance Method Details

#allObject



37
38
39
# File 'lib/buildkite/builder/extension_manager.rb', line 37

def all
  @extensions.keys
end

#buildObject



27
28
29
30
31
# File 'lib/buildkite/builder/extension_manager.rb', line 27

def build
  @extensions.each do |extension_class, extension|
    log_build(extension_class.name) { extension.build }
  end
end

#find(klass) ⇒ Object



33
34
35
# File 'lib/buildkite/builder/extension_manager.rb', line 33

def find(klass)
  @extensions.fetch(klass)
end

#use(extension, native: false, **args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/buildkite/builder/extension_manager.rb', line 14

def use(extension, native: false, **args, &block)
  unless extension < Buildkite::Builder::Extension
    raise "#{extension.name} must subclass Buildkite::Builder::Extension"
  end

  if @extensions[extension]
    raise "#{extension.name} already registered"
  end

  @extensions[extension] = extension.new(@context, **args, &block)
  @context.dsl.extend(extension)
end