Class: Asciidoctor::ISO::PlantUMLBlockMacroBackend
- Inherits:
-
Object
- Object
- Asciidoctor::ISO::PlantUMLBlockMacroBackend
- Defined in:
- lib/asciidoctor/iso/macros.rb
Class Method Summary collapse
- .generate_attrs(attrs) ⇒ Object
- .generate_file(parent, reader) ⇒ Object
- .plantuml_installed? ⇒ Boolean
Class Method Details
.generate_attrs(attrs) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/asciidoctor/iso/macros.rb', line 66 def self.generate_attrs attrs through_attrs = %w(id align float title role width height alt). inject({}) do |memo, key| memo[key] = attrs[key] if attrs.has_key? key memo end end |
.generate_file(parent, reader) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/asciidoctor/iso/macros.rb', line 55 def self.generate_file parent, reader src = reader.source reader.lines.first.sub(/\s+$/, "") != "@startuml" or src = "@startuml\n#{src}\n@enduml\n" filename = parent.document.reader.lineno system "mkdir -p plantuml" File.open("plantuml/#{filename}.pml", "w") { |f| f.write src } system "plantuml plantuml/#{filename}.pml" filename end |
.plantuml_installed? ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/asciidoctor/iso/macros.rb', line 43 def self.plantuml_installed? cmd = "plantuml" exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) end end nil end |