Class: Tavola::Demonstration

Inherits:
Object
  • Object
show all
Defined in:
lib/tavola/demonstrations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, path) ⇒ Demonstration



32
33
34
35
# File 'lib/tavola/demonstrations.rb', line 32

def initialize config, path
  @config = config
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



30
31
32
# File 'lib/tavola/demonstrations.rb', line 30

def path
  @path
end

Instance Method Details

#qed_augment(path) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/tavola/demonstrations.rb', line 51

def qed_augment path
  # Mostly a copy from Session#run in QED.
  settings = ::QED::Settings.new()
  session  = ::QED::Session.new(settings)

  io = StringIO.new
  reporter = QED::Reporter.new(io: io)
  
  session.prepare_loadpath
  session.require_libraries

  demo = ::QED::Demo.new(path, at: root)
  demo.steps

  ::QED::Evaluator.run(demo, observers: [reporter], settings: settings)

  p io
  io.string
end

#relative_pathObject



42
43
44
# File 'lib/tavola/demonstrations.rb', line 42

def relative_path
  remove_root(path)
end

#renderObject



46
47
48
49
# File 'lib/tavola/demonstrations.rb', line 46

def render
  qed_augment(path)
  # File.read(path)
end

#rootObject



37
38
39
# File 'lib/tavola/demonstrations.rb', line 37

def root
  root = @config.base_dir
end