# -*- encoding : utf-8 -*- class Card module Set # the set loading process has two main phases: # 1. Definition: interpret each set file, creating/defining set and # set_format modules # 2. Organization: have base classes include modules associated with the # 'all' set, and clean up the other modules module Loader # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Definition Phase # each set file calls `extend Card::Set` when loaded def extended mod register_set mod end # make the set available for use def register_set set_module if set_module.all_set? # automatically included in Card class modules[:base] << set_module else set_type = set_module.abstract_set? ? :abstract : :nonbase # made ready for dynamic loading via #include_set_modules modules[set_type][set_module.shortname] ||= [] modules[set_type][set_module.shortname] << set_module end end # # When a Card application loads, it uses set modules to autogenerate # tmp files that add module names (Card::Set::PATTERN::ANCHOR) and # extend the module with Card::Set. # # # def write_tmp_file from_file, to_file, rel_path name_parts = rel_path.gsub(/\.rb/, '').split(File::SEPARATOR) submodules = name_parts.map { |a| "module #{a.camelize};" } * ' ' file_content = <