# -*- coding: utf-8 -*- #============================================================================== # ** scripts-loader v1.1.0 #------------------------------------------------------------------------------ # By Joke @biloumaster # GitHub: https://github.com/RMEx/scripts-externalizer #------------------------------------------------------------------------------ # Load all scripts from the given folder # See the README.md on GitHub! #============================================================================== #============================================================================== # ** CONFIGURATION #============================================================================== module XT_CONFIG LOAD_FROM = "Scripts" # Load the scripts from the folder you want. # Can be "C:/.../MyScripts/" or "../../MyScripts/" end #============================================================================== # ** Loader #------------------------------------------------------------------------------ # Load all scripts #============================================================================== module Loader #-------------------------------------------------------------------------- # * Extend self #-------------------------------------------------------------------------- extend self #-------------------------------------------------------------------------- # * Run the loader #-------------------------------------------------------------------------- def run read_list(XT_CONFIG::LOAD_FROM + "/") end #-------------------------------------------------------------------------- # * Read a file #-------------------------------------------------------------------------- def read(file) File.open(file, 'r') { |f| f.read } end #-------------------------------------------------------------------------- # * Read a list and load all the elements #-------------------------------------------------------------------------- def read_list(path) @list = read(path + "_list.rb").split("\n") @list.each do |e| e.strip! next if e[0] == "#" if e[-1] == "/" read_list(path + e) else Kernel.send(:load, path + e + ".rb") end end end end Loader.run