Refactor: autoload, OOP cleanup, and spec improvements#420
Conversation
b6455d7 to
6629101
Compare
|
@ronaldtse Merged main into this (a ton of discrepancies), it failed badly, you will need to get it working. Not to be included in this release, marking as draft until it matures. As I have no idea what you are doing, merging main into this PR to make it ready for merging is your responsibillity... |
e1fc4af to
8b47b85
Compare
8b47b85 to
400b7d0
Compare
|
@opoudjis this is ready. |
The main->branch merge surfaced three breakages, all on the refactor side: 1. site_generator_spec.rb: the refactor moved let(:output_directory) into each context but missed "with output format extensions" (the #418 group), so output_directory was undefined there (5 failures). Add the let. 2. ConfigExporter::FLAVOR_FILE_PATTERNS was a stale duplicate of flavor.rb's EXPORT_CONFIG_FLAVOR_FILES and lacked the .xsl/.yaml globs merged from #421/#423, so export-config dropped flavor XSLT and .yaml i18n files (1 failure). Add the globs to the live ConfigExporter list, and delete the now-dead flavor.rb export methods + constant (no callers since export_config routes through ConfigExporter) to remove the duplication that caused the divergence. This also clears the 4 rubocop offenses that lived in that dead block. 3. export_config_spec.rb: collapse the per-file File.exist? assertions into a loop, clearing the two over-long lines and the redundant Dir.exist? guard before FileUtils.rm_rf.
|
Pushed 1. 2. 3. rubocop — 7 offenses. 4 were in the dead flavor.rb block (gone with #2); the other 3 were over-long lines + a redundant Verified locally: 🤖 |
Changes
Architecture
require "metanorma/cli/*"converted to Rubyautoloadin parent namespace files. Createdlib/metanorma/cli/commands.rbfor theCommandsnamespace autoloads.cli/flavor.rbconverted from reopening theCommandclass to a properFlavorMethodsmodule, included viainclude FlavorMethods.export_config_*methods (~100 lines) extracted from the flavor helpers into a dedicatedMetanorma::Cli::ConfigExporterclass.Code Quality
require_relative "flavor"fromcommand.rb(last require_relative in lib/)public_send(:[], h)→acc[h]andpublic_send(:[]=, ...)→acc[...] = valueinCommands::Configmanifest[:template]&.public_send(node.to_s)with direct attribute access inSiteGeneratorcollection_file?andselect_source_collection_filespublic query methodsSpecs
double()withinstance_double()(type-checked) in collection and compiler specssend()on private methods in site_generator_specConfigExporterclassNote
stringify_all_keys.rbis dead code (require commented out everywhere) — flagged for removal in a follow-up.