Sha256: 8e2be317f4b668108a2c4b578a398a14bb38baf0a417cc10a5ae346a5889cf81
Contents?: true
Size: 1.52 KB
Versions: 22
Compression:
Stored size: 1.52 KB
Contents
require 'rubypitaya/core/path' module RubyPitaya class ApplicationFilesImporter def import 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.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
22 entries across 22 versions & 1 rubygems