Class: Snapbot::Diagram::DotGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/snapbot/diagram/dot_generator.rb

Overview

Get a visual handle on what small constellations of objects we’re creating in specs

Instance Method Summary collapse

Constructor Details

#initialize(label: "g", attrs: false, ignore_lets: %i[], rspec: false) ⇒ DotGenerator

Returns a new instance of DotGenerator.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/snapbot/diagram/dot_generator.rb', line 15

def initialize(label: "g", attrs: false, ignore_lets: i[], rspec: false)
  @label = label
  @options = { attrs: attrs }
  @ignore_lets = ignore_lets

  @lets_by_value = if rspec
                     example = binding.of_caller(1).eval("self")
                     collect_lets(example)
                   else
                     {}
                   end
end

Instance Method Details

#dotObject



28
29
30
31
# File 'lib/snapbot/diagram/dot_generator.rb', line 28

def dot
  renderer = ERB.new(template, trim_mode: "-")
  renderer.result(self.binding)
end