k_builder 0.0.63 → 0.0.71

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 260817fcc90386176ab82712c52a9a15e5a822b04f348a1b3f5b9ba7ea57c0dd
4
- data.tar.gz: 68587734f564fac66c1fe8378cb417f81a88539cfa1cb58f08d34a29dca288ff
3
+ metadata.gz: 608a406238f03125011e9fcf3e09eda00ec82f973ae2a2cafe99119e712b0693
4
+ data.tar.gz: 563cc5eb0c7e5aa0cadbbba6b9ad2008339ac4e758bb842b6b17a059e7d46bbd
5
5
  SHA512:
6
- metadata.gz: 57099e14149c32c39e02d85322bfa241ba5525ffe939a59824a21a67738db77a4fae2eb070cb777feb85dcaf9aa7113d107a53ed2be15e1219607a7f271f4852
7
- data.tar.gz: e2b5a3aa292859d76c69f70ff0e99d20fd2b0f5ea67be17c20f4cf338f3c5be5fb37370528f44c64ad2376a8b22f1ecd21f011581f688b72dbf60cb7f830b5c0
6
+ metadata.gz: f10c8c559770b885062ac07fa321bfffec918cf09765c1febf287221e3252edbc21e7837d6a9547b57571cc47a5f4cdd487a2c68944e7a1b02d43a7e7d30e109
7
+ data.tar.gz: 76d9c0bbcdb2d6163f4258e138c724489cab7b313c9bd0ce5ba7792ef47a6049f345b5118c5e6d397c460c3f21f8250dd625a884bab835ebf611655721d496fb
@@ -0,0 +1,103 @@
1
+ <mxfile host="65bd71144e">
2
+ <diagram id="R2lEEEUBdFMjLlhIrx00" name="Page-1">
3
+ <mxGraphModel dx="902" dy="583" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0" extFonts="Permanent Marker^https://fonts.googleapis.com/css?family=Permanent+Marker">
4
+ <root>
5
+ <mxCell id="0"/>
6
+ <mxCell id="1" parent="0"/>
7
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-1" value="" style="edgeStyle=entityRelationEdgeStyle;endArrow=ERzeroToMany;startArrow=ERone;endFill=1;startFill=0;" parent="1" source="C-vyLk0tnHw3VtMMgP7b-24" target="C-vyLk0tnHw3VtMMgP7b-6" edge="1">
8
+ <mxGeometry width="100" height="100" relative="1" as="geometry">
9
+ <mxPoint x="340" y="720" as="sourcePoint"/>
10
+ <mxPoint x="440" y="620" as="targetPoint"/>
11
+ </mxGeometry>
12
+ </mxCell>
13
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-12" value="" style="edgeStyle=entityRelationEdgeStyle;endArrow=ERzeroToMany;startArrow=ERone;endFill=1;startFill=0;" parent="1" source="C-vyLk0tnHw3VtMMgP7b-3" target="C-vyLk0tnHw3VtMMgP7b-17" edge="1">
14
+ <mxGeometry width="100" height="100" relative="1" as="geometry">
15
+ <mxPoint x="400" y="180" as="sourcePoint"/>
16
+ <mxPoint x="460" y="205" as="targetPoint"/>
17
+ </mxGeometry>
18
+ </mxCell>
19
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-2" value="Orders" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
20
+ <mxGeometry x="450" y="120" width="250" height="130" as="geometry"/>
21
+ </mxCell>
22
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-3" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
23
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
24
+ </mxCell>
25
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-4" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-3" vertex="1">
26
+ <mxGeometry width="30" height="30" as="geometry"/>
27
+ </mxCell>
28
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-5" value="order_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-3" vertex="1">
29
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
30
+ </mxCell>
31
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-6" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
32
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
33
+ </mxCell>
34
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-7" value="FK1" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-6" vertex="1">
35
+ <mxGeometry width="30" height="30" as="geometry"/>
36
+ </mxCell>
37
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-8" value="customer_id int NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-6" vertex="1">
38
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
39
+ </mxCell>
40
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-9" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
41
+ <mxGeometry y="90" width="250" height="30" as="geometry"/>
42
+ </mxCell>
43
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-10" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-9" vertex="1">
44
+ <mxGeometry width="30" height="30" as="geometry"/>
45
+ </mxCell>
46
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-11" value="order_date date NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-9" vertex="1">
47
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
48
+ </mxCell>
49
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-13" value="Shipments" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
50
+ <mxGeometry x="450" y="280" width="250" height="130" as="geometry"/>
51
+ </mxCell>
52
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-14" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
53
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
54
+ </mxCell>
55
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-15" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-14" vertex="1">
56
+ <mxGeometry width="30" height="30" as="geometry"/>
57
+ </mxCell>
58
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-16" value="shipment_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-14" vertex="1">
59
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
60
+ </mxCell>
61
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-17" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
62
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
63
+ </mxCell>
64
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-18" value="FK1" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-17" vertex="1">
65
+ <mxGeometry width="30" height="30" as="geometry"/>
66
+ </mxCell>
67
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-19" value="order_id int NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-17" vertex="1">
68
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
69
+ </mxCell>
70
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-20" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
71
+ <mxGeometry y="90" width="250" height="30" as="geometry"/>
72
+ </mxCell>
73
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-21" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-20" vertex="1">
74
+ <mxGeometry width="30" height="30" as="geometry"/>
75
+ </mxCell>
76
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-22" value="shipment_date date NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-20" vertex="1">
77
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
78
+ </mxCell>
79
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-23" value="Customers" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
80
+ <mxGeometry x="20" y="50" width="250" height="100" as="geometry"/>
81
+ </mxCell>
82
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-24" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-23" vertex="1">
83
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
84
+ </mxCell>
85
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-25" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-24" vertex="1">
86
+ <mxGeometry width="30" height="30" as="geometry"/>
87
+ </mxCell>
88
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-26" value="test_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-24" vertex="1">
89
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
90
+ </mxCell>
91
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-27" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-23" vertex="1">
92
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
93
+ </mxCell>
94
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-28" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-27" vertex="1">
95
+ <mxGeometry width="30" height="30" as="geometry"/>
96
+ </mxCell>
97
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-29" value="customer_name char(50) NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-27" vertex="1">
98
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
99
+ </mxCell>
100
+ </root>
101
+ </mxGraphModel>
102
+ </diagram>
103
+ </mxfile>
data/Sample.drawio ADDED
@@ -0,0 +1,103 @@
1
+ <mxfile host="65bd71144e">
2
+ <diagram id="R2lEEEUBdFMjLlhIrx00" name="Page-1">
3
+ <mxGraphModel dx="951" dy="448" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0" extFonts="Permanent Marker^https://fonts.googleapis.com/css?family=Permanent+Marker">
4
+ <root>
5
+ <mxCell id="0"/>
6
+ <mxCell id="1" parent="0"/>
7
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-1" value="" style="edgeStyle=entityRelationEdgeStyle;endArrow=ERzeroToMany;startArrow=ERone;endFill=1;startFill=0;" parent="1" source="C-vyLk0tnHw3VtMMgP7b-24" target="C-vyLk0tnHw3VtMMgP7b-6" edge="1">
8
+ <mxGeometry width="100" height="100" relative="1" as="geometry">
9
+ <mxPoint x="340" y="720" as="sourcePoint"/>
10
+ <mxPoint x="440" y="620" as="targetPoint"/>
11
+ </mxGeometry>
12
+ </mxCell>
13
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-12" value="" style="edgeStyle=entityRelationEdgeStyle;endArrow=ERzeroToMany;startArrow=ERone;endFill=1;startFill=0;" parent="1" source="C-vyLk0tnHw3VtMMgP7b-3" target="C-vyLk0tnHw3VtMMgP7b-17" edge="1">
14
+ <mxGeometry width="100" height="100" relative="1" as="geometry">
15
+ <mxPoint x="400" y="180" as="sourcePoint"/>
16
+ <mxPoint x="460" y="205" as="targetPoint"/>
17
+ </mxGeometry>
18
+ </mxCell>
19
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-2" value="Orders" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
20
+ <mxGeometry x="450" y="120" width="250" height="130" as="geometry"/>
21
+ </mxCell>
22
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-3" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
23
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
24
+ </mxCell>
25
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-4" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-3" vertex="1">
26
+ <mxGeometry width="30" height="30" as="geometry"/>
27
+ </mxCell>
28
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-5" value="order_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-3" vertex="1">
29
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
30
+ </mxCell>
31
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-6" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
32
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
33
+ </mxCell>
34
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-7" value="FK1" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-6" vertex="1">
35
+ <mxGeometry width="30" height="30" as="geometry"/>
36
+ </mxCell>
37
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-8" value="customer_id int NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-6" vertex="1">
38
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
39
+ </mxCell>
40
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-9" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
41
+ <mxGeometry y="90" width="250" height="30" as="geometry"/>
42
+ </mxCell>
43
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-10" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-9" vertex="1">
44
+ <mxGeometry width="30" height="30" as="geometry"/>
45
+ </mxCell>
46
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-11" value="order_date date NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-9" vertex="1">
47
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
48
+ </mxCell>
49
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-13" value="Shipments" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
50
+ <mxGeometry x="450" y="280" width="250" height="130" as="geometry"/>
51
+ </mxCell>
52
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-14" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
53
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
54
+ </mxCell>
55
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-15" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-14" vertex="1">
56
+ <mxGeometry width="30" height="30" as="geometry"/>
57
+ </mxCell>
58
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-16" value="shipment_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-14" vertex="1">
59
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
60
+ </mxCell>
61
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-17" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
62
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
63
+ </mxCell>
64
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-18" value="FK1" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-17" vertex="1">
65
+ <mxGeometry width="30" height="30" as="geometry"/>
66
+ </mxCell>
67
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-19" value="order_id int NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-17" vertex="1">
68
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
69
+ </mxCell>
70
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-20" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
71
+ <mxGeometry y="90" width="250" height="30" as="geometry"/>
72
+ </mxCell>
73
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-21" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-20" vertex="1">
74
+ <mxGeometry width="30" height="30" as="geometry"/>
75
+ </mxCell>
76
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-22" value="shipment_date date NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-20" vertex="1">
77
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
78
+ </mxCell>
79
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-23" value="Customers" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
80
+ <mxGeometry x="50" y="120" width="250" height="100" as="geometry"/>
81
+ </mxCell>
82
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-24" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-23" vertex="1">
83
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
84
+ </mxCell>
85
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-25" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-24" vertex="1">
86
+ <mxGeometry width="30" height="30" as="geometry"/>
87
+ </mxCell>
88
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-26" value="test_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-24" vertex="1">
89
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
90
+ </mxCell>
91
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-27" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-23" vertex="1">
92
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
93
+ </mxCell>
94
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-28" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-27" vertex="1">
95
+ <mxGeometry width="30" height="30" as="geometry"/>
96
+ </mxCell>
97
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-29" value="customer_name char(50) NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-27" vertex="1">
98
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
99
+ </mxCell>
100
+ </root>
101
+ </mxGraphModel>
102
+ </diagram>
103
+ </mxfile>
data/Sample.xml ADDED
@@ -0,0 +1,103 @@
1
+ <mxfile host="65bd71144e">
2
+ <diagram id="R2lEEEUBdFMjLlhIrx00" name="Page-1">
3
+ <mxGraphModel dx="2" dy="1" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0" extFonts="Permanent Marker^https://fonts.googleapis.com/css?family=Permanent+Marker">
4
+ <root>
5
+ <mxCell id="0"/>
6
+ <mxCell id="1" parent="0"/>
7
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-1" value="" style="edgeStyle=entityRelationEdgeStyle;endArrow=ERzeroToMany;startArrow=ERone;endFill=1;startFill=0;" parent="1" source="C-vyLk0tnHw3VtMMgP7b-24" target="C-vyLk0tnHw3VtMMgP7b-6" edge="1">
8
+ <mxGeometry width="100" height="100" relative="1" as="geometry">
9
+ <mxPoint x="340" y="720" as="sourcePoint"/>
10
+ <mxPoint x="440" y="620" as="targetPoint"/>
11
+ </mxGeometry>
12
+ </mxCell>
13
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-12" value="" style="edgeStyle=entityRelationEdgeStyle;endArrow=ERzeroToMany;startArrow=ERone;endFill=1;startFill=0;" parent="1" source="C-vyLk0tnHw3VtMMgP7b-3" target="C-vyLk0tnHw3VtMMgP7b-17" edge="1">
14
+ <mxGeometry width="100" height="100" relative="1" as="geometry">
15
+ <mxPoint x="400" y="180" as="sourcePoint"/>
16
+ <mxPoint x="460" y="205" as="targetPoint"/>
17
+ </mxGeometry>
18
+ </mxCell>
19
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-2" value="Orders" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
20
+ <mxGeometry x="450" y="120" width="250" height="130" as="geometry"/>
21
+ </mxCell>
22
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-3" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
23
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
24
+ </mxCell>
25
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-4" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-3" vertex="1">
26
+ <mxGeometry width="30" height="30" as="geometry"/>
27
+ </mxCell>
28
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-5" value="order_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-3" vertex="1">
29
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
30
+ </mxCell>
31
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-6" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
32
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
33
+ </mxCell>
34
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-7" value="FK1" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-6" vertex="1">
35
+ <mxGeometry width="30" height="30" as="geometry"/>
36
+ </mxCell>
37
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-8" value="customer_id int NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-6" vertex="1">
38
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
39
+ </mxCell>
40
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-9" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-2" vertex="1">
41
+ <mxGeometry y="90" width="250" height="30" as="geometry"/>
42
+ </mxCell>
43
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-10" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-9" vertex="1">
44
+ <mxGeometry width="30" height="30" as="geometry"/>
45
+ </mxCell>
46
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-11" value="order_date date NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-9" vertex="1">
47
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
48
+ </mxCell>
49
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-13" value="Shipments" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
50
+ <mxGeometry x="450" y="280" width="250" height="130" as="geometry"/>
51
+ </mxCell>
52
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-14" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
53
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
54
+ </mxCell>
55
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-15" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-14" vertex="1">
56
+ <mxGeometry width="30" height="30" as="geometry"/>
57
+ </mxCell>
58
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-16" value="shipment_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-14" vertex="1">
59
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
60
+ </mxCell>
61
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-17" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
62
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
63
+ </mxCell>
64
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-18" value="FK1" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-17" vertex="1">
65
+ <mxGeometry width="30" height="30" as="geometry"/>
66
+ </mxCell>
67
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-19" value="order_id int NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-17" vertex="1">
68
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
69
+ </mxCell>
70
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-20" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-13" vertex="1">
71
+ <mxGeometry y="90" width="250" height="30" as="geometry"/>
72
+ </mxCell>
73
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-21" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-20" vertex="1">
74
+ <mxGeometry width="30" height="30" as="geometry"/>
75
+ </mxCell>
76
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-22" value="shipment_date date NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-20" vertex="1">
77
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
78
+ </mxCell>
79
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-23" value="Customers" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;" parent="1" vertex="1">
80
+ <mxGeometry x="20" y="50" width="250" height="100" as="geometry"/>
81
+ </mxCell>
82
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-24" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" parent="C-vyLk0tnHw3VtMMgP7b-23" vertex="1">
83
+ <mxGeometry y="30" width="250" height="30" as="geometry"/>
84
+ </mxCell>
85
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-25" value="PK" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;" parent="C-vyLk0tnHw3VtMMgP7b-24" vertex="1">
86
+ <mxGeometry width="30" height="30" as="geometry"/>
87
+ </mxCell>
88
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-26" value="test_id int NOT NULL " style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;" parent="C-vyLk0tnHw3VtMMgP7b-24" vertex="1">
89
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
90
+ </mxCell>
91
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-27" value="" style="shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;fillColor=none;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" parent="C-vyLk0tnHw3VtMMgP7b-23" vertex="1">
92
+ <mxGeometry y="60" width="250" height="30" as="geometry"/>
93
+ </mxCell>
94
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-28" value="" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;" parent="C-vyLk0tnHw3VtMMgP7b-27" vertex="1">
95
+ <mxGeometry width="30" height="30" as="geometry"/>
96
+ </mxCell>
97
+ <mxCell id="C-vyLk0tnHw3VtMMgP7b-29" value="customer_name char(50) NOT NULL" style="shape=partialRectangle;overflow=hidden;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;" parent="C-vyLk0tnHw3VtMMgP7b-27" vertex="1">
98
+ <mxGeometry x="30" width="220" height="30" as="geometry"/>
99
+ </mxCell>
100
+ </root>
101
+ </mxGraphModel>
102
+ </diagram>
103
+ </mxfile>
data/hooks/pre-commit CHANGED
@@ -8,8 +8,8 @@ require 'English'
8
8
 
