Sha256: 709641b87da343a7eb54be235f0b7e52c189e45dc58db989b958ecbed5e70697

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require_relative "serializer"
require_relative "common_utils"

module Oscal
  class Profile
    include Serializer
    include CommonUtils

    KEY = %i(uuid metadata imports merge modify back_matter)
    attr_accessor *KEY

    attr_serializable *KEY

    def initialize(uuid, metadata, imports, merge, modify, back_matter)
      @uuid        = uuid
      @metadata    = MetadataBlock.new(metadata)
      @imports     = ImportObject.wrap(imports) if imports
      @merge       = Merge.wrap(merge) if merge
      @modify      = Modify.wrap(modify) if modify
      @back_matter = BackMatter.wrap(back_matter) if back_matter
    end

    def self.load_from_yaml(path)
      yaml_data     = safe_load_yaml(path)
      yaml_profile  = yaml_data["profile"]

      uuid          = yaml_profile["uuid"]
      metadata      = yaml_profile["metadata"]
      imports       = yaml_profile["imports"]
      merge         = yaml_profile["merge"]
      modify        = yaml_profile["modify"]
      back_matter   = yaml_profile["back-matter"]

      Profile.new(uuid, metadata, imports, merge, modify, back_matter)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oscal-0.2.3 lib/oscal/profile.rb
oscal-0.2.2 lib/oscal/profile.rb
oscal-0.2.0 lib/oscal/profile.rb