Class: Mrubyc::Debugger::Bootstrap

Inherits:
Thor
  • Object
show all
Defined in:
lib/mrubyc/debugger.rb

Instance Method Summary collapse

Instance Method Details

#startObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/mrubyc/debugger.rb', line 21

def start
  result = Mrubyc::Debugger::Config.check
  unless result
    puts "\e[31;1m"
    puts 'Error'
    result[:messages].each do |message|
      puts '  ' + message
    end
    puts "\e[0m"
    exit(1)
  end
  mrblib_dir = if File.exists?('.mrubycconfig')
    config = YAML.load_file('.mrubycconfig')
    config['mruby_lib_dir']
  else
    ENV['GEM_ENV'] == 'test' ? 'spec/fixtures/files' : 'mrblib'
  end
  models = Dir.glob(File.join(Dir.pwd, mrblib_dir, "models", "*.rb"))
  loops = Dir.glob(File.join(Dir.pwd, mrblib_dir, "loops", "*.rb"))
  if loops.size == 0
    puts "Exit as no loop found"
    exit(1)
  end
 mrblibs = {
    models: models,
    loops: loops
  }
#        Mrubyc::Debugger::Mrblib.setup_models(mrblibs[:models])
  yaml = File.join(Dir.pwd, "mrubyc-debugger.yml")
  stubs = if File.exists?(yaml)
    YAML.load_file(yaml)
  else
    {}
  end
  Mrubyc::Debugger::Window.setup_models(mrblibs[:models], stubs)
  $logger = Logger.new("/tmp/mrubyc-debugger.log")
  $logger.level = if options[:debug]
    Logger::DEBUG
  else
    Logger::INFO
  end
  Mrubyc::Debugger::Window.start(mrblibs, options[:delay])
end