Module: Prmd::Combine

Defined in:
lib/prmd/commands/combine.rb

Overview

Schema combine

Class Method Summary collapse

Class Method Details

.combine(paths, options = {}) ⇒ Prmd::Schema

Merges all found schema files in the given paths into a single Schema

Parameters:

  • paths (Array<String>)
  • options (Hash<Symbol, Object>) (defaults to: {})

Returns:


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/prmd/commands/combine.rb', line 107

def self.combine(paths, options = {})
  schemata = escape_hrefs(load_schemas(paths))
  base = Prmd::Template.load_json('combine_head.json')
  schema = base['$schema']
  meta = {}
  filename = options[:meta]
  meta = Prmd.load_schema_file(filename) if filename
  if meta.nil? || meta.empty?
    if filename
      warn "Meta file (#{filename}) is empty, please fill it next time."
    else
      warn "Meta is empty, please fill it next time."
    end
    meta ||= {}
  end
  combiner = Prmd::Combiner.new(meta: meta, base: base, schema: schema)
  combiner.combine(*schemata)
end