Class: Md2key::Diagram
- Inherits:
-
Object
- Object
- Md2key::Diagram
- Defined in:
- lib/md2key/diagram.rb
Class Method Summary collapse
-
.generate_image_file(code) ⇒ Object
SEQUENCE_CONFIG_PATH = File.expand_path(‘../../assets/mermaid_sequence.config’, __dir__) GANTT_CONFIG_PATH = File.expand_path(‘../../assets/mermaid_gantt.config’, __dir__).
Class Method Details
.generate_image_file(code) ⇒ Object
SEQUENCE_CONFIG_PATH = File.expand_path(‘../../assets/mermaid_sequence.config’, __dir__) GANTT_CONFIG_PATH = File.expand_path(‘../../assets/mermaid_gantt.config’, __dir__)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/md2key/diagram.rb', line 6 def generate_image_file(code) ensure_mermaid_availability file = Tempfile.new("diagram-#{code.extension}") file.write(code.source) file.close output_dir = File.dirname(file.path) image_path = "" IO.popen("mermaid #{file.path} | grep 'saved png' | awk -F':' '\{print $2\}'", 'r+') do |info| image_path = info.read.strip file.unlink end return image_path end |