9
9
  exit 0 if ARGV.include?('--no-verify')
10
10
 
11
- warning_keywords = %w[console.log]
12
- keywords = %w[binding.pry console.dir byebug debugger]
11
+ warning_keywords = %w[]
12
+ keywords = %w[binding.pry console.dir byebug]
13
13
  files_changed = `git diff-index --name-only HEAD --`.split
14
14
 
15
15
  # puts '----------------------------------------------------------------------'
@@ -23,6 +23,8 @@ files_changed -= ['Gemfile']
23
23
  files_changed -= ['Gemfile.lock']
24
24
  files_changed -= ['.gitignore']
25
25
  files_changed -= ['README.md']
26
+ files_changed -= ['lib/k_builder/assets/highlight.min.js']
27
+ files_changed -= ['spec/k_builder/base_builder_spec.rb']
26
28
 
27
29
  files_changed = files_changed.reject { |f| f.downcase.end_with?('.json') }
28
30
  files_changed = files_changed.reject { |f| f.downcase.end_with?('.yml') }
data/k_builder.gemspec CHANGED
@@ -37,7 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
38
  spec.require_paths = ['lib']
39
39
  # spec.extensions = ['ext/k_builder/extconf.rb']
40
-
41
40
  spec.add_dependency 'handlebars-helpers', '~> 0'
