Skip to content

Commit

Permalink
add moose-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed May 28, 2024
1 parent a62fbb9 commit fd94c17
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
67 changes: 67 additions & 0 deletions moose-wiki/Users/moose-ide/moose-exporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
layout: page
author: Benoit Verhaeghe
background: '/img/bg-wiki.jpg'
title: 'Moose Entities Exporter'
subtitle: 'Export Moose Metrics'
toc: true
---

Once you have performed many query to search for entities of interest, you might want to export the result in a file to be consumed by others software systems.
Moose IDE comes with the Moose Entities Exporter that helps you doing so.
It is possible to use the Moose Entities Browser to generate CSV using the User Interface, or programmatically by using the browser model.

## Export using the UI

## Export programmatically

Sometimes, it is easier to perform the export using programmatic approach.
It is for example the case when you want to perform export from a CI.

### Initialized your exporter

First, you will need to create a `MiExportModel` and to configure it with the data you will want to explore.

```st
exportBrowserModel := MiExportModel new.
exportBrowserModel entitiesList: collectionOfEntities.
```

Then, you might want to remove the default columns of the `MiExportModel`: `#Type` and `#Name`.
`#Type` is the string representing the type of the entity in the model, and `#Name` its moose name if some.
To remove them, simply send the `removeColumnForQueryNamed:` message to your `MiExportModel`.

```st
"Remove default column"
exportBrowserModel removeColumnForQueryNamed: #Name.
exportBrowserModel removeColumnForQueryNamed: #Type.
```

### Add column based on a custom based query

Once you have initialized your model, you can create column that will be computed based on a block.
The block will be computed for each entity of your `collectionOfEntities`.

```st
exportBrowserModel addColumnForQuery: [ :violation | violation violatedCondition name ] withName: #'Rule name'.
exportBrowserModel addColumnForQuery: [ :violation | violation violatedCondition summary ] withName: #'Rule summary'.
```

> The example above is done in combination with the Moose Critics tool to export information about Code violation.
### Export

The final step is the export of the model using the defined query.
We implemented two exporters: CSV and Markdown.

For the CSV exporter use the method `writeCSVOn:`, whereas for markdown use the methods `writeMarkdownTableOn:`.

Example:

```st
'D:/myFile.csv' asFileReference writeStreamDo: [ :aStream |
"Note this line that can be added to easily open CSV file using Excel"
aStream << 'sep=,'; << OSPlatform current lineEnding.
"Do export"
exportBrowserModel writeCSVOn: aStream ].
```
5 changes: 0 additions & 5 deletions moose-wiki/Users/moose-ide/workflow.md

This file was deleted.

1 change: 1 addition & 0 deletions moose-wiki/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Moose IDE is a group of tools that one can use to explore a model.
In this section, we group the documentation for each tool.

- [Moose IDE Browsers](Users/moose-ide/browsers)
- [Moose Exporter](Users/moose-ide/moose-exporter)

### Visualizing a model

Expand Down

0 comments on commit fd94c17

Please sign in to comment.