Class: Expressir::Package::Metadata
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Expressir::Package::Metadata
- Defined in:
- lib/expressir/package/metadata.rb
Overview
Package metadata with serialization support Stores configuration and statistics for LER packages
Instance Method Summary collapse
-
#to_h ⇒ Hash
Convert metadata to hash.
-
#validate ⇒ Hash
Validate metadata configuration.
Instance Method Details
#to_h ⇒ Hash
Convert metadata to hash
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/expressir/package/metadata.rb', line 64 def to_h { "name" => name, "version" => version, "description" => description, "created_at" => created_at, "created_by" => created_by, "expressir_version" => expressir_version, "express_mode" => express_mode, "resolution_mode" => resolution_mode, "serialization_format" => serialization_format, "files" => files, "schemas" => schemas, } end |
#validate ⇒ Hash
Validate metadata configuration
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/expressir/package/metadata.rb', line 38 def validate errors = [] errors << "name is required" if name.nil? || name.empty? errors << "version is required" if version.nil? || version.empty? unless %w[include_all allow_external].include?(express_mode) errors << "express_mode must be 'include_all' or 'allow_external'" end unless %w[resolved bare].include?(resolution_mode) errors << "resolution_mode must be 'resolved' or 'bare'" end unless %w[marshal json yaml].include?(serialization_format) errors << "serialization_format must be 'marshal', 'json', or 'yaml'" end { valid?: errors.empty?, errors: errors, } end |