Module: Prebake::Hooks

Defined in:
lib/prebake/hooks.rb

Class Method Summary collapse

Class Method Details

.register!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/prebake/hooks.rb', line 9

def self.register!
  return unless defined?(Bundler::Plugin::API)

  Bundler::Plugin::API.hook("after-install") do |spec_install|
    next unless Prebake.push_enabled?
    next unless spec_install.state == :installed

    gem_spec = spec_install.spec
    next unless gem_spec.extensions.any?
    next unless gem_spec.platform.to_s == "ruby"
    next unless File.exist?(gem_spec.gem_build_complete_path)

    AsyncPublisher.enqueue(gem_spec, Prebake.backend)
  end

  Bundler::Plugin::API.hook("after-install-all") do |_deps|
    ExtensionValidator.validate_all

    next unless Prebake.push_enabled?

    AsyncPublisher.wait_for_completion
  end

  Logger.debug "Hooks registered"
end