tailwind_dsl 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/blueprint/tailwind.rb +400 -0
- data/.builders/boot.rb +8 -0
- data/.builders/generators/domain-model-to-code.rb +97 -0
- data/.builders/generators/domain-model.rb +174 -0
- data/.builders/generators/project-plan.rb +36 -0
- data/CHANGELOG.md +7 -0
- data/docs/domain-model-custom.drawio +109 -0
- data/docs/domain-model.json +927 -0
- data/docs/domain-model.svg +3 -0
- data/docs/project-plan/project.drawio +32 -0
- data/docs/project-plan/project_in_progress.svg +3 -0
- data/lib/_.rb +13 -0
- data/lib/tailwind_dsl/base_data_builder.rb +10 -0
- data/lib/tailwind_dsl/config/collection.rb +15 -0
- data/lib/tailwind_dsl/config/component.rb +15 -0
- data/lib/tailwind_dsl/config/component_group.rb +16 -0
- data/lib/tailwind_dsl/config/configuration.rb +15 -0
- data/lib/tailwind_dsl/config/theme.rb +14 -0
- data/lib/tailwind_dsl/data_shape.rb +12 -0
- data/lib/tailwind_dsl/schema/component.rb +16 -0
- data/lib/tailwind_dsl/schema/page.rb +18 -0
- data/lib/tailwind_dsl/schema/web_site.rb +20 -0
- data/lib/tailwind_dsl/tailwind_dsl.rb +16 -0
- data/lib/tailwind_dsl/version.rb +1 -1
- data/lib/tailwind_dsl.rb +1 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574d3ce7e5298a88097270102327b55a5b89be6193e250cea95b4dafcf0ec2db
|
4
|
+
data.tar.gz: e81ab5eea249499d2ee91069b07ea92527ae75a0d08f6932ed93ed8b8e68ee99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca1aefbfee42b2608c0753768b993d5705fd2590412719c1a87ff54bdeb207b2591f3d0dabb0b86d1306e097f7035b3aa72543400289b166f092b5f16726443a
|
7
|
+
data.tar.gz: 4a080c5b6f8e825489d9571ae3e324d8876869ae8900dfa28f19876af478a1cc2fc46254fcc23bf50817fde2d17adc9af8819b89091bee98026fa0c9989ae658
|
@@ -0,0 +1,400 @@
|
|
1
|
+
KManager.model :tailwind, namespace: %i[domain] do
|
2
|
+
# microapp = import(:handlebars_helpers, :microapp)
|
3
|
+
|
4
|
+
# other settings
|
5
|
+
# strokeWidth: 1-n
|
6
|
+
# when there is an arrow at beginning
|
7
|
+
# startFill=1,0
|
8
|
+
# when there is an arrow at end
|
9
|
+
# endFill=1,0
|
10
|
+
|
11
|
+
table :collections do
|
12
|
+
fields %i[key description default_themes]
|
13
|
+
|
14
|
+
row :devdojo, 'DevDojo', %w[blue red green]
|
15
|
+
row :merikui, 'Merikui', %w[black white]
|
16
|
+
end
|
17
|
+
|
18
|
+
table :component_groups do
|
19
|
+
fields %i[collection key description]
|
20
|
+
|
21
|
+
row :devdojo, :nav
|
22
|
+
row :devdojo, :hero
|
23
|
+
row :devdojo, :header
|
24
|
+
row :devdojo, :logo
|
25
|
+
row :devdojo, :content
|
26
|
+
row :devdojo, :footer
|
27
|
+
end
|
28
|
+
|
29
|
+
table :components do
|
30
|
+
fields %i[component_group key data_shape name description]
|
31
|
+
|
32
|
+
|
33
|
+
row :devdojo_nav , :nav_01
|
34
|
+
row :devdojo_nav , :nav_02
|
35
|
+
row :devdojo_nav , :nav_03
|
36
|
+
row :devdojo_nav , :nav_04
|
37
|
+
row :devdojo_hero , :hero_01
|
38
|
+
row :devdojo_hero , :hero_02
|
39
|
+
row :devdojo_hero , :hero_03
|
40
|
+
row :devdojo_hero , :hero_04
|
41
|
+
row :devdojo_content , :fancy_paragraph, :fancy_paragraph
|
42
|
+
end
|
43
|
+
|
44
|
+
# Component - AKA: Template
|
45
|
+
SAMPLE_TAILWIND = <<-HTML
|
46
|
+
# Fancy Paragraph
|
47
|
+
<div class="container mx-auto">
|
48
|
+
<div class="flex flex-wrap">
|
49
|
+
<div class="w-full md:w-1/2 p-6">
|
50
|
+
<div class="{{bg}} rounded-lg shadow-lg p-6">
|
51
|
+
<p class="{{fg}}">{{p}}</p>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
HTML
|
57
|
+
|
58
|
+
TAILWIND_DSL = <<-RUBY
|
59
|
+
tailwind = TailwindDsl
|
60
|
+
.init
|
61
|
+
.website(:test_site1,
|
62
|
+
name: 'Test Site 1',
|
63
|
+
description: 'This is our sample Test Site',
|
64
|
+
target_folder: 'test_site1',
|
65
|
+
base_collection: :devdojo,
|
66
|
+
theme: :teal
|
67
|
+
|
68
|
+
)
|
69
|
+
.page(:home
|
70
|
+
name: 'Home Page',
|
71
|
+
description: 'This is the Home Page',
|
72
|
+
child_pages(:about, :contact, :faq, :privacy, :articles) do
|
73
|
+
|
74
|
+
nav(:nav_01)
|
75
|
+
content(:fancy_paragraph) do
|
76
|
+
data
|
77
|
+
.p('The quick brown fox jumps over the lazy dog.')
|
78
|
+
.color(bg: 'white', fg: 'black')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
.page(:about
|
82
|
+
name: 'About Page',
|
83
|
+
description: 'This is the About Page') do
|
84
|
+
|
85
|
+
nav(:nav_01)
|
86
|
+
content(:paragraph) do
|
87
|
+
data
|
88
|
+
.p('This is the about page')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
.page(:contact
|
92
|
+
name: 'Contact Page',
|
93
|
+
description: 'This is the Contact Page') do
|
94
|
+
|
95
|
+
nav(:nav_01)
|
96
|
+
content(:paragraph) do
|
97
|
+
data
|
98
|
+
.p('This is the contact page')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
RUBY
|
102
|
+
|
103
|
+
SAMPLE_DATASHAPE_DSL_DEFINITION = <<-RUBY
|
104
|
+
fancy_paragraph_definition = DataDsl
|
105
|
+
.init(:fancy_paragraph)
|
106
|
+
.requires(:p, default: 'The quick brown fox jumps over the lazy dog.')
|
107
|
+
.requires(:color, defaults: { bg: 'white', fg: 'black' })
|
108
|
+
RUBY
|
109
|
+
|
110
|
+
SAMPLE_DATASHAPE_DSL = <<-RUBY
|
111
|
+
fancy_paragraph = FancyParagraph
|
112
|
+
.init
|
113
|
+
.p('The quick brown fox jumps over the lazy dog.')
|
114
|
+
.color(bg: 'white', fg: 'black')
|
115
|
+
RUBY
|
116
|
+
|
117
|
+
SAMPLE_DATASHAPE_JSON = <<-JSON
|
118
|
+
{
|
119
|
+
p: 'The quick brown fox jumps over the lazy dog.',
|
120
|
+
bg: 'white',
|
121
|
+
fg: 'black'
|
122
|
+
}
|
123
|
+
JSON
|
124
|
+
|
125
|
+
# A datashape is a DSL definition for the data that is used to populate the tailwind component data
|
126
|
+
table :data_shapes do
|
127
|
+
fields %i[key name description]
|
128
|
+
|
129
|
+
row :fancy_paragraph
|
130
|
+
end
|
131
|
+
|
132
|
+
table :themes do
|
133
|
+
fields %i[favourite key bg_color font_color]
|
134
|
+
|
135
|
+
# fields %i[key fill_color stroke_color font_color gradient]
|
136
|
+
|
137
|
+
# row :style_01, '#f5f5f5', '#666666', '#333333'
|
138
|
+
# row :style_02, '#dae8fc', '#6c8ebf', '#333333'
|
139
|
+
|
140
|
+
# alternative source: https://www.quackit.com/css/css_color_codes.cfm
|
141
|
+
# source: https://www.w3schools.com/colors/colors_hex.asp
|
142
|
+
row 0, :navy , '#000080', '#FFFFFF'
|
143
|
+
row 0, :dark_blue , '#00008B', '#FFFFFF'
|
144
|
+
row 0, :medium_blue , '#0000CD', '#FFFFFF'
|
145
|
+
row 0, :blue , '#0000FF', '#FFFFFF'
|
146
|
+
row 0, :dark_green , '#006400', '#FFFFFF'
|
147
|
+
row 0, :green , '#008000', '#FFFFFF'
|
148
|
+
row 1, :teal , '#008080', '#FFFFFF'
|
149
|
+
row 0, :dark_cyan , '#008B8B', '#FFFFFF'
|
150
|
+
row 1, :deep_sky_blue , '#00BFFF', '#FFFFFF'
|
151
|
+
row 1, :dark_turquoise , '#00CED1', '#FFFFFF'
|
152
|
+
row 0, :medium_spring_green , '#00FA9A', '#1F2D3D'
|
153
|
+
row 0, :lime , '#00FF00', '#FFFFFF'
|
154
|
+
row 0, :spring_green , '#00FF7F', '#1F2D3D'
|
155
|
+
row 0, :aqua , '#00FFFF', '#1F2D3D'
|
156
|
+
row 0, :cyan , '#00FFFF', '#1F2D3D'
|
157
|
+
row 0, :midnight_blue , '#191970', '#FFFFFF'
|
158
|
+
row 0, :dodger_blue , '#1E90FF', '#FFFFFF'
|
159
|
+
row 0, :light_sea_green , '#20B2AA', '#FFFFFF'
|
160
|
+
row 0, :forest_green , '#228B22', '#FFFFFF'
|
161
|
+
row 0, :sea_green , '#2E8B57', '#FFFFFF'
|
162
|
+
row 0, :dark_slate_gray , '#2F4F4F', '#FFFFFF'
|
163
|
+
row 0, :dark_slate_grey , '#2F4F4F', '#FFFFFF'
|
164
|
+
row 0, :lime_green , '#32CD32', '#FFFFFF'
|
165
|
+
row 0, :medium_sea_green , '#3CB371', '#FFFFFF'
|
166
|
+
row 0, :turquoise , '#40E0D0', '#1F2D3D'
|
167
|
+
row 1, :royal_blue , '#4169E1', '#FFFFFF'
|
168
|
+
row 1, :steel_blue , '#4682B4', '#FFFFFF'
|
169
|
+
row 0, :dark_slate_blue , '#483D8B', '#FFFFFF'
|
170
|
+
row 0, :medium_turquoise , '#48D1CC', '#1F2D3D'
|
171
|
+
row 0, :indigo , '#4B0082', '#FFFFFF'
|
172
|
+
row 0, :dark_olive_green , '#556B2F', '#FFFFFF'
|
173
|
+
row 0, :cadet_blue , '#5F9EA0', '#FFFFFF'
|
174
|
+
row 1, :cornflower_blue , '#6495ED', '#FFFFFF'
|
175
|
+
row 0, :rebecca_purple , '#663399', '#FFFFFF'
|
176
|
+
row 0, :medium_aqua_marine , '#66CDAA', '#1F2D3D'
|
177
|
+
row 0, :dim_gray , '#696969', '#FFFFFF'
|
178
|
+
row 0, :dim_grey , '#696969', '#FFFFFF'
|
179
|
+
row 0, :slate_blue , '#6A5ACD', '#FFFFFF'
|
180
|
+
row 0, :olive_drab , '#6B8E23', '#FFFFFF'
|
181
|
+
row 0, :slate_gray , '#708090', '#FFFFFF'
|
182
|
+
row 0, :slate_grey , '#708090', '#FFFFFF'
|
183
|
+
row 0, :light_slate_gray , '#778899', '#FFFFFF'
|
184
|
+
row 0, :light_slate_grey , '#778899', '#FFFFFF'
|
185
|
+
row 0, :medium_slate_blue , '#7B68EE', '#FFFFFF'
|
186
|
+
row 0, :lawn_green , '#7CFC00', '#1F2D3D'
|
187
|
+
row 0, :chartreuse , '#7FFF00', '#1F2D3D'
|
188
|
+
row 0, :aquamarine , '#7FFFD4', '#1F2D3D'
|
189
|
+
row 0, :maroon , '#800000', '#FFFFFF'
|
190
|
+
row 0, :purple , '#800080', '#FFFFFF'
|
191
|
+
row 0, :olive , '#808000', '#FFFFFF'
|
192
|
+
row 0, :gray , '#808080', '#FFFFFF'
|
193
|
+
row 0, :grey , '#808080', '#FFFFFF'
|
194
|
+
row 0, :sky_blue , '#87CEEB', '#1F2D3D'
|
195
|
+
row 0, :light_sky_blue , '#87CEFA', '#1F2D3D'
|
196
|
+
row 0, :blue_violet , '#8A2BE2', '#FFFFFF'
|
197
|
+
row 0, :dark_red , '#8B0000', '#FFFFFF'
|
198
|
+
row 0, :dark_magenta , '#8B008B', '#FFFFFF'
|
199
|
+
row 0, :saddle_brown , '#8B4513', '#FFFFFF'
|
200
|
+
row 1, :dark_sea_green , '#8FBC8F', '#1F2D3D'
|
201
|
+
row 0, :light_green , '#90EE90', '#1F2D3D'
|
202
|
+
row 0, :medium_purple , '#9370DB', '#FFFFFF'
|
203
|
+
row 0, :dark_violet , '#9400D3', '#FFFFFF'
|
204
|
+
row 0, :pale_green , '#98FB98', '#1F2D3D'
|
205
|
+
row 0, :dark_orchid , '#9932CC', '#FFFFFF'
|
206
|
+
row 0, :yellow_green , '#9ACD32', '#1F2D3D'
|
207
|
+
row 0, :sienna , '#A0522D', '#FFFFFF'
|
208
|
+
row 0, :brown , '#A52A2A', '#FFFFFF'
|
209
|
+
row 0, :dark_gray , '#A9A9A9', '#1F2D3D'
|
210
|
+
row 0, :dark_grey , '#A9A9A9', '#1F2D3D'
|
211
|
+
row 0, :light_blue , '#ADD8E6', '#1F2D3D'
|
212
|
+
row 0, :green_yellow , '#ADFF2F', '#1F2D3D'
|
213
|
+
row 0, :pale_turquoise , '#AFEEEE', '#1F2D3D'
|
214
|
+
row 1, :light_steel_blue , '#B0C4DE', '#1F2D3D'
|
215
|
+
row 0, :powder_blue , '#B0E0E6', '#1F2D3D'
|
216
|
+
row 1, :fire_brick , '#B22222', '#FFFFFF'
|
217
|
+
row 0, :dark_golden_rod , '#B8860B', '#FFFFFF'
|
218
|
+
row 0, :medium_orchid , '#BA55D3', '#FFFFFF'
|
219
|
+
row 1, :rosy_brown , '#BC8F8F', '#1F2D3D'
|
220
|
+
row 0, :dark_khaki , '#BDB76B', '#1F2D3D'
|
221
|
+
row 0, :silver , '#C0C0C0', '#1F2D3D'
|
222
|
+
row 0, :medium_violet_red , '#C71585', '#FFFFFF'
|
223
|
+
row 1, :indian_red , '#CD5C5C', '#FFFFFF'
|
224
|
+
row 0, :peru , '#CD853F', '#FFFFFF'
|
225
|
+
row 0, :chocolate , '#D2691E', '#FFFFFF'
|
226
|
+
row 1, :tan , '#D2B48C', '#1F2D3D'
|
227
|
+
row 0, :light_gray , '#D3D3D3', '#1F2D3D'
|
228
|
+
row 0, :light_grey , '#D3D3D3', '#1F2D3D'
|
229
|
+
row 0, :thistle , '#D8BFD8', '#1F2D3D'
|
230
|
+
row 0, :orchid , '#DA70D6', '#1F2D3D'
|
231
|
+
row 0, :golden_rod , '#DAA520', '#1F2D3D'
|
232
|
+
row 0, :pale_violet_red , '#DB7093', '#FFFFFF'
|
233
|
+
row 0, :crimson , '#DC143C', '#FFFFFF'
|
234
|
+
row 0, :gainsboro , '#DCDCDC', '#1F2D3D'
|
235
|
+
row 0, :plum , '#DDA0DD', '#1F2D3D'
|
236
|
+
row 1, :burly_wood , '#DEB887', '#1F2D3D'
|
237
|
+
row 0, :light_cyan , '#E0FFFF', '#1F2D3D'
|
238
|
+
row 0, :lavender , '#E6E6FA', '#1F2D3D'
|
239
|
+
row 0, :dark_salmon , '#E9967A', '#1F2D3D'
|
240
|
+
row 0, :violet , '#EE82EE', '#1F2D3D'
|
241
|
+
row 0, :pale_golden_rod , '#EEE8AA', '#1F2D3D'
|
242
|
+
row 0, :light_coral , '#F08080', '#1F2D3D'
|
243
|
+
row 0, :khaki , '#F0E68C', '#1F2D3D'
|
244
|
+
row 0, :alice_blue , '#F0F8FF', '#1F2D3D'
|
245
|
+
row 0, :honey_dew , '#F0FFF0', '#1F2D3D'
|
246
|
+
row 0, :azure , '#F0FFFF', '#1F2D3D'
|
247
|
+
row 0, :sandy_brown , '#F4A460', '#1F2D3D'
|
248
|
+
row 1, :wheat , '#F5DEB3', '#1F2D3D'
|
249
|
+
row 0, :beige , '#F5F5DC', '#1F2D3D'
|
250
|
+
row 0, :white_smoke , '#F5F5F5', '#1F2D3D'
|
251
|
+
row 0, :mint_cream , '#F5FFFA', '#1F2D3D'
|
252
|
+
row 0, :ghost_white , '#F8F8FF', '#1F2D3D'
|
253
|
+
row 0, :salmon , '#FA8072', '#1F2D3D'
|
254
|
+
row 0, :antique_white , '#FAEBD7', '#1F2D3D'
|
255
|
+
row 1, :linen , '#FAF0E6', '#1F2D3D'
|
256
|
+
row 1, :light_golden_rod_yellow , '#FAFAD2', '#1F2D3D'
|
257
|
+
row 1, :pale_gray , '#FAFAFA', '#1F2D3D'
|
258
|
+
row 0, :pale_grey , '#FAFAFA', '#1F2D3D'
|
259
|
+
row 0, :old_lace , '#FDF5E6', '#1F2D3D'
|
260
|
+
row 0, :red , '#FF0000', '#FFFFFF'
|
261
|
+
row 0, :fuchsia , '#FF00FF', '#FFFFFF'
|
262
|
+
row 0, :magenta , '#FF00FF', '#FFFFFF'
|
263
|
+
row 0, :deep_pink , '#FF1493', '#FFFFFF'
|
264
|
+
row 0, :orange_red , '#FF4500', '#FFFFFF'
|
265
|
+
row 0, :tomato , '#FF6347', '#FFFFFF'
|
266
|
+
row 0, :hot_pink , '#FF69B4', '#1F2D3D'
|
267
|
+
row 0, :coral , '#FF7F50', '#1F2D3D'
|
268
|
+
row 0, :dark_orange , '#FF8C00', '#1F2D3D'
|
269
|
+
row 0, :light_salmon , '#FFA07A', '#1F2D3D'
|
270
|
+
row 0, :orange , '#FFA500', '#1F2D3D'
|
271
|
+
row 0, :light_pink , '#FFB6C1', '#1F2D3D'
|
272
|
+
row 0, :pink , '#FFC0CB', '#1F2D3D'
|
273
|
+
row 0, :gold , '#FFD700', '#1F2D3D'
|
274
|
+
row 1, :peach_puff , '#FFDAB9', '#1F2D3D'
|
275
|
+
row 0, :navajo_white , '#FFDEAD', '#1F2D3D'
|
276
|
+
row 0, :moccasin , '#FFE4B5', '#1F2D3D'
|
277
|
+
row 0, :bisque , '#FFE4C4', '#1F2D3D'
|
278
|
+
row 0, :misty_rose , '#FFE4E1', '#1F2D3D'
|
279
|
+
row 0, :blanched_almond , '#FFEBCD', '#1F2D3D'
|
280
|
+
row 0, :papaya_whip , '#FFEFD5', '#1F2D3D'
|
281
|
+
row 0, :lavender_blush , '#FFF0F5', '#1F2D3D'
|
282
|
+
row 0, :sea_shell , '#FFF5EE', '#1F2D3D'
|
283
|
+
row 1, :cornsilk , '#FFF8DC', '#1F2D3D'
|
284
|
+
row 0, :lemon_chiffon , '#FFFACD', '#1F2D3D'
|
285
|
+
row 0, :floral_white , '#FFFAF0', '#1F2D3D'
|
286
|
+
row 1, :snow , '#FFFAFA', '#1F2D3D'
|
287
|
+
row 0, :yellow , '#FFFF00', '#1F2D3D'
|
288
|
+
row 0, :light_yellow , '#FFFFE0', '#1F2D3D'
|
289
|
+
row 1, :ivory , '#FFFFF0', '#1F2D3D'
|
290
|
+
end
|
291
|
+
|
292
|
+
action do
|
293
|
+
return
|
294
|
+
data = self.raw_data
|
295
|
+
|
296
|
+
lookup = data['lines'] + data['texts'] + data['elements']
|
297
|
+
|
298
|
+
content = {
|
299
|
+
shape: {
|
300
|
+
lookup: lookup.map { |shape| { key: shape['key'], category: shape['category'] } },
|
301
|
+
elements: data['elements'],
|
302
|
+
lines: data['lines'],
|
303
|
+
texts: data['texts']
|
304
|
+
},
|
305
|
+
connector: {
|
306
|
+
compass_points: data['connector_compass_points'],
|
307
|
+
waypoints: data['connector_waypoints'],
|
308
|
+
arrows: data['connector_arrows'],
|
309
|
+
designs: data['connector_designs'],
|
310
|
+
},
|
311
|
+
theme: {
|
312
|
+
elements: data['element_themes'],
|
313
|
+
backgrounds: data['background_themes']
|
314
|
+
},
|
315
|
+
strokes: data['strokes']
|
316
|
+
}
|
317
|
+
|
318
|
+
k_builder
|
319
|
+
.cd(:app)
|
320
|
+
.add_file('config/configuration.json', content: JSON.pretty_generate(content), on_exist: :write)
|
321
|
+
|
322
|
+
generate_code
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def generate_code
|
327
|
+
shapes_file = k_builder.target_folders.get_filename(:app, 'config/configuration.json')
|
328
|
+
shapes_configuration = JSON.parse(File.read(shapes_file))
|
329
|
+
shapes = shapes_configuration['shape']
|
330
|
+
lookup = shapes['lookup']
|
331
|
+
elements = shapes['elements']
|
332
|
+
lines = shapes['lines']
|
333
|
+
texts = shapes['texts']
|
334
|
+
|
335
|
+
# strokes = shapes_configuration['strokes']
|
336
|
+
|
337
|
+
KDirector::Dsls::BasicDsl
|
338
|
+
.init(k_builder,
|
339
|
+
on_exist: :write, # %i[skip write compare]
|
340
|
+
on_action: :execute # %i[queue execute]
|
341
|
+
)
|
342
|
+
.blueprint(
|
343
|
+
active: true,
|
344
|
+
on_exist: :write) do
|
345
|
+
|
346
|
+
cd(:lib)
|
347
|
+
|
348
|
+
add('schema/_.rb',
|
349
|
+
template_file: 'schema_require.rb',
|
350
|
+
elements: elements,
|
351
|
+
lines: lines,
|
352
|
+
texts: texts)
|
353
|
+
|
354
|
+
elements.each do |element|
|
355
|
+
add("schema/elements/#{element['key']}.rb",
|
356
|
+
template_file: 'schema_element.rb',
|
357
|
+
element: element)
|
358
|
+
end
|
359
|
+
|
360
|
+
lines.each do |line|
|
361
|
+
add("schema/lines/#{line['key']}.rb",
|
362
|
+
template_file: 'schema_line.rb',
|
363
|
+
line: line)
|
364
|
+
end
|
365
|
+
|
366
|
+
texts.each do |text|
|
367
|
+
add("schema/texts/#{text['key']}.rb",
|
368
|
+
template_file: 'schema_text.rb',
|
369
|
+
text: text)
|
370
|
+
end
|
371
|
+
|
372
|
+
add("drawio_shapes.rb" , template_file: 'drawio_shapes.rb' , shapes: lookup, shape_length: lookup.length)
|
373
|
+
add("dom_builder_shapes.rb" , template_file: 'dom_builder_shapes.rb' , shapes: lookup)
|
374
|
+
|
375
|
+
cd(:spec)
|
376
|
+
|
377
|
+
# build spec for each shape
|
378
|
+
elements.each do |element|
|
379
|
+
add("schema/elements/#{element['key']}_spec.rb",
|
380
|
+
template_file: 'schema_element_spec.rb',
|
381
|
+
element: element)
|
382
|
+
end
|
383
|
+
|
384
|
+
lines.each do |line|
|
385
|
+
add("schema/lines/#{line['key']}_spec.rb",
|
386
|
+
template_file: 'schema_line_spec.rb',
|
387
|
+
line: line)
|
388
|
+
end
|
389
|
+
|
390
|
+
texts.each do |text|
|
391
|
+
add("schema/texts/#{text['key']}_spec.rb",
|
392
|
+
template_file: 'schema_text_spec.rb',
|
393
|
+
text: text)
|
394
|
+
end
|
395
|
+
|
396
|
+
cd(:app)
|
397
|
+
run_command('rubocop -a')
|
398
|
+
|
399
|
+
end
|
400
|
+
end
|
data/.builders/boot.rb
CHANGED
@@ -16,6 +16,11 @@ def camel
|
|
16
16
|
Handlebars::Helpers::StringFormatting::Camel.new
|
17
17
|
end
|
18
18
|
|
19
|
+
def snake
|
20
|
+
require 'handlebars/helpers/string_formatting/snake'
|
21
|
+
Handlebars::Helpers::StringFormatting::Snake.new
|
22
|
+
end
|
23
|
+
|
19
24
|
def titleize
|
20
25
|
require 'handlebars/helpers/string_formatting/titleize'
|
21
26
|
Handlebars::Helpers::StringFormatting::Titleize.new
|
@@ -49,6 +54,9 @@ KConfig.configure(CONFIG_KEY) do |config|
|
|
49
54
|
config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
|
50
55
|
|
51
56
|
config.target_folders.add(:app , base_folder)
|
57
|
+
config.target_folders.add(:lib , :app, 'lib', 'tailwind_dsl')
|
58
|
+
config.target_folders.add(:spec , :app, 'spec', 'tailwind_dsl')
|
59
|
+
config.target_folders.add(:docs , :app, 'docs')
|
52
60
|
config.target_folders.add(:builder , builder_folder)
|
53
61
|
end
|
54
62
|
|
@@ -0,0 +1,97 @@
|
|
1
|
+
KManager.action :domain_model_to_code do
|
2
|
+
action do
|
3
|
+
director = KDirector::Dsls::RubyGemDsl
|
4
|
+
.init(k_builder,
|
5
|
+
template_base_folder: 'ruby/components/drawio_diagram',
|
6
|
+
on_exist: :skip, # %i[skip write compare]
|
7
|
+
on_action: :queue # %i[queue execute]
|
8
|
+
)
|
9
|
+
.data(
|
10
|
+
)
|
11
|
+
.blueprint(
|
12
|
+
active: true,
|
13
|
+
name: :build_domain,
|
14
|
+
description: 'Build the domain classes and tests based on the domain model',
|
15
|
+
on_exist: :skip) do
|
16
|
+
|
17
|
+
domain_model_list = domain_model.take(11)
|
18
|
+
|
19
|
+
domain_model_list.each do |code_block|
|
20
|
+
if code_block[:block_type] == 'klass'
|
21
|
+
klass = code_block[:items].select { |item| item[:type] == 'class' }.first
|
22
|
+
namespaces = snake.parse(klass[:namespace]).to_s.split('::')
|
23
|
+
model = {
|
24
|
+
name: klass[:name],
|
25
|
+
description: klass[:description],
|
26
|
+
namespaces: [:tailwind_dsl] + namespaces,
|
27
|
+
fields: code_block[:items].select { |item| item[:type] == 'field' }.map { |item| { name: item[:name], type: item[:type] } },
|
28
|
+
methods: code_block[:items].select { |item| item[:type] == 'method' }.map { |item| { name: item[:name], type: item[:type] } }
|
29
|
+
}
|
30
|
+
|
31
|
+
cd(:lib)
|
32
|
+
add(output_file_name(namespaces, klass[:name]), template_file: 'class.rb', model: model)
|
33
|
+
cd(:spec)
|
34
|
+
add(output_file_name(namespaces, klass[:name], suffix: '_spec'), template_file: 'class_spec.rb', model: model)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
require_paths = domain_model_list.map { |code_block|
|
39
|
+
klass = code_block[:items].select { |item| item[:type] == 'class' }.first
|
40
|
+
namespaces = snake.parse(klass[:namespace]).to_s.split('::')
|
41
|
+
full_namespace = [:tailwind_dsl] + namespaces + [snake.parse(klass[:name])]
|
42
|
+
full_namespace.join('/')
|
43
|
+
}
|
44
|
+
|
45
|
+
cd(:lib)
|
46
|
+
add('../_.rb', template_file: 'requires.rb', require_paths: require_paths)
|
47
|
+
|
48
|
+
run_command('rubocop -a')
|
49
|
+
|
50
|
+
# puts JSON.pretty_generate(domain_model)
|
51
|
+
# add('.gitignore')
|
52
|
+
end
|
53
|
+
|
54
|
+
director.play_actions
|
55
|
+
# director.builder.logit
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
@domain_model = nil
|
60
|
+
|
61
|
+
def domain_model
|
62
|
+
@domain_model ||= begin
|
63
|
+
file = k_builder.target_folders.get_filename(:docs, 'domain-model.json')
|
64
|
+
hash = JSON.parse(File.read(file), symbolize_names: true)
|
65
|
+
|
66
|
+
domain_page = hash[:pages].first
|
67
|
+
page_node = domain_page[:nodes].first
|
68
|
+
root_node = page_node[:nodes].first
|
69
|
+
code_blocks = root_node[:nodes].select { |node| node[:key] == 'klass' || node[:key] == 'interface' }
|
70
|
+
# puts JSON.pretty_generate(code_blocks)
|
71
|
+
# todo: post process to code block items to handle deep namespaces if needed
|
72
|
+
code_blocks.map do |code_block|
|
73
|
+
{
|
74
|
+
block_type: code_block[:key],
|
75
|
+
items: code_block[:meta_data][:items]
|
76
|
+
}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def output_file_name(namespaces, name, suffix: '', extension: 'rb')
|
82
|
+
name = snake.parse(name)
|
83
|
+
|
84
|
+
file_name = "#{name}#{suffix}.#{extension}"
|
85
|
+
file_parts = namespaces.reject(&:empty?)
|
86
|
+
file_parts << file_name
|
87
|
+
file_parts.join('/')
|
88
|
+
end
|
89
|
+
|
90
|
+
KManager.opts.app_name = 'domain_model_to_code'
|
91
|
+
KManager.opts.sleep = 2
|
92
|
+
KManager.opts.reboot_on_kill = 0
|
93
|
+
KManager.opts.reboot_sleep = 4
|
94
|
+
KManager.opts.exception_style = :short
|
95
|
+
KManager.opts.show.time_taken = true
|
96
|
+
KManager.opts.show.finished = true
|
97
|
+
KManager.opts.show.finished_message = 'FINISHED :)'
|