42
41
  spec.add_dependency 'k_log', '~> 0'
43
42
  spec.add_dependency 'k_type', '~> 0'
@@ -1,21 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KBuilder
4
+ # TODO: Why is this called BaseBuilder, why not just builder
5
+ # TODO: Is this really the builder pattern, it could be the class used by a director
6
+ # but it is not really storing information for builder purposes.
7
+ #
4
8
  # Base builder defines builder methods, build method and configuration
5
9
  #
6
10
  # Convention: Setter methods (are Fluent) and use the prefix set_
7
11
  # Getter methods (are NOT fluent) and return the stored value
8
12
  # Setter methods (are NOT fluent) can be created as needed
9
13
  # these methods would not be prefixed with the set_
14
+
15
+ # process_any_content(content: 'abc')
16
+ # process_any_content(content_file: 'abc.txt')
17
+ # process_any_content(template: 'abc {{name}}', name: 'sean')
18
+ # process_any_content(template_file: 'abc.txt', name: 'sean')
19
+
20
+ # process_any_content(content_gist: 'https://gist.github.com/klueless-io/8d4b6d199dbe4a5d40807a47fff8ed1c')
21
+ # process_any_content(template_gist: 'https://gist.github.com/klueless-io/8d4b6d199dbe4a5d40807a47fff8ed1c', name: 'sean')
22
+
10
23
  class BaseBuilder
