lib/jekyll-diagrams/smcat.rb in jekyll-diagrams-0.7.1 vs lib/jekyll-diagrams/smcat.rb in jekyll-diagrams-0.8.0
- old
+ new
@@ -1,31 +1,29 @@
module Jekyll
- module Diagrams
- class SMCatBlock < Block
- CONFIGURATIONS = {
- 'input-type' => 'smcat',
- 'engine' => 'dot',
- 'direction' => 'top-down'
- }.freeze
+ module Diagrams
+ class SMCatBlock < Block
+ CONFIGURATIONS = %w( direction engine input-type ).freeze
- def render_svg(code, config)
- svg = render_with_tempfile(build_command(config), code) do |command, input, output|
- "#{command} #{input} --output-to #{output}"
- end
+ def render_svg(code, config)
+ command = build_command(config)
- svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
+ svg = render_with_stdout(command, code) do |command, input|
+ "#{command} #{input} -"
end
-
- def build_command(config)
- command = 'smcat'
- CONFIGURATIONS.merge(config).each do |conf, value|
- command << " --#{conf} #{value}"
- end
+ svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
+ end
- command
+ def build_command(config)
+ command = 'smcat'
+
+ CONFIGURATIONS.each do |conf|
+ command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
end
+
+ command
end
end
end
-
- Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)
+end
+
+Liquid::Template.register_tag(:smcat, Jekyll::Diagrams::SMCatBlock)
\ No newline at end of file