Class: EmergeCLI::Commands::ValidateLinkmaps

Inherits:
GlobalOptions
  • Object
show all
Defined in:
lib/commands/order_files/validate_linkmaps.rb

Instance Method Summary collapse

Methods inherited from GlobalOptions

#before

Constructor Details

#initialize(network: nil) ⇒ ValidateLinkmaps

Returns a new instance of ValidateLinkmaps.



11
12
13
# File 'lib/commands/order_files/validate_linkmaps.rb', line 11

def initialize(network: nil)
  @network = network
end

Instance Method Details

#call(**options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/commands/order_files/validate_linkmaps.rb', line 15

def call(**options)
  @options = options
  before(options)

  Sync do
    executable_name = get_executable_name
    raise 'Executable not found' if executable_name.nil?

    Logger.info "Using executable: #{executable_name}"

    linkmaps_path = File.join(@options[:path], 'Linkmaps')
    raise 'Linkmaps folder not found' unless File.directory?(linkmaps_path)

    linkmaps = Dir.glob("#{linkmaps_path}/*.txt")
    raise 'No linkmaps found' if linkmaps.empty?

    executable_linkmaps = linkmaps.select do |linkmap|
      File.basename(linkmap).start_with?(executable_name)
    end
    raise 'No linkmaps found for executable' if executable_linkmaps.empty?

    Logger.info "✅ Found linkmaps for #{executable_name}"
  end
end