module ADIWG::Mdtranslator::Writers::MdJson

Constants

VERSION

Public Class Methods

json_map(collection = [], _class) click to toggle source

ignore jBuilder object mapping when array is empty

# File lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb, line 46
def self.json_map(collection = [], _class)
   if collection.nil? || collection.empty?
      return nil
   else
      collection.map { |item| _class.build(item).attributes! }
   end
end
startWriter(intObj, responseObj) click to toggle source
# File lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb, line 17
def self.startWriter(intObj, responseObj)

   @intObj = intObj

   # set output flag for null properties
   Jbuilder.ignore_nil(!responseObj[:writerShowTags])

   # set the format of the output file based on the writer specified
   responseObj[:writerOutputFormat] = 'json'
   schemaVersion = Gem::Specification.find_by_name('adiwg-mdjson_schemas').version.to_s
   responseObj[:writerVersion] = schemaVersion

   # write the mdJson metadata record
   metadata = MdJson.build(intObj, responseObj)

   # set writer pass to true if no messages
   # false or warning will be set by code that places the message
   responseObj[:writerPass] = true if responseObj[:writerMessages].empty?

   # generated mdJson is not validated against schema
   # mdJson record may be partial
   # or mdJson may be conversion from other format destined for mdEditor

   # encode the metadata target as JSON
   metadata.target!

end