Class: CC::Analyzer::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/analyzer/engine.rb

Overview

Running specifically an Engine container

Input:

- name
- metadata
  - image
  - command (optional)
- config (becomes /config.json)
- label
- io (to write filtered, validated output)

Output:

- Container::Result

Constant Summary collapse

Error =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(name, metadata, config, label) ⇒ Engine

Returns a new instance of Engine.



23
24
25
26
27
28
29
# File 'lib/cc/analyzer/engine.rb', line 23

def initialize(name, , config, label)
  @name = name
  @metadata = 
  @config = config
  @label = label.to_s
  @error = nil
end

Instance Method Details

#run(io) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cc/analyzer/engine.rb', line 31

def run(io)
  write_config_file

  container = Container.new(
    image: .fetch("image"),
    command: ["command"],
    name: container_name,
  )

  container.on_output("\0") do |output|
    handle_output(container, io, output)
  end

  container.run(container_options).tap do |result|
    result.merge_from_exception(error) if error.present?
  end
ensure
  delete_config_file
end