Class: Lutaml::Xsd::Commands::PkgCommand

Inherits:
Thor
  • Object
show all
Defined in:
lib/lutaml/xsd/commands/pkg_command.rb

Overview

Package inspection commands (MECE category) Handles all package querying, listing, and inspection operations

Instance Method Summary collapse

Instance Method Details

#attribute_def(qname, package_path) ⇒ Object



432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 432

def attribute_def(qname, package_path)
  package = SchemaRepositoryPackage.new(package_path)
  extractor = DefinitionExtractor.new(package)

  definition = extractor.extract_attribute_definition(qname)

  if definition
    display_attribute_definition(definition)
  else
    puts "Attribute '#{qname}' not found in package"
    exit 1
  end
end

#coverage(package_path) ⇒ Object



195
196
197
198
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 195

def coverage(package_path)
  require_relative "coverage_command"
  CoverageCommand.new(package_path, options).run
end

#element_def(qname, package_path) ⇒ Object



407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 407

def element_def(qname, package_path)
  package = SchemaRepositoryPackage.new(package_path)
  extractor = DefinitionExtractor.new(package)

  definition = extractor.extract_element_definition(qname)

  if definition
    display_element_definition(definition)
  else
    puts "Element '#{qname}' not found in package"
    exit 1
  end
end

#entrypoints(package_path) ⇒ Object



357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 357

def entrypoints(package_path)
  package = SchemaRepositoryPackage.new(package_path)
  identifier = EntrypointIdentifier.new(package)

  entrypoints = identifier.identify_entrypoints
  dependencies = identifier.get_dependencies

  if options[:tree]
    display_entrypoint_tree(package, entrypoints, options[:depth])
  else
    display_entrypoints_list(entrypoints, dependencies)
  end
end

#extract(package_path, schema_name) ⇒ Object



168
169
170
171
172
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 168

def extract(package_path, schema_name)
  require_relative "package_command"
  PackageCommand::ExtractCommand.new(package_path, schema_name,
                                     options).run
end

#inspect(package_path) ⇒ Object



115
116
117
118
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 115

def inspect(package_path)
  require_relative "package_command"
  PackageCommand::InfoCommand.new(package_path, options).run
end

#ls(package_path) ⇒ Object



56
57
58
59
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 56

def ls(package_path)
  require_relative "package_command"
  PackageCommand::SchemasCommand.new(package_path, options).run
end

#namespace_elements(uri, package_path) ⇒ Object



487
488
489
490
491
492
493
494
495
496
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 487

def namespace_elements(uri, package_path)
  package = SchemaRepositoryPackage.new(package_path)
  repository = package.load_repository

  namespace_uri = resolve_namespace_uri(repository, uri)

  elements = filter_elements_by_namespace(repository, namespace_uri)

  display_namespace_elements(namespace_uri, elements, options[:format])
end

#namespace_types(uri, package_path) ⇒ Object



461
462
463
464
465
466
467
468
469
470
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 461

def namespace_types(uri, package_path)
  package = SchemaRepositoryPackage.new(package_path)
  repository = package.load_repository

  namespace_uri = resolve_namespace_uri(repository, uri)

  types = filter_types_by_namespace(repository, namespace_uri)

  display_namespace_types(namespace_uri, types, options[:format])
end

#search(query, package_path) ⇒ Object



309
310
311
312
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 309

def search(query, package_path)
  require_relative "search_command"
  Commands::SearchCommand.new(query, package_path, options).run
end

#stats(package_path) ⇒ Object



142
143
144
145
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 142

def stats(package_path)
  require_relative "stats_command"
  StatsCommand::ShowCommand.new(package_path, options).run
end

#tree(package_path) ⇒ Object



94
95
96
97
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 94

def tree(package_path)
  require_relative "tree_command"
  TreeCommand.new(package_path, options).run
end

#type_def(qname, package_path) ⇒ Object



382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 382

def type_def(qname, package_path)
  package = SchemaRepositoryPackage.new(package_path)
  extractor = DefinitionExtractor.new(package)

  definition = extractor.extract_type_definition(qname)

  if definition
    display_type_definition(definition)
  else
    puts "Type '#{qname}' not found in package"
    exit 1
  end
end

#verify(package_path) ⇒ Object



231
232
233
234
# File 'lib/lutaml/xsd/commands/pkg_command.rb', line 231

def verify(package_path)
  require_relative "verify_command"
  VerifyCommand.new(package_path, options).run
end