Class: Judges::Inspect

Inherits:
Object show all
Defined in:
lib/judges/commands/inspect.rb

Overview

The inspect command.

This class is instantiated by the bin/judge command line interface. You are not supposed to instantiate it yourself.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2024-2025 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(loog) ⇒ Inspect

Initialize.

Parameters:

  • loog (Loog)

    Logging facility



21
22
23
# File 'lib/judges/commands/inspect.rb', line 21

def initialize(loog)
  @loog = loog
end

Instance Method Details

#run(_opts, args) ⇒ Object

Run the inspect command (called by the bin/judges script).

Parameters:

  • _opts (Hash)

    Command line options (not used)

  • args (Array)

    List of command line arguments

Raises:

  • (RuntimeError)

    If no arguments provided



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/judges/commands/inspect.rb', line 29

def run(_opts, args)
  raise 'At least one argument required' if args.empty?
  fb = Judges::Impex.new(@loog, args[0]).import
  @loog.info("Facts: #{fb.size}")
  sum = fb.query('(eq what "judges-summary")').each.to_a
  if sum.empty?
    @loog.info('Summary fact not found')
  else
    @loog.info("Summary fact found:\n\t#{Factbase::FactAsYaml.new(sum.first).gsub("\n", "\n\t")}")
  end
end