Sha256: 997ae8ee193bd051e2af707d987dc5507539206c2e1f9a0d84e111d4f821b065
Contents?: true
Size: 1.33 KB
Versions: 9
Compression:
Stored size: 1.33 KB
Contents
module Zeus class LoadTracking class << self def features_loaded_by(&block) old_features = all_features() yield new_features = all_features() - old_features return new_features end def add_feature(file) path = if File.exist?(File.expand_path(file)) File.expand_path(file) else find_in_load_path(file) end add_extra_feature(path) if path end private def all_features untracked = defined?($untracked_features) ? $untracked_features : [] $LOADED_FEATURES + untracked end def add_extra_feature(path) $untracked_features ||= [] $untracked_features << path end def find_in_load_path(file) $LOAD_PATH.map { |path| "#{path}/#{file}" }.detect{ |file| File.exist? file } end end end end module Kernel def load(file, *a) Kernel.load(file, *a) end class << self alias_method :__load_without_zeus, :load def load(file, *a) Zeus::LoadTracking.add_feature(file) __load_without_zeus(file, *a) end end end require 'yaml' module YAML class << self alias_method :__load_file_without_zeus, :load_file def load_file(file, *a) Zeus::LoadTracking.add_feature(file) __load_file_without_zeus(file, *a) end end end
Version data entries
9 entries across 9 versions & 1 rubygems