Class: Gvg::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/gvg/cli.rb

Instance Method Summary collapse

Instance Method Details

#generateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gvg/cli.rb', line 16

def generate
  agnot = Gvg::Agnot.new
  parser = Gvg::Parser.new
  defaults = { source: File.join(resource_path(), 'hello.json'), destination: '/tmp/hello.vxml' }
  notfound = File.join(resource_path(), '404.json')

  source = options[:source] || defaults[:source]
  source = File.file?(source) ? source : notfound

  automaton = parser.parse(source)

  agnot.start
  states = automaton['states']
  for state in states
    agnot.send(state['type'], state['audio'])
  end
  agnot.stop
end