Class: Ace::Demo::CLI::Commands::Verify

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/demo/cli/commands/verify.rb

Instance Method Summary collapse

Instance Method Details

#call(cast:, tape:, **options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ace/demo/cli/commands/verify.rb', line 21

def call(cast:, tape:, **options)
  resolved_tape = Molecules::TapeResolver.new.resolve(tape)
  unless resolved_tape.end_with?(".tape.yml", ".tape.yaml")
    raise Ace::Support::Cli::Error, "ace-demo verify requires a .tape.yml tape"
  end

  spec = Atoms::DemoYamlParser.parse_file(resolved_tape)
  verification = Molecules::CastVerifier.new.verify(
    cast_path: File.expand_path(cast),
    tape_spec: spec,
    sandbox_path: options[:sandbox_path],
    env: {}
  )

  print_verification(verification)
  return if verification.success?

  report_path = Molecules::VerificationReportWriter.new(
    base_dir: options[:report_dir] || File.join(Dir.pwd, ".ace-local/demo")
  ).write(
    demo_name: File.basename(cast, File.extname(cast)),
    verification: verification
  )
  puts "Verification report: #{report_path}"
  raise Ace::Support::Cli::Error, "Demo verification failed (#{verification.classification}). Report: #{report_path}"
rescue TapeNotFoundError, DemoYamlParseError, CastParseError, ArgumentError => e
  raise Ace::Support::Cli::Error, e.message
end