class Nanoc::Graphviz::Filter

Graphviz Filter class

Public Instance Methods

ready?() click to toggle source

check runtime envs

@return [Boolean]

# File lib/nanoc/graphviz/filter.rb, line 28
def ready?
  graphviz_ready?
end
run(content, _ = {}) click to toggle source

convert Graphviz code to image

@param [String] content Graphviz code @return [Integer] command process status @raise [RuntimeError]

# File lib/nanoc/graphviz/filter.rb, line 18
def run(content, _ = {})
  fail 'Runtime environments is not ready' unless ready?
  command = "dot -Tpng -o #{output_filename} < #{content}"
  system(command)
  $?
end

Private Instance Methods

graphviz_ready?() click to toggle source

Whether the Graphviz installed

@return [Boolean]

# File lib/nanoc/graphviz/filter.rb, line 37
def graphviz_ready?
  if system('which dot >/dev/null 2>&1')
    return true
  end
  false
end