Module: Asciidoctor::Diagram::CliGenerator
- Includes:
- Logging
- Included in:
- AsciiToSvgConverter, BpmnConverter, BytefieldConverter, D2Converter, DbmlConverter, DiagramsConverter, DpicConverter, ErdConverter, GnuplotConverter, GraphvizConverter, GraphvizPyConverter, LilypondConverter, MermaidConverter, MscgenConverter, NomnomlConverter, PenroseConverter, PikchrConverter, ShaapeConverter, SmcatConverter, SvgbobConverter, SymbolatorConverter, SyntraxConverter, TikZConverter, UmletConverter, VegaConverter, WavedromConverter
- Defined in:
- lib/asciidoctor-diagram/util/cli_generator.rb
Instance Method Summary collapse
- #generate_file(tool, input_ext, output_ext, code) ⇒ Object
- #generate_file_stdout(tool, input_ext, code) ⇒ Object
- #generate_stdin(tool, format, code) ⇒ Object
- #generate_stdin_file(tool, code, target_file_path) ⇒ Object
- #generate_stdin_stdout(tool, code) ⇒ Object
Instance Method Details
#generate_file(tool, input_ext, output_ext, code) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/asciidoctor-diagram/util/cli_generator.rb', line 37 def generate_file(tool, input_ext, output_ext, code) tool_name = File.basename(tool) source_file = Tempfile.new([tool_name, ".#{input_ext}"]) begin File.write(source_file.path, code) target_file = Tempfile.new([tool_name, ".#{output_ext}"]) begin target_file.close opts = yield tool, source_file.path, target_file.path generate(opts, target_file.path) ensure target_file.unlink end ensure source_file.unlink end end |
#generate_file_stdout(tool, input_ext, code) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/asciidoctor-diagram/util/cli_generator.rb', line 59 def generate_file_stdout(tool, input_ext, code) tool_name = File.basename(tool) source_file = Tempfile.new([tool_name, ".#{input_ext}"]) begin File.write(source_file.path, code) opts = yield tool, source_file.path generate(opts, :stdout) ensure source_file.unlink end end |
#generate_stdin(tool, format, code) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/asciidoctor-diagram/util/cli_generator.rb', line 11 def generate_stdin(tool, format, code) target_file = Tempfile.new([File.basename(tool), ".#{format}"]) begin target_file.close generate_stdin_file(tool, code, target_file.path) do |t| yield t, target_file.path end ensure target_file.unlink end end |
#generate_stdin_file(tool, code, target_file_path) ⇒ Object
23 24 25 26 |
# File 'lib/asciidoctor-diagram/util/cli_generator.rb', line 23 def generate_stdin_file(tool, code, target_file_path) opts = yield tool generate(opts, target_file_path, :stdin_data => code) end |
#generate_stdin_stdout(tool, code) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/asciidoctor-diagram/util/cli_generator.rb', line 28 def generate_stdin_stdout(tool, code) if block_given? opts = yield tool else opts = [tool] end generate(opts, :stdout, :stdin_data => code, :binmode => true) end |