update 2023-05-22 02:53:53

This commit is contained in:
Robot 2023-05-22 02:53:56 +02:00
parent 3edd68587a
commit 719461fa0a
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
14 changed files with 1837 additions and 3979 deletions

2170
README.md

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,8 @@ class Infusion #Gold {
+ set() : void
- parsePowers() : void
- setSuperPowers() : void
- mergePowers($powers, $old) : void
- sortPowers($powers) : void
- setPowers() : void
- index(array $powers) : string
- code(object $power) : string
@ -70,6 +72,20 @@ note left of Infusion::setSuperPowers
return: void
end note
note right of Infusion::mergePowers
Merge the old missing powers found in local repository back into the index
since: 3.2.0
return: void
end note
note left of Infusion::sortPowers
Sort Powers
since: 3.2.0
return: void
end note
note right of Infusion::setPowers
Set the Powers code

View File

@ -232,9 +232,18 @@ class Infusion
array(&$context, &$path, &$key, &$powers)
);
// we add and all missing powers
if (isset($this->power->old_superpowers[$path]))
{
$this->mergePowers($powers, $this->power->old_superpowers[$path]);
}
// POWERREADME
$this->content->set_($key, 'POWERREADME', $this->reposreadme->get($powers));
// sort all powers
$this->sortPowers($powers);
// POWERINDEX
$this->content->set_($key, 'POWERINDEX', $this->index($powers));
@ -247,6 +256,34 @@ class Infusion
}
}
/**
* Merge the old missing powers found in local repository back into the index
*
* @return void
* @since 3.2.0
*/
private function mergePowers(array &$powers, array &$old)
{
foreach ($old as $guid => $values)
{
if (!isset($powers[$guid]))
{
$powers[$guid] = $values;
}
}
}
/**
* Sort Powers
*
* @return void
* @since 3.2.0
*/
private function sortPowers(array &$powers)
{
ksort($powers, SORT_STRING);
}
/**
* Set the Powers code
*

View File

@ -197,9 +197,18 @@
array(&$context, &$path, &$key, &$powers)
);
// we add and all missing powers
if (isset($this->power->old_superpowers[$path]))
{
$this->mergePowers($powers, $this->power->old_superpowers[$path]);
}
// POWERREADME
$this->content->set_($key, 'POWERREADME', $this->reposreadme->get($powers));
// sort all powers
$this->sortPowers($powers);
// POWERINDEX
$this->content->set_($key, 'POWERINDEX', $this->index($powers));
@ -212,6 +221,34 @@
}
}
/**
* Merge the old missing powers found in local repository back into the index
*
* @return void
* @since 3.2.0
*/
private function mergePowers(array &$powers, array &$old)
{
foreach ($old as $guid => $values)
{
if (!isset($powers[$guid]))
{
$powers[$guid] = $values;
}
}
}
/**
* Sort Powers
*
* @return void
* @since 3.2.0
*/
private function sortPowers(array &$powers)
{
ksort($powers, SORT_STRING);
}
/**
* Set the Powers code
*

View File

@ -18,13 +18,11 @@ class Readme #Gold {
- readmeBuilder($powers) : string
- readmeModel(array $classes) : string
- generateIndex(array $classes) : string
- generateDiagramBucket(array $classes) : string
- defineTypeOrder() : array
- sortClasses(array $classes, array $typeOrder) : void
- compareNamespace(array $a, array $b) : int
- compareType(array $a, array $b, ...) : int
- compareName(array $a, array $b) : int
- generateNamespaceDiagram(string $current_namespace, string $diagrams) : string
- indexLinkPower(string $power) : string
- linkPowerRepo(string $power) : string
- linkPowerCode(string $power) : string
@ -65,34 +63,28 @@ note right of Readme::generateIndex
return: string
end note
note left of Readme::generateDiagramBucket
Generate the diagram bucket string for classes
return: string
end note
note right of Readme::defineTypeOrder
note left of Readme::defineTypeOrder
Define the order of types for sorting purposes
since: 3.2.0
return: array
end note
note left of Readme::sortClasses
note right of Readme::sortClasses
Sort the flattened array using a single sorting function
since: 3.2.0
return: void
end note
note right of Readme::compareNamespace
note left of Readme::compareNamespace
Compare the namespace of two classes
since: 3.2.0
return: int
end note
note left of Readme::compareType
note right of Readme::compareType
Compare the type of two classes
since: 3.2.0
@ -104,19 +96,13 @@ note left of Readme::compareType
array $typeOrder
end note
note right of Readme::compareName
note left of Readme::compareName
Compare the name of two classes
since: 3.2.0
return: int
end note
note left of Readme::generateNamespaceDiagram
Generate a namespace diagram string
return: string
end note
note right of Readme::indexLinkPower
Build the Link to the power in this repository

View File

@ -123,18 +123,13 @@ class Readme
$classes = [];
foreach ($powers as $guid => $power)
{
$power_object = $this->power->get($guid);
if (isset($power_object->parsed_class_code) && is_array($power_object->parsed_class_code))
{
// add to the sort bucket
$classes[] = [
'namespace' => $power['namespace'],
'type' => $power['type'],
'name' => $power['name'],
'link' => $this->indexLinkPower($power),
'diagram' => $this->plantuml->classBasicDiagram($power, $power_object->parsed_class_code)
];
}
// add to the sort bucket
$classes[] = [
'namespace' => $power['namespace'],
'type' => $power['type'],
'name' => $power['name'],
'link' => $this->indexLinkPower($power)
];
}
return $this->readmeModel($classes);
@ -152,11 +147,7 @@ class Readme
{
$this->sortClasses($classes, $this->defineTypeOrder());
$result = $this->generateIndex($classes);
$diagram_bucket = $this->generateDiagramBucket($classes);
return $result . $diagram_bucket;
return $this->generateIndex($classes);
}
/**
@ -187,40 +178,6 @@ class Readme
return $result;
}
/**
* Generate the diagram bucket string for classes
*
* @param array $classes The sorted classes
*
* @return string The diagram bucket string
*/
private function generateDiagramBucket(array &$classes): string
{
$diagram_bucket = "\n\n# Class Diagrams\n";
$current_namespace = null;
$diagrams = '';
foreach ($classes as $class)
{
if ($class['namespace'] !== $current_namespace)
{
if ($current_namespace !== null)
{
$diagram_bucket .= $this->generateNamespaceDiagram($current_namespace, $diagrams);
}
$current_namespace = $class['namespace'];
$diagrams = '';
}
$diagrams .= $class['diagram'];
}
// Add the last namespace diagram
$diagram_bucket .= $this->generateNamespaceDiagram($current_namespace, $diagrams);
return $diagram_bucket;
}
/**
* Define the order of types for sorting purposes
*
@ -318,24 +275,6 @@ class Readme
return strcmp($a['name'], $b['name']);
}
/**
* Generate a namespace diagram string
*
* @param string $current_namespace The current namespace
* @param string $diagrams The diagrams for the namespace
*
* @return string The namespace diagram string
*/
private function generateNamespaceDiagram(string $current_namespace, string $diagrams): string
{
$namespace_title = str_replace('\\', ' ', $current_namespace);
$diagram_code = "\n## {$namespace_title}\n> namespace {$current_namespace}\n";
$diagram_code .= "```uml\n@startuml\n\n" .
$this->plantuml->namespaceDiagram($current_namespace, $diagrams) . "\n\n@enduml\n```\n";
return $diagram_code;
}
/**
* Build the Link to the power in this repository
*
@ -403,7 +342,6 @@ class Readme
private function linkPowerSPK(array &$power): string
{
return $power['spk'];
}
}
}

View File

@ -98,18 +98,13 @@
$classes = [];
foreach ($powers as $guid => $power)
{
$power_object = $this->power->get($guid);
if (isset($power_object->parsed_class_code) && is_array($power_object->parsed_class_code))
{
// add to the sort bucket
$classes[] = [
'namespace' => $power['namespace'],
'type' => $power['type'],
'name' => $power['name'],
'link' => $this->indexLinkPower($power),
'diagram' => $this->plantuml->classBasicDiagram($power, $power_object->parsed_class_code)
];
}
// add to the sort bucket
$classes[] = [
'namespace' => $power['namespace'],
'type' => $power['type'],
'name' => $power['name'],
'link' => $this->indexLinkPower($power)
];
}
return $this->readmeModel($classes);
@ -127,11 +122,7 @@
{
$this->sortClasses($classes, $this->defineTypeOrder());
$result = $this->generateIndex($classes);
$diagram_bucket = $this->generateDiagramBucket($classes);
return $result . $diagram_bucket;
return $this->generateIndex($classes);
}
/**
@ -162,40 +153,6 @@
return $result;
}
/**
* Generate the diagram bucket string for classes
*
* @param array $classes The sorted classes
*
* @return string The diagram bucket string
*/
private function generateDiagramBucket(array &$classes): string
{
$diagram_bucket = "\n\n# Class Diagrams\n";
$current_namespace = null;
$diagrams = '';
foreach ($classes as $class)
{
if ($class['namespace'] !== $current_namespace)
{
if ($current_namespace !== null)
{
$diagram_bucket .= $this->generateNamespaceDiagram($current_namespace, $diagrams);
}
$current_namespace = $class['namespace'];
$diagrams = '';
}
$diagrams .= $class['diagram'];
}
// Add the last namespace diagram
$diagram_bucket .= $this->generateNamespaceDiagram($current_namespace, $diagrams);
return $diagram_bucket;
}
/**
* Define the order of types for sorting purposes
*
@ -293,24 +250,6 @@
return strcmp($a['name'], $b['name']);
}
/**
* Generate a namespace diagram string
*
* @param string $current_namespace The current namespace
* @param string $diagrams The diagrams for the namespace
*
* @return string The namespace diagram string
*/
private function generateNamespaceDiagram(string $current_namespace, string $diagrams): string
{
$namespace_title = str_replace('\\', ' ', $current_namespace);
$diagram_code = "\n## {$namespace_title}\n> namespace {$current_namespace}\n";
$diagram_code .= "```uml\n@startuml\n\n" .
$this->plantuml->namespaceDiagram($current_namespace, $diagrams) . "\n\n@enduml\n```\n";
return $diagram_code;
}
/**
* Build the Link to the power in this repository
*
@ -378,4 +317,4 @@
private function linkPowerSPK(array &$power): string
{
return $power['spk'];
}
}

View File

@ -29,6 +29,7 @@ class Structure #Gold {
- setDynamicFolders() : void
- setSuperPowerDetails() : void
- setSuperPowerFiles(object $power, string $bom) : void
- loadExistingSuperPower(string $repository) : void
}
note right of Structure::__construct
@ -49,7 +50,7 @@ note right of Structure::__construct
?CMSApplication $app = null
end note
note right of Structure::build
note left of Structure::build
Build the Powers files, folders
since: 3.2.0
@ -69,7 +70,7 @@ note right of Structure::createFile
string $key
end note
note right of Structure::setHtaccess
note left of Structure::setHtaccess
Set the .htaccess for this power path
since: 3.2.0
@ -83,7 +84,7 @@ note right of Structure::setDynamicFolders
return: void
end note
note right of Structure::setSuperPowerDetails
note left of Structure::setSuperPowerDetails
Set the super powers details structure
since: 3.2.0
@ -96,6 +97,13 @@ note right of Structure::setSuperPowerFiles
since: 3.2.0
return: void
end note
note left of Structure::loadExistingSuperPower
Set the super power file paths
since: 3.2.0
return: void
end note
@enduml
```

View File

@ -28,6 +28,8 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
@ -372,6 +374,9 @@ class Structure
{
foreach ($this->power->superpowers as $path => $powers)
{
// get existing files
$this->loadExistingSuperPower($path);
// create the path if it does not exist
$this->folder->create($path, false);
@ -424,6 +429,22 @@ class Structure
}
}
}
/**
* Set the super power file paths
*
* @param string $repository The super power repository
*
* @return void
* @since 3.2.0
*/
private function loadExistingSuperPower(string $repository)
{
if (($content = FileHelper::getContent($repository . '/super-powers.json', null)) !== null &&
JsonHelper::check($content))
{
$this->power->old_superpowers[$repository] = json_decode($content, true);
}
}
}