11
24
  include KLog::Logging
12
25
 
13
26
  attr_reader :configuration
14
27
 
15
28
  attr_accessor :target_folders
16
-
17
29
  attr_accessor :template_folders
18
30
 
31
+ attr_accessor :last_output_file
32
+ attr_accessor :last_output_folder
33
+ # attr_accessor :last_template
34
+ attr_accessor :last_template_file
35
+
19
36
  # Factory method that provides a builder for a specified structure
20
37
  # runs through a configuration block and then builds the final structure
21
38
  #
@@ -59,6 +76,7 @@ module KBuilder
59
76
  }
60
77
  end
61
78
 
79
+ # rubocop:disable Metrics/AbcSize
62
80
  def debug
63
81
  log.subheading 'kbuilder'
64
82
 
@@ -69,8 +87,16 @@ module KBuilder
69
87
  log.info ''
70
88
 
71
89
  template_folders.debug(title: 'template folders (search order)')
90
+
91
+ log.info ''
92
+ log.kv 'last output file' , last_output_file
93
+ log.kv 'last output folder' , last_output_folder
94
+ # log.kv 'last template' , last_template
95
+ log.kv 'last template file' , last_template_file
96
+
72
97
  ''
73
98
  end
99
+ # rubocop:enable Metrics/AbcSize
74
100
 
