Skip to content

Commit

Permalink
Update documentation for native transformations #216 #231 #292 #293
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric L. Charlier committed Sep 9, 2017
1 parent e5cb076 commit cc0c956
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
52 changes: 50 additions & 2 deletions _documentation/transform-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@ The element *transform* works as a modification of the content of all cells for

## Languages

At the moment, you can make usage of three different languages to define your transformation:
At the moment, you can make usage of three different languages and a few ready-to-go transformations provided by the framework to define your transformation:

* NCalc - ```ncalc```
* Format - ```format```
* C# - ```c-sharp```
* Native - ```native```

These languages support different purposes.
These options support different purposes.

*NCalc* is specifically dedicated to calculations on numerical values but also offers limited features for booleans and texts.

*Format* is a quick way to transform a *dateTime* or *numeric* to a text representation taking into account culture specific formats (leading 0, 2 or 4 digits for years, coma or point for decimal spearator and many more).

*C#* is there to support advanced transformations requiring a little bit more of code.

*Native* is a collection of ready-to-go transformations for general purposes. It's especially useful around *null*, *empty*, *blank* and *text*

| Language | source | destination
| ----------------------------
| NCalc | numeric (limited for boolean and text)| unchanged
| Format | numeric or dateTime | text
| C# | all | all
| Native | text or dateTime | text or numeric

Technically, the destination could be something else that the option(s) defined in the table above, but most of the time it has no added-value.

Expand Down Expand Up @@ -122,3 +126,47 @@ The exemple here under is transformating the content of two columns.
</row-count>
</assert>
{% endhighlight %}

### Native

Currently, you cannot assemble native transformations, it means that you're limited to use one and only one of them in a column's transformation.

Following transformations are supported by NBi v1.16

- ```blank-to-empty```: if the current content of the cell is ```blank``` (zero or many spaces) replace the content ```(empty)```
- ```blank-to-null```: if the current content of the cell is ```blank``` (zero or many spaces) replace the content ```(null)```
- ```empty-to-null```: if the current content of the cell is ```empty``` (length=0) replace the content ```(null)```
- ```null-to-empty```: if the current content of the cell is ```null``` replace the content ```(empty)```
- ```null-to-value```: if the current content of the cell is ```null``` replace the content ```(value)```
- ```any-to-any```: replaces the content of the cell by ```(any)```
- ```value-to-value```: if the cell's value is not ```null``` will replace the content by ```(value)```
- ```string-to-without-diacritics```: if the current cell's value contains any accents or diacritics, they are removed
- ```string-to-upper```: returns a copy of this string converted to uppercase
- ```string-to-lower```: returns a copy of this string converted to lowercase
- ```html-to-string```: decodes the html to a string
- ```string-to-html```: encodes the string to html
- ```string-to-trim```: removes blanks from the beginning and end of the cell.
- ```string-to-length```: returns the length of the *text* value of the cell. If the cell is ```null``` or ```empty```, it returns 0.
- ```date-to-age```: returns the age according to the *dateTime* value of the cell at the moment of execution of the test.

{% highlight xml %}
<assert>
<equalTo>
<column index="0" role="key" type="text">
<transform language="native" source-type="text">
string-to-trim
</transform>
</column>
<column index="1" role="value" type="text">
<transform language="native" source-type="text">
empty-to-null
</transform>
</column>
<column index="2" role="value" type="text">
<transform language="native" source-type="text">
any-to-value
</transform>
</column>
</row-count>
</assert>
{% endhighlight %}
2 changes: 1 addition & 1 deletion release.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h2>Looking for a specific release?</h2>
for (var i = 0; i < release.assets.length; i++) {
downloadCount += release.assets[i].download_count;
}
downloadCount += 1956;
downloadCount += 607 + 495 + 561 + 115 + 1488 + 250 + 49 + 1956;
var releaseInfo = release.name + " downloaded " + downloadCount + " times.";
$("#downloadURL").attr("href", downloadURL);
$("#downloadCount").text(downloadCount);
Expand Down

0 comments on commit cc0c956

Please sign in to comment.