Class: Expressir::Package::Metadata

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/expressir/package/metadata.rb

Overview

Package metadata with serialization support Stores configuration and statistics for LER packages

Instance Method Summary collapse

Instance Method Details

#to_hHash

Convert metadata to hash

Returns:

  • (Hash)

    Metadata as 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

#validateHash

Validate metadata configuration

Returns:

  • (Hash)

    Validation result with :valid? and :errors



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