Sha256: bae572385fbe1e23c4d3cb8fdca1d74c4413d4c2c4973ac3ed531051f3f5becd

Contents?: true

Size: 1.69 KB

Versions: 25

Compression:

Stored size: 1.69 KB

Contents

# mdJson 2.0 writer

# History:
#   Stan Smith 2017-03-10 refactored for mdJson/mdTranslator 2.0
#   Josh Bradley original script

require 'jbuilder'
require_relative 'version'
require_relative 'sections/mdJson_mdJson'

module ADIWG
   module Mdtranslator
      module Writers
         module MdJson

            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[:writerFormat] = 'json'
               responseObj[:writerVersion] = ADIWG::Mdtranslator::Writers::MdJson::VERSION

               # 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

            # ignore jBuilder object mapping when array is empty
            def self.json_map(collection = [], _class)
               if collection.nil? || collection.empty?
                  return nil
               else
                  collection.map { |item| _class.build(item).attributes! }
               end
            end

         end
      end
   end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.6.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.5.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.4.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.3.5 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.3.4 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.3.3 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.3.2 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.3.1 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.3.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.2.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.1.2 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.1.1 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.1.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.0.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.0.0rc13 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.0.0rc11 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.0.0rc10 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.0.0rc9 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.0.0rc8 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.0.0rc7 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb