PsClassUtils, is a Powershell module which contains tools to ease the work with Powershell Classes.
One cool feature is available is the fact that it can generate UML-like Class Diagrams in png format of your scripts / modules in a glimps! (See Write-CUClassDiagram
)
Since version 2.6.0
we have also added the possibility to automatically generate your pester tests for your entiere module / script / file(s).( See Write-CUPesterTest
below.)
Master | Dev | Downloads |
---|---|---|
Find-module PSClassUtils | install-Module
Release notes can be found here --> Release Notes
Get-CUClass
Get-CUClassConstructor
Get-CUClassMethod
Get-CUClassProperty
Get-CUCommands
Get-CUEnum
Get-CULoadedClass
Install-CUDiagramPrerequisites
Write-CUClassDiagram
Write-CUInterfaceImplementation
Write-CUPesterTest
Allows to generate UML diagrams of powerShell scripts / modules that contain PowerShell classes.
This module has a dependency on Kevin Marquette's PSGraph powershell module. The prerequisites can be installed either manually, or by using the following methodology:
Import-Module PSClassutils
Install-CUDiagramPreRequisites
Write-CUClassDiagram currently allows to draw diagrams (or components of diagrams) of the follow items:
- Document a Class
- it's Properties
- it's Methods
- it's Constructors
- it's Inheritance
Has a relationships (Composition) is currently not supported. (But is planned for a future release)
It is possible to draw diagrams from classes in the following different manners:
- On a folder level
- This will create a diagram and document each independant .ps1 file that contains a class. If no classes are found, it will be an empty square.
- File base (.ps1)
- you can point the function to a single .ps1 file, and will generate the diagram for all the classes located in that file.
- File base (.psm1)
- you can point the function to a single .psm1 file, and will generate the diagram for all the classes located in that file.
A script called inheritance.ps1
contains the following code:
Class Woop {
[String]$String
[int]$number
Woop([String]$String,[int]$Number){
}
[String]DoSomething(){
return $this.String
}
}
Class Wap :Woop {
[String]$prop3
DoChildthing(){}
}
Class Wep : Woop {
[String]$prop4
DoOtherChildThing(){
}
}
Write-CUClassDiagram -Path ".\Inheritance.ps1"
I took the 'liberty' to run Write-CUClassDiagram on some well known modules available on the internet that are classed based. These are all great modules, and I recommend you have a look at them!
This is the result of running Write-CUClassDiagram
on this module itself
Below is the export of the Class Diagram of a module I wrote that helps to manage HostsFiles accross the network using PowerShell classes. (The project is accessible Here)
Write-CUClassDiagram allows to generate diagrams of complex class based modules, and gives you the ability to have a global picture of any project quickly, without reading through the code. PoshBot is probably the best example:
https://github.com/Stephanevg/PSClassUtils/blob/master/PSClassUtils/Examples/06/PoshBot_Diagram.png
Since version 2.6.0
the PsClassUtils module received a few new cmdlets related to pester tests. The most interesting one is without a doubt the: Write-CUPesterTest
As it's name implies, this function allows to automatically generate your pester tests. (Click on the image below for an example.)
You feel like contributing to this project? Awesome! We are happy to hear that, and will to help you succeed in that. You can start by reading our Contribution guide.
Please don't hesitate to open an issue so we can quickly discuss about implementation details and design of your, perhaps to be, new feature of PSClassutils :)
for 'HacktOberFest' I created an issue to push people to use the module on their classes, and PR us their classes + examples.
Here under is the list of community driven contributions:
Thanks to LxLeChat !!
Acl class is used to create a 3 levels folder structure in a standardized way. The acl creates both folders and corresponding groups and set acl.