module AocRb::AppLoader

Constants

EXECUTABLES
RUBY

Public Instance Methods

exec_app() click to toggle source
# File lib/aoc_rb/app_loader.rb, line 12
def exec_app
  original_cwd = Dir.pwd

  loop do
    if exe = find_executable
      contents = File.read(exe)

      if /THIS IS THE BIN FILE/.match?(contents)
        exec RUBY, exe, *ARGV
        break
      end
    end

    Dir.chdir(original_cwd) && return if Pathname.new(Dir.pwd).root?

    Dir.chdir("..")
  end
end
find_executable() click to toggle source
# File lib/aoc_rb/app_loader.rb, line 31
def find_executable
  EXECUTABLES.find { |exe| File.file?(exe) }
end