Sha256: d986d8507a7794edddbb792eaa2305e4d3ca3e75d5ec21319247909b606db170
Contents?: true
Size: 723 Bytes
Versions: 8
Compression:
Stored size: 723 Bytes
Contents
module SmallCage # load files into anonymous module class AnonymousLoader attr_reader :module, :module_names def initialize @module = Module.new @module_names = [] end def load_match_files(dir, rex) return unless File.exist?(dir) Dir.entries(dir).sort.each do |h| next unless h =~ rex module_name = Regexp.last_match(1).camelize path = File.join(dir, h) src = File.read(path) @module.module_eval(src, path) @module_names << module_name end end def self.load(dir, rex) loader = new loader.load_match_files(dir, rex) { :module => loader.module, :names => loader.module_names } end end end
Version data entries
8 entries across 8 versions & 1 rubygems