nitweb: factorize catalog building
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 2 Aug 2016 18:08:33 +0000 (14:08 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 10 Aug 2016 19:46:25 +0000 (15:46 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/nitweb.nit

index 7c34e87..3f3b7f5 100644 (file)
@@ -38,12 +38,9 @@ end
 # Phase that builds the model and wait for http request to serve pages.
 private class NitwebPhase
        super Phase
-       redef fun process_mainmodule(mainmodule, mmodules)
-       do
-               var model = mainmodule.model
-               var modelbuilder = toolcontext.modelbuilder
 
-               # Build catalog
+       # Build the nit catalog used in homepage.
+       fun build_catalog(model: Model, modelbuilder: ModelBuilder): Catalog do
                var catalog = new Catalog(modelbuilder)
                for mpackage in model.mpackages do
                        catalog.deps.add_node(mpackage)
@@ -59,6 +56,14 @@ private class NitwebPhase
                        catalog.git_info(mpackage)
                        catalog.package_page(mpackage)
                end
+               return catalog
+       end
+
+       redef fun process_mainmodule(mainmodule, mmodules)
+       do
+               var model = mainmodule.model
+               var modelbuilder = toolcontext.modelbuilder
+               var catalog = build_catalog(model, modelbuilder)
 
                # Prepare mongo connection
                var mongo = new MongoClient("mongodb://localhost:27017/")