Module: Lutaml::Model::Schema::RncCompiler::SourceResolver

Defined in:
lib/lutaml/model/schema/rnc_compiler/source_resolver.rb

Overview

Resolves RNC input text and the base directory used for relative include paths.

Defined Under Namespace

Classes: ResolvedSource

Class Method Summary collapse

Class Method Details

.resolve(input, options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lutaml/model/schema/rnc_compiler/source_resolver.rb', line 15

def resolve(input, options)
  location = options[:location].to_s
  return string_source(input) if location.empty?

  expanded = File.expand_path(location)
  if File.file?(expanded)
    return file_source(expanded) if input.nil? || input.to_s.empty?

    return string_source(input, base_dir: File.dirname(expanded), path: expanded)
  end
  return string_source(input, base_dir: expanded) if File.directory?(expanded)

  string_source(input)
end