Class: RosettAi::Thor::Tasks::Config

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/config.rb

Overview

Thor task for compiling engine configuration YAML to settings JSON.

Instance Method Summary collapse

Instance Method Details

#compileObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/rosett_ai/thor/tasks/config.rb', line 81

def compile
  compiler = resolve_config_compiler(simulate: options[:simulate])

  results = if options[:scope]
              scope_path = find_scope_file(options[:scope], compiler)
              [compiler.compile_scope(scope_path)]
            else
              compiler.compile
            end

  if results.empty?
    puts Rainbow(t('no_scopes')).yellow
    return
  end

  results.each { |r| print_result(r) }
  print_warnings(results) if options[:verbose]
  compiler.write_results(results) unless options[:simulate]
  print_summary(results)
  abort_if_failed(results)
end

#show(scope) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rosett_ai/thor/tasks/config.rb', line 39

def show(scope)
  scope = RosettAi::TextSanitizer.normalize_nfc(scope)
  compiler = resolve_config_compiler(simulate: true, masking: true)
  scope_path = find_scope_file(scope, compiler)

  if options[:raw]
    print_raw_source(scope_path)
  else
    print_compiled_json(scope_path, compiler)
  end
end