class Yoda::Commands::Top

Public Instance Methods

complete(position) click to toggle source
# File lib/yoda/commands.rb, line 30
def complete(position)
  process_class_options
  Commands::Complete.run(position)
end
infer(position) click to toggle source
# File lib/yoda/commands.rb, line 24
def infer(position)
  process_class_options
  Commands::Infer.run(position)
end
server() click to toggle source
# File lib/yoda/commands.rb, line 36
def server
  process_class_options
  Server.new.run
end
setup() click to toggle source
# File lib/yoda/commands.rb, line 18
def setup
  process_class_options
  Commands::Setup.run(force_build: options[:force_build])
end

Private Instance Methods

process_class_options() click to toggle source
# File lib/yoda/commands.rb, line 43
def process_class_options
  set_log_level
  use_profiler_if_enabled
end
set_log_level() click to toggle source
# File lib/yoda/commands.rb, line 48
def set_log_level
  Yoda::Logger.log_level = options[:log_level].to_sym if options[:log_level]
end
use_profiler_if_enabled() click to toggle source
# File lib/yoda/commands.rb, line 52
def use_profiler_if_enabled
  if options[:profile]
    require 'stackprof'
    require 'securerandom'
    Logger.info('Enabled profiler')
    StackProf.start(mode: :wall, raw: true)

    at_exit do
      StackProf.stop
      tmpfile_path = File.expand_path(SecureRandom.hex(12), Dir.tmpdir)
      StackProf.results(tmpfile_path)
      Logger.fatal("Dumped file to: #{tmpfile_path}")
    end
  end
end