View File

@ -332,6 +332,9 @@
{
foreach ($this->power->superpowers as $path => $powers)
{
// get existing files
$this->loadExistingSuperPower($path);
// create the path if it does not exist
$this->folder->create($path, false);
@ -384,3 +387,20 @@
}
}
}
/**
* Set the super power file paths
*
* @param string $repository The super power repository
*
* @return void
* @since 3.2.0
*/
private function loadExistingSuperPower(string $repository)
{
if (($content = FileHelper::getContent($repository . '/super-powers.json', null)) !== null &&
JsonHelper::check($content))
{
$this->power->old_superpowers[$repository] = json_decode($content, true);
}
}

View File

@ -63,6 +63,14 @@
"as": "default"
},
"use_selection13": {
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
"as": "default"
},
"use_selection14": {
"use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0",
"as": "default"
},
"use_selection15": {
"use": "500f3a7f-c16d-4dd4-81b2-2df6776b5388",
"as": "default"
}

View File

@ -69,6 +69,14 @@ class Power implements PowerInterface
**/
public array $superpowers = [];
/**
* Old super powers found in the local repos
*
* @var array
* @since 3.2.0
**/
public array $old_superpowers = [];
/**
* The url to the power, if there is an error.
*

View File

@ -30,6 +30,14 @@
**/
public array $superpowers = [];
/**
* Old super powers found in the local repos
*
* @var array
* @since 3.2.0
**/
public array $old_superpowers = [];
/**
* The url to the power, if there is an error.
*

File diff suppressed because it is too large Load Diff