Class: MetzScan::Calibration::ProjectAnalyzerEvidenceRunner::TargetSet

Inherits:
Object
  • Object
show all
Defined in:
lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb

Constant Summary collapse

DEFAULT_SCAN_CHILDREN =
%w[app lib].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths:, default_apps_path:, targets_file: nil) ⇒ TargetSet

Returns a new instance of TargetSet.



11
12
13
14
15
16
# File 'lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb', line 11

def initialize(paths:, default_apps_path:, targets_file: nil)
  @paths = Array(paths)
  @default_apps_path = default_apps_path
  @targets_file = targets_file && File.expand_path(targets_file)
  reject_mixed_target_inputs!
end

Instance Attribute Details

#targets_fileObject (readonly)

Returns the value of attribute targets_file.



18
19
20
# File 'lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb', line 18

def targets_file
  @targets_file
end

Instance Method Details

#ensure_present!Object

Raises:



22
23
24
25
26
27
28
# File 'lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb', line 22

def ensure_present!
  missing = paths.reject { |path| File.exist?(path) }
  raise Error, "calibration target missing: #{missing.first}" unless missing.empty?

  missing_scan_path = manifest_scan_paths.flatten.find { |path| !File.directory?(path) }
  raise Error, "calibration scan path missing: #{missing_scan_path}" if missing_scan_path
end

#pathsObject



20
# File 'lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb', line 20

def paths = raw_targets.map { |path| File.expand_path(path) }.uniq.sort

#scan_paths_for(target) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb', line 30

def scan_paths_for(target)
  manifest_paths = manifest_scan_paths_by_target[File.expand_path(target)]
  return manifest_paths if manifest_paths

  scan_paths = scan_children_for(target)
  scan_paths = [target] if scan_paths.empty? && explicit_targets?
  scan_paths.map { |path| File.expand_path(path) }
end