Sha256: 38624298d774a29f25492e7a66d554f0469ed08070c8e984109a91c5cf75ebc7

Contents?: true

Size: 1.78 KB

Versions: 45

Compression:

Stored size: 1.78 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 'rubygems'
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[: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

            # 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

45 entries across 45 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.19.0.pre.beta.31 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.30 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.29 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.28 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.27 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.26 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.13 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.12 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.11 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.10 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.9 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.8 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.19.0.pre.beta.7 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.18.4 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.18.2 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.18.1 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.18.0 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.18.0rc9 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.18.0rc8 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb
adiwg-mdtranslator-2.18.0rc7 lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb