Class: Lutaml::Xsd::PackageConfiguration
- Inherits:
-
Object
- Object
- Lutaml::Xsd::PackageConfiguration
- Defined in:
- lib/lutaml/xsd/package_configuration.rb
Overview
Configuration for schema repository package creation Defines three independent options:
-
XSD Mode: How XSD files are included
-
Resolution Mode: Whether to pre-serialize parsed schemas
-
Serialization Format: How schemas are serialized/deserialized
Constant Summary collapse
- XSD_MODES =
XSD inclusion modes
{ include_all: :include_all, # Bundle all XSDs with rewritten paths allow_external: :allow_external, # Keep external references }.freeze
- RESOLUTION_MODES =
Resolution modes
{ bare: :bare, # Parse on load (smaller metadata) resolved: :resolved, # Instant load (serialized schemas included) }.freeze
- SERIALIZATION_FORMATS =
Serialization formats
{ marshal: :marshal, # Ruby Marshal (fastest, binary) json: :json, # JSON format (portable, human-readable) yaml: :yaml, # YAML format (portable, human-readable) parse: :parse, # Parse XSD files (no serialization) }.freeze
Instance Attribute Summary collapse
-
#resolution_mode ⇒ Object
readonly
Returns the value of attribute resolution_mode.
-
#serialization_format ⇒ Object
readonly
Returns the value of attribute serialization_format.
-
#xsd_mode ⇒ Object
readonly
Returns the value of attribute xsd_mode.
Class Method Summary collapse
-
.from_hash(data) ⇒ PackageConfiguration
Create from hash.
Instance Method Summary collapse
-
#allow_external_xsds? ⇒ Boolean
Whether to allow external XSD references.
-
#bare_package? ⇒ Boolean
Whether package requires parsing on load.
-
#include_all_xsds? ⇒ Boolean
Whether to include all XSD files in package.
-
#initialize(xsd_mode: :include_all, resolution_mode: :resolved, serialization_format: :marshal) ⇒ PackageConfiguration
constructor
A new instance of PackageConfiguration.
-
#json_format? ⇒ Boolean
Whether to use JSON serialization.
-
#marshal_format? ⇒ Boolean
Whether to use marshal serialization.
-
#parse_format? ⇒ Boolean
Whether to parse XSD files (no serialization).
-
#resolved_package? ⇒ Boolean
Whether package includes pre-resolved schemas.
-
#to_h ⇒ Hash
Configuration as hash.
-
#yaml_format? ⇒ Boolean
Whether to use YAML serialization.
Constructor Details
#initialize(xsd_mode: :include_all, resolution_mode: :resolved, serialization_format: :marshal) ⇒ PackageConfiguration
Returns a new instance of PackageConfiguration.
36 37 38 39 40 41 42 43 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 36 def initialize(xsd_mode: :include_all, resolution_mode: :resolved, serialization_format: :marshal) @xsd_mode = validate_mode(xsd_mode, XSD_MODES, "XSD mode") @resolution_mode = validate_mode(resolution_mode, RESOLUTION_MODES, "Resolution mode") @serialization_format = validate_mode(serialization_format, SERIALIZATION_FORMATS, "Serialization format") end |
Instance Attribute Details
#resolution_mode ⇒ Object (readonly)
Returns the value of attribute resolution_mode.
31 32 33 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 31 def resolution_mode @resolution_mode end |
#serialization_format ⇒ Object (readonly)
Returns the value of attribute serialization_format.
31 32 33 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 31 def serialization_format @serialization_format end |
#xsd_mode ⇒ Object (readonly)
Returns the value of attribute xsd_mode.
31 32 33 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 31 def xsd_mode @xsd_mode end |
Class Method Details
.from_hash(data) ⇒ PackageConfiguration
Create from hash
97 98 99 100 101 102 103 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 97 def self.from_hash(data) new( xsd_mode: data[:xsd_mode] || data["xsd_mode"], resolution_mode: data[:resolution_mode] || data["resolution_mode"], serialization_format: data[:serialization_format] || data["serialization_format"] || :marshal, ) end |
Instance Method Details
#allow_external_xsds? ⇒ Boolean
Returns Whether to allow external XSD references.
51 52 53 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 51 def allow_external_xsds? @xsd_mode == :allow_external end |
#bare_package? ⇒ Boolean
Returns Whether package requires parsing on load.
61 62 63 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 61 def @resolution_mode == :bare end |
#include_all_xsds? ⇒ Boolean
Returns Whether to include all XSD files in package.
46 47 48 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 46 def include_all_xsds? @xsd_mode == :include_all end |
#json_format? ⇒ Boolean
Returns Whether to use JSON serialization.
71 72 73 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 71 def json_format? @serialization_format == :json end |
#marshal_format? ⇒ Boolean
Returns Whether to use marshal serialization.
66 67 68 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 66 def marshal_format? @serialization_format == :marshal end |
#parse_format? ⇒ Boolean
Returns Whether to parse XSD files (no serialization).
81 82 83 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 81 def parse_format? @serialization_format == :parse end |
#resolved_package? ⇒ Boolean
Returns Whether package includes pre-resolved schemas.
56 57 58 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 56 def resolved_package? @resolution_mode == :resolved end |
#to_h ⇒ Hash
Returns Configuration as hash.
86 87 88 89 90 91 92 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 86 def to_h { xsd_mode: @xsd_mode, resolution_mode: @resolution_mode, serialization_format: @serialization_format, } end |
#yaml_format? ⇒ Boolean
Returns Whether to use YAML serialization.
76 77 78 |
# File 'lib/lutaml/xsd/package_configuration.rb', line 76 def yaml_format? @serialization_format == :yaml end |