75
101
  # ----------------------------------------------------------------------
76
102
  # Fluent interface
@@ -95,31 +121,116 @@ module KBuilder
95
121
  # Extra options will be used as data for templates, e.g
96
122
  # @option opts [String] :to Recipient email
97
123
  # @option opts [String] :body The email's body
124
+ def add_file_action(file, **opts)
125
+ {
126
+ action: :add_file,
127
+ played: false,
128
+ file: file,
129
+ opts: opts
130
+ }
131
+ end
132
+
133
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
98
134
  def add_file(file, **opts)
99
135
  # move to command
100
- full_file = opts.key?(:folder_key) ? target_file(file, folder: opts[:folder_key]) : target_file(file)
136
+ full_file = target_file(file, **opts) # opts.key?(:folder_key) || opts.key?(:folder) ? target_file(file, folder: opts[:folder], folder_key: opts[:folder_key]) : target_file(file)
101
137
 
102
138
  # Need logging options that can log these internal details
103
- FileUtils.mkdir_p(File.dirname(full_file))
139
+ mkdir_p(File.dirname(full_file))
104
140
 
105
141
  content = process_any_content(**opts)
106
142
 
107
- File.write(full_file, content)
143
+ file_write(full_file, content, on_exist: opts[:on_exist])
108
144
 
109
145
  # Prettier needs to work with the original file name
110
- run_prettier file if opts.key?(:pretty)
146
+ run_prettier file if opts.key?(:pretty)
147
+ # TODO: Add test
148
+ run_cop(full_file, fix_safe: true) if opts.key?(:cop) || opts.key?(:ruby_cop)
149
+ # TODO: Add test
150
+ run_command(file) if opts.key?(:run)
151
+
111
152
  # Need support for rubocop -a
153
+ open_file(last_output_file) if opts.key?(:open)
154
+ open_file(last_template_file) if opts.key?(:open_template)
155
+ browse_file(last_output_file) if opts.key?(:browse)
156
+ pause(opts[:pause]) if opts[:pause]
112
157
 
113
158
  self
114
159
  end
160
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
161
+
162
+ def play_actions(actions)
163
+ actions.reject { |action| action[:played] }.each do |action|
164
+ play_action(action)
165
+ end
166
+ end
167
+
168
+ def play_action(action)
169
+ run_action(action)
170
+ action[:played] = true
171
+ end
172
+
173
+ # certain actions (e.g. set_current_folder) will run independently to play
174
+ def run_action(action)
175
+ case action[:action]
176
+ when :add_file
177
+ add_file(action[:file], action[:opts])
178
+ when :delete_file
179
+ delete_file(action[:file], action[:opts])
180
+ when :vscode
181
+ vscode(action[:file_parts], action[:opts])
182
+ when :browse
183
+ browse(action[:file_parts], action[:opts])
184
+ when :set_current_folder
185
+ set_current_folder(action[:folder_key])
186
+ when :run_command
187
+ run_command(action[:command])
188
+ when :run_script
189
+ run_script(action[:script])
190
+ else
191
+ log.error "Unknown action: #{action[:action]}"
192
+ end
193
+ end
194
+
115
195
  alias touch add_file # it is expected that you would not supply any options, just a file name
116
196
 
197
+ def delete_file_action(file, **opts)
198
+ {
199
+ action: :delete_file,
200
+ played: false,
201
+ file: file,
202
+ opts: opts
203
+ }
204
+ end
205
+
206
+ def delete_file(file, **opts)
207
+ full_file = target_file(file, **opts) # = opts.key?(:folder_key) ? target_file(file, folder: opts[:folder_key]) : target_file(file)
208
+
209
+ File.delete(full_file) if File.exist?(full_file)
210
+
211
+ self
212
+ end
213
+
214
+ def file_exist?(file, **opts)
215
+ # full_file = opts.key?(:folder_key) ? target_file(file, folder_key: opts[:folder_key]) : target_file(file)
216
+ full_file = target_file(file, **opts)
217
+
218
+ File.exist?(full_file)
219
+ end
220
+
221
+ # ToDo
222
+ # def delete_folder(file)
223
+ # FileUtils.remove_dir(path_to_directory) if File.directory?(path_to_directory)
224
+
225
+ # self
226
+ # end
227
+
117
228
  def make_folder(folder_key = nil, sub_path: nil)
