Sha256: 2558b8ddfaba19e35c01d421f8ee22417894c03794f7faaaefd5d7bc11f3644e
Contents?: true
Size: 1.69 KB
Versions: 24
Compression:
Stored size: 1.69 KB
Contents
require 'rubypitaya/core/path' module RubyPitaya class ApplicationFilesImporter def import(is_cheats_enabled) app_folder_paths = Path::Plugins::APP_FOLDER_PATHS + [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH] app_folder_paths.each do |app_folder_path| app_files_path = "#{app_folder_path}/**/*.rb" gem_files = Gem.find_files(app_files_path) gem_files = gem_files.select { |a| !a[/.+_cheats.rb/] && !a[/.+_cheat.rb/] } unless is_cheats_enabled Gem.find_files(app_files_path).each do |path| require path unless path.include?('app/migrations') end end end def auto_reload require 'listen' app_folder_paths = [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH] app_files_listener = Listen.to(*app_folder_paths, only: /\.rb$/, force_polling: true, latency: 0.25, wait_for_delay: 0.1) do |modified, added, removed| import_added_files(added) reload_modified_files(modified) end app_files_listener.start end private def import_added_files(files_path) Gem.find_files(files_path).each do |path| require path puts "ADDED ruby file: #{path}" end rescue Exception => error puts "ERROR: #{error}" puts error.backtrace end def reload_modified_files(files_path) files_path.each do |path| load(path) puts "MODIFIED ruby file: #{path}" end rescue Exception => error puts "ERROR: #{error}" puts error.backtrace end end end
Version data entries
24 entries across 20 versions & 1 rubygems