vernou / textdatabuilder Goto Github PK
View Code? Open in Web Editor NEWBuild text file with datas (sql, csv, json, xml, ...)
License: MIT License
Build text file with datas (sql, csv, json, xml, ...)
License: MIT License
A tag has the structure @{PrototypeName Parameter1=Value1, Parameter2="Value2"}.
We need to evolve the tag class to parse parameter.
For example :
@{Prototype1 Parameter1=Value1, Parameter2="Value 2"}
@{Prototype2 Parameter1 = Value1 , Parameter2 = "Value 2" }
@{Prototype3 Paths = "C:\Temp\Folder 1,C:\Temp\Folder 2"}
Prototype | Parameter | Value |
---|---|---|
MyPrototype1 | Parameter1 | Value1 |
Parameter2 | Value 2 | |
MyPrototype2 | Parameter1 | Value1 |
Parameter2 | Value 2 | |
MyPrototype3 | Paths | C:\Temp\Folder 1,C:\Temp\Folder 2 |
We need a configuration to use VS Code.
We need modify the separator of tag's parameters to be blank char (like HTML attribute separator).
Example :
@{Tag Param1=Value1 Param2=Value2}
@{Tag Param1=Value1
Param2=Value2}
A template is text that describe how generate the text data.
First, the template is raw text and the generated text will be a copy of raw text.
For example :
This is the text of template.
Maybe a second line.
Result :
This is the text of template.
Maybe a second line.
We need to add a prototype CSV.
Example :
My.csv
Value1,Value2,Valu3
Value4,Value5,Valu6
Template.txt
@{CSV Path="My.csv"}
Column 1 : {0}, Column 2 : {1}, Column 3 : {0}
@{EndCSV}
Result
Column 1 : Value1, Column 2 : Value2, Column 3 : Value3
Column 1 : Value4, Column 2 : Value5, Column 3 : Value6
We need follow the code coverage evolution.
We need to add the possibility to use 'Data tag' in 'Content tag'.
Example :
{CSV Path="file.csv"}
{0}, @{RandomInterger Min=27 Max=42}, {2}, @{Text Raw="End"}
{/CSV}
file.csv
Val1,Val2,Val3
Val4,Val5,Val6
Val7,Val8,Val9
Result :
Val1, 32, Val3, End
Val3, 37, Val6, End
Val7, 29, Val9, End
To help to correct the template, we need to display the line number that raise the error.
We need to add three examples of template to demonstrate how use the program :
The rule is :
If the commit has code coverage equal or greater than 80% then
the commit has the success status
else
the commit has the fail status
But the pull request #39 have 85.51% coverage and has the fail status :
We need to disable the Path Status from Codecov :
https://docs.codecov.io/docs/commit-status#section-patch-status
Example of Codecov settings where the Path Status is disable :
https://github.com/junit-team/junit5/blob/f681af72f8d4c97bc61d5643c6f43f1d313b629b/.codecov.yml
If you execute :
..\sources\TextDataBuilder\bin\Debug\netcoreapp3.0\TextDataBuilder.exe .\random_number.txt
Result :
Unhandled exception. System.InvalidOperationException: Expected ',' between parameters.
at TextDataBuilder.Parser.Tag.ParseParameters(Browser browser) in .\sources\TextDataBuilder\Parser\Tag.cs:line 58
at TextDataBuilder.Parser.Tag.Parse(String text) in .\sources\TextDataBuilder\Parser\Tag.cs:line 24
at TextDataBuilder.Parser.Tag.<>c__DisplayClass1_0.<.ctor>b__0() in .\sources\TextDataBuilder\Parser\Tag.cs:line 14
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at TextDataBuilder.Parser.Tag.get_Name() in .\sources\TextDataBuilder\Parser\Tag.cs:line 17
at TextDataBuilder.Parser.TemplateParser.ParseTag(Browser browser) in .\sources\TextDataBuilder\Parser\TemplateParser.cs:line 54
at TextDataBuilder.Parser.TemplateParser.Parse(Browser browser) in .\sources\TextDataBuilder\Parser\TemplateParser.cs:line 37
at TextDataBuilder.Program.Main(String[] args) in .\sources\TextDataBuilder\Program.cs:line 21
We want the architecture :
We need to explain how use the program in the readme.
All tag can have the parameter 'As'. This parameter is to distinguish tag based on the same prototype.
Example :
I am @{RandomInteger As=MyAge, Min=15, Max=20}.
My sister is @{RandomInteger As=SisterAge, Min=25, Max=30}
The first argument is the template file path.
We need to parse a tag to prototype CSV.
Example :
My.csv
Value1,Value2,Valu3
Value4,Value5,Valu6
Template.txt
@{CSV Path="My.csv"}
Column 1 : {0}, Column 2 : {1}, Column 3 : {2}
@{EndCSV}
Result
Column 1 : Value1, Column 2 : Value2, Column 3 : Value3
Column 1 : Value4, Column 2 : Value5, Column 3 : Value6
The methods ParseRandomInteger
and ParseRawText
has the same structure.
We need refactor the code to facilitate the addition of the next prototypes.
On pull request and push :
The tag's parameter As
make a alias to the tag.
It is then possible to add a tag with the name of the alias to reprint the value generated by the precedent tag.
Example :
I am @{RandomInteger As=Age, Min=10, Max=20}.
At @{Age}, we can do a lot of thing.
Actually, end tag is 'End' + tag's name.
We want end tag like HTML, '/' + tag's name.
it's more succinct syntax.
Example with CSV tag :
My.csv
Value1,Value2,Valu3
Value4,Value5,Valu6
Template.txt
@{CSV Path="My.csv"}
Column 1 : {0}, Column 2 : {1}, Column 3 : {0}
@{/CSV}
Result
Column 1 : Value1, Column 2 : Value2, Column 3 : Value3
Column 1 : Value4, Column 2 : Value5, Column 3 : Value6
Add a prototype to display a random integer.
Name : Random integer
Parameters :
Name | Type | Required | Default |
---|---|---|---|
Min | Integer | No | 0 |
Max | Integer | No | int.MaxValue |
When :
@{FirstTag} and @{SecondTag}
Result :
FirstTag and @{SecondTag}
Expected :
FirstTag and SecondTag
When we add/rename/remove a test, the refresh action don't work on the text explorer.
The refresh fail with the error :
Error running command extension.refreshObjectExplorerNode:
command extension.refreshObjectExplorerNode' not found.
This is likely caused by the extension that contributes extension.refreshObjectExplorerNode.
Actually, we need restart VS Code to refresh the tests discovered.
The pull request #30 is in fail status because default Codecov settings are not suitable for the project.
We need add Codecov settings to success pull request commit when the code coverage is equal or greater than 80%.
Add a prototype to display a raw text
Name : Text
Parameters :
Name | Type | Required | Default |
---|---|---|---|
Raw | String | Yes |
A tag is characters will be replaced by generated text. It has the structure @{PrototypeName}.
We need to add the parameter Join
to prototype CSV.
Join
is string to put at the end each line, except in the last line.
Example :
My.csv
Value1,Value2,Value3
Value4,Value5,Value6
Value7,Value8,Value9
Template.txt
INSERT INTO MyTable (Col1, Col2, Col3)
VALUES
@{CSV Path="My.csv" Join=","}
({0}, {1}, {2})
@{/CSV}
Result
INSERT INTO MyTable (Col1, Col2, Col3)
VALUES
(Value1, Value2, Value3),
(Value4, Value5, Value6),
(Value7, Value8, Value9)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.