118
229
  folder_key = current_folder_key if folder_key.nil?
119
230
  folder = target_folder(folder_key)
120
231
  folder = File.join(folder, sub_path) unless sub_path.nil?
121
232
 
122
- FileUtils.mkdir_p(folder)
233
+ mkdir_p(folder)
123
234
 
124
235
  self
125
236
  end
@@ -140,6 +251,8 @@ module KBuilder
140
251
 
141
252
  begin
142
253
  IO.popen('pbcopy', 'w') { |f| f << content }
254
+
255
+ open_file(last_template_file) if opts.key?(:open_template)
143
256
  rescue Errno::ENOENT => e
144
257
  if e.message == 'No such file or directory - pbcopy'
145
258
  # May want to use this GEM in the future
@@ -152,15 +265,84 @@ module KBuilder
152
265
  end
153
266
  alias clipboard_copy add_clipboard
154
267
 
155
- def vscode(*file_parts, folder: current_folder_key)
268
+ def vscode_action(*file_parts, folder_key: current_folder_key, file: nil)
269
+ {
270
+ action: :vscode,
271
+ played: false,
272
+ file_parts: file_parts,
273
+ opts: { folder_key: folder_key, file: file }
274
+ }
275
+ end
276
+
277
+ def vscode(*file_parts, folder_key: current_folder_key, file: nil)
156
278
  # move to command
157
- file = target_file(*file_parts, folder: folder)
279
+ file = target_file(*file_parts, folder_key: folder_key) if file.nil?
158
280
 
159
281
  rc "code #{file}"
160
282
 
161
283
  self
162
284
  end
163
285
 
286
+ def browse_action(*file_parts, folder_key: current_folder_key, file: nil)
287
+ {
288
+ action: :browse,
289
+ played: false,
290
+ file_parts: file_parts,
291
+ opts: { folder_key: folder_key, file: file }
292
+ }
293
+ end
294
+
295
+ def browse(*file_parts, folder_key: current_folder_key, file: nil)
296
+ # move to command
297
+ file = target_file(*file_parts, folder_key: folder_key) if file.nil?
298
+
299
+ rc "open -a \"Google Chrome\" #{file}"
300
+
301
+ self
302
+ end
303
+
304
+ def open
305
+ open_file(last_output_file)
306
+
307
+ self
308
+ end
309
+ alias o open
310
+
311
+ def open_template
312
+ open_file(last_template_file)
313
+
314
+ self
315
+ end
316
+ alias ot open_template
317
+
318
+ def open_file(file)
319
+ if file.nil?
320
+ log.warn('open_file will not open when file is nil')
321
+ return self
322
+ end
323
+
324
+ vscode(file: file)
325
+
326
+ self
327
+ end
328
+
329
+ def browse_file(file)
330
+ if file.nil?
331
+ log.warn('browse_file will not browse when file is nil')
332
+ return self
333
+ end
334
+
335
+ browse(file: file)
336
+
337
+ self
338
+ end
339
+
340
+ def pause(seconds = 1)
341
+ sleep(seconds)
342
+
343
+ self
344
+ end
345
+
164
346
  # ----------------------------------------------------------------------
165
347
  # Attributes: Think getter/setter
166
348
  #
@@ -174,6 +356,14 @@ module KBuilder
174
356
  # Target folders and files
175
357
  # ----------------------------------------------------------------------
176
358
 
359
+ def set_current_folder_action(folder_key)
360
+ {
361
+ action: :set_current_folder,
362
+ played: false,
363
+ folder_key: folder_key
364
+ }
365
+ end
366
+
177
367
  def set_current_folder(folder_key)
178
368
  target_folders.current = folder_key
179
369
 
@@ -216,12 +406,18 @@ module KBuilder
216
406
  # target_file('/abc.txt')
217
407
  # target_file('/xyz/abc.txt')
218
408
  # target_file('/xyz', 'abc.txt')
219
- def target_file(*file_parts, folder: current_folder_key)
409
+ def target_file(*file_parts, folder_key: current_folder_key, folder: nil, **)
410
+ # TODO: Mismatch (sometimes called folder, sometimes called folder_key:)
411
+ if folder
412
+ log.error("Change folder: to folder_key: for #{folder} - #{file_parts}")
413
+ return
414
+ end
415
+
220
416
  # Absolute path
221
417
  return File.join(*file_parts) if Pathname.new(file_parts.first).absolute?
222
418
 
223
- # Relative to :folder
224
- File.join(target_folder(folder), *file_parts)
419
+ # Relative to :folder_key
420
+ File.join(target_folder(folder_key), *file_parts)
225
421
  end
