Sha256: a7a9103c26ca2420105450b0c6e56da059370a95006144fe6356952839e858f2

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'pathname'
require 'json'

class Ree::PackageSchemaBuilder
  Schema = Ree::PackageSchema

  # @param [Ree::Package] package
  # @return [Hash]
  def call(package)
    Ree.logger.debug("generating package schema for '#{package.name}' package")

    if !package.loaded?
      raise Ree::Error.new("package schema should be loaded", :invalid_schema)
    end

    data = {
      Schema::SCHEMA_TYPE => Schema::PACKAGE,
      Schema::SCHEMA_VERSION => Schema::SCHEMA_VERSION_NUMBER,
      Schema::NAME => package.name,
      Schema::ENTRY_PATH => package.entry_rpath,
      Schema::TAGS => package.tags,
      Schema::DEPENDS_ON => package.deps.sort_by(&:name).map { |dep|
        {
          Schema::DependsOn::NAME => dep.name,
        }
      },
      Schema::ENV_VARS => package.env_vars.sort_by(&:name).map { |var|
        {
          Schema::EnvVars::NAME => var.name,
          Schema::EnvVars::DOC => var.doc,
        }
      },
      Schema::OBJECTS => package.objects.select { !_1.rpath.nil? }.sort_by(&:name).map { |object|
        {
          Schema::Objects::NAME => object.name,
          Schema::Objects::SCHEMA => object.schema_rpath,
          Schema::Objects::TAGS => object.tags
        }
      }
    }

    data
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ree-1.0.47 lib/ree/core/package_schema_builder.rb
ree-1.0.46 lib/ree/core/package_schema_builder.rb
ree-1.0.45 lib/ree/core/package_schema_builder.rb
ree-1.0.44 lib/ree/core/package_schema_builder.rb
ree-1.0.43 lib/ree/core/package_schema_builder.rb
ree-1.0.42 lib/ree/core/package_schema_builder.rb
ree-1.0.41 lib/ree/core/package_schema_builder.rb
ree-1.0.40 lib/ree/core/package_schema_builder.rb
ree-1.0.39 lib/ree/core/package_schema_builder.rb
ree-1.0.38 lib/ree/core/package_schema_builder.rb
ree-1.0.37 lib/ree/core/package_schema_builder.rb
ree-1.0.36 lib/ree/core/package_schema_builder.rb
ree-1.0.35 lib/ree/core/package_schema_builder.rb
ree-1.0.34 lib/ree/core/package_schema_builder.rb
ree-1.0.33 lib/ree/core/package_schema_builder.rb