lib/card/set/loader.rb in card-1.19.4 vs lib/card/set/loader.rb in card-1.19.5

- old
+ new

@@ -50,18 +50,39 @@ parts.map! &:camelize [parts.shift, parts] end def tmp_file_template pattern, modules, content_path + content = File.read(content_path) + wrapped_content = tmp_file_wrapped_content content_path, content + + # TODO: load directly without tmp file + return wrapped_content if content =~ /\A#!\s?simple load/ + submodules = modules.map { |m| "module #{m};" } + if content =~ /\A#!\s?not? set module/ + submodules.pop + else + submodules[-1] += " extend Card::Set" + end + tmp_file_frame pattern, submodules, wrapped_content + end + + def tmp_file_frame pattern, submodules, content <<-RUBY # -*- encoding : utf-8 -*- -class Card; module Set; class #{pattern}; #{submodules * ' '} extend Card::Set +class Card; module Set; class #{pattern}; #{submodules.join ' '} +#{content} +end;end;end;#{'end;' * submodules.size} +RUBY + end + + def tmp_file_wrapped_content content_path, content +<<-RUBY # ~~ above autogenerated; below pulled from #{content_path} ~~ -#{File.read content_path} +#{content} # ~~ below autogenerated; above pulled from #{content_path} ~~ -end;end;end;#{'end;' * submodules.size} RUBY end # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Organization Phase