lib/jekyll-diagrams/erd.rb in jekyll-diagrams-0.9.1 vs lib/jekyll-diagrams/erd.rb in jekyll-diagrams-0.9.2
- old
+ new
@@ -1,27 +1,30 @@
+# frozen_string_literal: true
+
module Jekyll
module Diagrams
class ErdBlock < Block
- CONFIGURATIONS = %w( config edge ).freeze
+ XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze
+ CONFIGURATIONS = %w[config edge].freeze
def render_svg(code, config)
command = build_command(config)
svg = render_with_stdin_stdout(command, code)
- svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
+ svg.sub!(XML_REGEX, '')
end
def build_command(config)
- command = 'erd --fmt=svg'
- command << ' --dot-entity' if config.has_key?('dot-entity')
+ command = +'erd --fmt=svg'
+ command << ' --dot-entity' if config.fetch('dot-entity', false) != false
CONFIGURATIONS.each do |conf|
- command << " --#{conf}=#{config[conf]}" if config.has_key?(conf)
+ command << " --#{conf}=#{config[conf]}" if config.key?(conf)
end
command
end
end
end
end
-Liquid::Template.register_tag(:erd, Jekyll::Diagrams::ErdBlock)
\ No newline at end of file
+Liquid::Template.register_tag(:erd, Jekyll::Diagrams::ErdBlock)