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

#compilevoid

This method returns an undefined value.

Compile the configuration.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rosett_ai/thor/tasks/config.rb', line 96

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

  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) ⇒ void

This method returns an undefined value.

Display detailed information for the named item.

Parameters:

  • scope (Object)

    the scope



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rosett_ai/thor/tasks/config.rb', line 43

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