Class: Asciidoctor::Standoc::PlantUMLBlockMacroBackend

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/standoc/macros.rb

Class Method Summary collapse

Class Method Details

.generate_attrs(attrs) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/asciidoctor/standoc/macros.rb', line 96

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



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/asciidoctor/standoc/macros.rb', line 84

def self.generate_file parent, reader
  src = reader.source
  !reader.lines.first.sub(/\s+$/, "").match /^@startuml($| )/ or
    src = "@startuml\n#{src}\n@enduml\n"
  /^@startuml (?<filename>[^\n]+)\n/ =~ src
  filename ||= parent.document.reader.lineno
  FileUtils.mkdir_p "plantuml"
  File.open("plantuml/#{filename}.pml", "w") { |f| f.write src }
  system "plantuml plantuml/#{filename}.pml"
  filename
end

.plantuml_installed?Boolean

Returns:

  • (Boolean)


72
73
74
75
76
77
78
79
80
81
82
# File 'lib/asciidoctor/standoc/macros.rb', line 72

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