Sha256: 45f3de066c48b0879807e6cd1c4483269fd1d5ee20e36e917d074a9478b6fc30

Contents?: true

Size: 609 Bytes

Versions: 18

Compression:

Stored size: 609 Bytes

Contents

require 'json'
require_relative '../schema'

# :nodoc:
module Prmd
  # Schema generator
  class Generator
    #
    # @param [Hash<Symbol, Object>] properties
    def initialize(properties = {})
      @properties = properties
      @base = properties.fetch(:base, {})
      @template = properties.fetch(:template)
    end

    #
    # @param [Hash<Symbol, Object>] options
    def generate(options = {})
      res = @template.result(options)
      resource_schema = JSON.parse(res)
      schema = Prmd::Schema.new
      schema.merge!(@base)
      schema.merge!(resource_schema)
      schema
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
prmd-0.14.0 lib/prmd/core/generator.rb
prmd-0.13.0 lib/prmd/core/generator.rb
prmd-0.12.0 lib/prmd/core/generator.rb
prmd-0.11.11 lib/prmd/core/generator.rb
prmd-0.11.10 lib/prmd/core/generator.rb
prmd-0.11.9 lib/prmd/core/generator.rb
prmd-0.11.8 lib/prmd/core/generator.rb
prmd-0.11.7 lib/prmd/core/generator.rb
prmd-0.11.6 lib/prmd/core/generator.rb
prmd-0.11.5 lib/prmd/core/generator.rb
prmd-0.11.4 lib/prmd/core/generator.rb
prmd-0.11.3 lib/prmd/core/generator.rb
prmd-0.11.2 lib/prmd/core/generator.rb
prmd-0.11.1 lib/prmd/core/generator.rb
prmd-0.11.0 lib/prmd/core/generator.rb
prmd-0.10.0 lib/prmd/core/generator.rb
prmd-0.9.0 lib/prmd/core/generator.rb
prmd-0.8.0 lib/prmd/core/generator.rb