Sha256: d0eae39ecdf424003c2f4c18f1fe9c05716f5212efe7e3e568fac068c128fbc3

Contents?: true

Size: 742 Bytes

Versions: 3

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

module LiquidDiagrams
  module Renderers
    class ErdRenderer < BasicRenderer
      OPTIONS = %w[
        config
        edge
      ].freeze

      SWITCHES = {
        'dot-entity' => false
      }.freeze

      XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze

      def render
        Rendering.render_with_stdin_stdout(build_command, @content).sub(XML_REGEX, '')
      end

      def build_command
        command = +'erd --fmt=svg'

        @config.slice(*OPTIONS).each do |opt, value|
          command << " --#{opt}=#{value}"
        end

        Utils.merge(SWITCHES, @config).each do |switch, value|
          command << " --#{switch}" if value
        end

        command
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
liquid-diagrams-0.3.0 lib/liquid_diagrams/renderers/erd_renderer.rb
liquid-diagrams-0.2.0 lib/liquid_diagrams/renderers/erd_renderer.rb
liquid-diagrams-0.1.0 lib/liquid_diagrams/renderers/erd_renderer.rb