226
422
 
227
423
  # Template folder & Files
@@ -242,7 +438,8 @@ module KBuilder
242
438
  # Gets a template_file relative to the template folder, looks first in
243
439
  # local template folder and if not found, looks in global template folder
244
440
  def find_template_file(file_parts)
245
- template_folders.find_file(file_parts)
441
+ self.last_template_file = template_folders.find_file(file_parts)
442
+ last_template_file
246
443
  end
247
444
 
248
445
  # Building content from templates
@@ -268,15 +465,6 @@ module KBuilder
268
465
 
269
466
  return "content not found: #{opts[:content_file]}" if cf.nil?
270
467
 
271
- # cf = opts[:content_file]
272
-
273
- # unless File.exist?(cf)
274
- # cf_from_template_folders = find_template_file(cf)
275
- # return "Content not found: #{File.expand_path(cf)}" unless File.exist?(cf_from_template_folders)
276
-
277
- # cf = cf_from_template_folders
278
- # end
279
-
280
468
  File.read(cf)
281
469
  end
282
470
 
@@ -340,7 +528,7 @@ module KBuilder
340
528
  # Deep path create if needed
341
529
  tf = target_folder
342
530
 
343
- FileUtils.mkdir_p(tf)
531
+ mkdir_p(tf)
344
532
 
345
533
  build_command = "cd #{tf} && #{command}"
346
534
 
@@ -349,7 +537,89 @@ module KBuilder
349
537
  # need to support the fork process options as I was not able to run
350
538
  # k_builder_watch -n because it hid all the following output
351
539
  system(build_command)
540
+
541
+ # FROM k_dsl
542
+ # system "/usr/local/bin/zsh #{output_file}" if execution_context == :system
543
+ # fork { exec("/usr/local/bin/zsh #{output_file}") } if execution_context == :fork
544
+
352
545
  end
353
546
  alias rc run_command
547
+
548
+ def run_command_action(command)
549
+ {
550
+ action: :run_command,
551
+ played: false,
552
+ command: command
553
+ }
554
+ end
555
+
556
+ # NOT TESTED, and not working with opts, this code needs rewrite
557
+ def run_script(script)
558
+ # Deep path create if needed
559
+ tf = target_folder
560
+
561
+ mkdir_p(tf)
562
+
563
+ Dir.chdir(tf) do
564
+ output, status = Open3.capture2(script) # , **opts)
565
+
566
+ unless status.success?
567
+ log.error("Script failed")
568
+ puts script
569
+ return nil
570
+ end
571
+
572
+ return output
573
+ end
574
+ end
575
+
576
+ def run_script_action(script)
577
+ {
578
+ action: :run_script,
579
+ played: false,
580
+ script: script
581
+ }
582
+ end
583
+
584
+ def file_write(file, content, on_exist: :skip)
585
+ self.last_output_file = file # if file not found, we still want to record this as the last_output_file
586
+
587
+ not_found = !File.exist?(file)
588
+
589
+ if not_found
590
+ File.write(file, content)
591
+ return
592
+ end
593
+
594
+ return if %i[skip ignore].include?(on_exist)
595
+
596
+ if %i[overwrite write].include?(on_exist)
597
+ File.write(file, content)
598
+ return
599
+ end
600
+
601
+ return unless on_exist == :compare
602
+
603
+ vscompare(file, content)
604
+ end
605
+
606
+ def vscompare(file, content)
607
+ # need to use some sort of caching folder for this
608
+ ext = File.extname(file)
609
+ fn = File.basename(file, ext)
610
+ temp_file = Tempfile.new([fn, ext])
611
+
612
+ temp_file.write(content)
613
+ temp_file.close
614
+
615
+ return if File.read(file) == content
616
+
617
+ system("code -d #{file} #{temp_file.path}")
618
+ sleep 2
619
+ end
620
+
621
+ def mkdir_p(folder)
622
+ @last_output_folder = FileUtils.mkdir_p(folder).first
623
+ end
354
624
  end
