Module: AocRb::AppLoader
Constant Summary collapse
- RUBY =
Gem.ruby
- EXECUTABLES =
["bin/aoc", "script/aoc"]
Instance Method Summary collapse
Instance Method Details
#exec_app ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 ⇒ Object
31 32 33 |
# File 'lib/aoc_rb/app_loader.rb', line 31 def find_executable EXECUTABLES.find { |exe| File.file?(exe) } end |