Class: Chronos::Application::DependencyReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/chronos/application/dependency_reporter.rb

Overview

Builds one bounded inventory from already loaded runtime components.

Examples:

payload = DependencyReporter.new(config).call

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ DependencyReporter

Returns a new instance of DependencyReporter.



16
17
18
19
20
21
22
23
# File 'lib/chronos/application/dependency_reporter.rb', line 16

def initialize(config, options = {})
  @config = config
  @loaded_specs = options[:loaded_specs] || proc { Gem.loaded_specs }
  @constants = options[:constants] || {}
  @mutex = Mutex.new
  @reported = false
  @release_override = nil
end

Instance Method Details

#callObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/chronos/application/dependency_reporter.rb', line 35

def call
  @mutex.synchronize do
    return nil if @reported || !@config.dependency_reporting

    @reported = true
    build_payload
  end
rescue StandardError
  nil
end

#reset(release = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/chronos/application/dependency_reporter.rb', line 25

def reset(release = nil)
  @mutex.synchronize do
    @release_override = bounded(release, 128)
    @reported = false
  end
  true
rescue StandardError
  false
end