355
625
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KBuilder
4
+ module Commands
5
+ # Run CodeSyntaxHighlighter against source code and produce a styled HTML representation
6
+ #
7
+ # Alternatives to Highlighter-js could be carbon-now and ray.so
8
+ class CodeSyntaxHighlighterCommand < BaseCommand
9
+ attr_reader :source_code
10
+ attr_reader :formatted_code
11
+
12
+ def initialize(source_code, **opts)
13
+ super(**opts)
14
+
15
+ self.source_code = source_code
16
+ end
17
+
18
+ def execute
19
+ return unless valid?
20
+
21
+ run
22
+ end
23
+
24
+ private
25
+
26
+ def source_code=(value)
27
+ @source_code = value
28
+
29
+ guard('Source code is required for formatting') if value.nil? || value.empty?
30
+ end
31
+
32
+ def run
33
+ # @formatted_code = ExecJS.eval("'red yellow blue'.split(' ')")
34
+
35
+ # # highlight_source = 'lib/k_builder/assets/a.js'
36
+ # highlight_source = 'lib/k_builder/assets/highlight.min.js'
37
+
38
+ # log.error ExecJS.runtime.name
39
+
40
+ # a = File.read(highlight_source)
41
+ # # context = ExecJS.compile(a)
42
+ # context = ExecJS.compile(highlight_source)
43
+ # context.call("html = hljs.highlightAuto('<h1>Hello World!</h1>').value")
44
+
45
+ # get_js_asset('highlight')
46
+ # get_js_asset('ruby')
47
+ end
48
+
49
+ # https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/highlight.min.js
50
+ # https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/languages/ruby.min.js
51
+
52
+ def get_js_asset(name)
53
+ url = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/#{name}.min.js"
54
+ target_folder = 'lib/k_builder/assets'
55
+ file = "#{name}.min.js"
56
+
57
+ get_asset(url, target_folder, file)
58
+ end
59
+
60
+ def get_asset(url, target_folder, file)
61
+ local_asset_file = File.join(target_folder, file)
62
+
63
+ return if File.exist?(local_asset_file)
64
+
65
+ content = Net::HTTP.get(URI.parse(url))
66
+
67
+ File.write(local_asset_file, content)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -5,18 +5,24 @@ module KBuilder
5
5
  # Configuration for webpack5/builder
6
6
  class << self
7
7
  attr_writer :configuration
8
- end
9
8
 
10
- def self.configuration
11
- @configuration ||= Configuration.new
12
- end
9
+ def configuration(name = :default)
10
+ @configuration ||= Hash.new do |h, key|
11
+ h[key] = KBuilder::Configuration.new
12
+ end
13
+ @configuration[name]
14
+ end
13
15
 
14
- def self.reset
15
- @configuration = Configuration.new
16
- end
16
+ def reset(name = :default)
17
+ @configuration ||= Hash.new do |h, key|
18
+ h[key] = KBuilder::Configuration.new
19
+ end
20
+ @configuration[name] = KBuilder::Configuration.new
21
+ end
17
22
 
18
- def self.configure
19
- yield(configuration)
23
+ def configure(name = :default)
24
+ yield(configuration(name))
25
+ end
20
26
  end
21
27
 
22
28
  # Does this class need to move out into k_types?
@@ -48,12 +54,16 @@ module KBuilder
48
54
  @template_folders = orig.template_folders.clone
49
55
  end
50
56
 
51
- def debug
52
- log.subheading 'kbuilder base configuration'
57
+ def debug(heading: 'kbuilder base configuration')
58
+ log.section_heading 'kbuilder base configuration' if heading
59
+
60
+ # TODO: Add name to configuration object
61
+ # Don't have support for name on the configuration object yet
62
+ # log.kv 'config name', name
53
63
 
54
64
  target_folders.debug(title: 'target_folders')
55
65
 
56
- log.info ''
66
+ # log.info ''
57
67
 
58
68
  template_folders.debug(title: 'template folders (search order)')
59
69
  ''
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KBuilder
4
- VERSION = '0.0.63'
4
+ VERSION = '0.0.71'
5
5
  end
data/lib/k_builder.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rubocop'
4
+ require "open3"
4
5
 
5
6
  require 'k_log'
6
7
  require 'k_util'
@@ -10,8 +11,11 @@ require 'k_builder/base_builder'
10
11
  require 'k_builder/base_configuration'
11
12
  require 'k_builder/configuration'
12
13
  require 'k_builder/file_segments'
14
+
15
+ # should commands be in their own gem?
13
16
  require 'k_builder/commands/base_command'
14
17
  require 'k_builder/commands/rubo_cop_command'
18
+ require 'k_builder/commands/code_syntax_highlighter_command'
15
19
 
16
20
  require 'handlebars/helpers/template'
17
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.63
4
+ version: 0.0.71
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-01 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: handlebars-helpers
@@ -99,6 +99,9 @@ files:
99
99
  - README.md
100
100
  - Rakefile
101
101
  - STORIES.md
102
+ - Sample-original.xml
103
+ - Sample.drawio
104
+ - Sample.xml
102
105
  - USAGE.md
103
106
  - bin/console
104
107
  - bin/k
@@ -112,6 +115,7 @@ files:
112
115
  - lib/k_builder/base_builder.rb
113
116
  - lib/k_builder/base_configuration.rb
114
117
  - lib/k_builder/commands/base_command.rb
118
+ - lib/k_builder/commands/code_syntax_highlighter_command.rb
115
119
  - lib/k_builder/commands/rubo_cop_command.rb
116
120
  - lib/k_builder/configuration.rb
117
121
  - lib/k_builder/file_segments.rb
@@ -145,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
149
  - !ruby/object:Gem::Version
146
150
  version: '0'
147
151
  requirements: []
148
- rubygems_version: 3.2.7
152
+ rubygems_version: 3.2.33
149
153
  signing_key:
150
154
  specification_version: 4
151
155
  summary: K Builder provides various fluent builders for initializing applications