tailwind_dsl 0.0.28 → 0.0.29

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: ec90fa82ceee220d0a9cbe382e1a724dc8e3a616b6f2452174d60ef3eb6f12d6
4
- data.tar.gz: ef5f47eeedc68ba11d750bd9683b2ecdc311f2cc204541261b08d79c223e435c
3
+ metadata.gz: a70be418386e67d6810404f966f97be9eff5cb76f29749f09720ce82a5ede862
4
+ data.tar.gz: 61177d4aa5b7739ad0f04f1e8dee210d176a166c0b51d71b4797075e320e23cb
5
5
  SHA512:
6
- metadata.gz: 1dd6c71477b385c209e06baa71348603f791d12a8af4246fead01dd1e33cc9e6cf10db17d066aeb54a95c745404e7223a3b986cad4d2e5be4f6cc28529d402d3
7
- data.tar.gz: efa06b0467b8d6bf5032b48ef1ef7091ce7b6c730a582060d56d9f55281a502810e9a82013a457bcca22f4da68106167f5ca9f1afd61abd44c85eb8e744be9d4
6
+ metadata.gz: 6a3597b9e27978d20c4fc6a55f087b8a1da50952028b09c97a5ce1bf286a7c4d5de42279bd4c719a328393df26c4734c1d13794513f5aa07f6ac8e5f4cf7d288
7
+ data.tar.gz: e252253ba7ff48a6b6ac604e6bd1122dfcc997d51708389218f27be0499ee14fa48a84de6a36e5c7c56481503d2151ffdb7ccd9797a45da7bd78f3d562d80370
data/.builders/boot.rb CHANGED
@@ -6,7 +6,10 @@ CONFIG_KEY = :tailwind_dsl
6
6
 
7
7
  log.kv 'working folder', Dir.pwd
8
8
 
9
- require_relative '../lib/tailwind_dsl'
9
+ # require 'gpt3/builder'
10
+ # require '/Users/davidcruwys/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/gpt3-builder-0.0.3/lib/gpt3/builder'
11
+
12
+ # require_relative '../lib/tailwind_dsl'
10
13
 
11
14
  KConfig.configure do |config|
12
15
  config.handlebars.defaults.add_all_defaults
@@ -1,3 +1,5 @@
1
+ require 'gpt3/builder'
2
+
1
3
  KManager.action :utilities do
2
4
  helpers = self
3
5
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.0.28](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.27...v0.0.28) (2022-10-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * remove sample specs from git hub actions ([2595490](https://github.com/klueless-io/tailwind_dsl/commit/2595490dc3e90d343c5e3e8f203ad4f71ba8dec4))
7
+
1
8
  ## [0.0.27](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.26...v0.0.27) (2022-10-24)
2
9
 
3
10
 
@@ -0,0 +1,207 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This is Reusable across concerns, it should be in it's own folder or in the ETL root
4
+ # Rename to component_list or component_query
5
+
6
+ module TailwindDsl
7
+ module Etl
8
+ # Component Query will return a list of raw components that are available for processing
9
+ #
10
+ # The query requires a uikit to be passed in, this is used to flatten and filter the components
11
+ class ComponentQuery
12
+ DesignSystem = Struct.new(:name, :source_path, :target_path, keyword_init: true) do
13
+ def debug
14
+ puts format('%-30<key>s : %<value>s', key: 'Design system', value: name)
15
+ puts format('%-30<key>s : %<value>s', key: 'Source path', value: source_path)
16
+ puts format('%-30<key>s : %<value>s', key: 'Target path', value: target_path)
17
+ end
18
+ end
19
+
20
+ Group = Struct.new(:key, :type, :sub_keys, :folder, keyword_init: true) do
21
+ def debug
22
+ puts format('%-30<key>s : %<value>s', key: 'Group key', value: key)
23
+ puts format('%-30<key>s : %<value>s', key: 'Group type', value: type)
24
+ puts format('%-30<key>s : %<value>s', key: 'Group sub keys', value: sub_keys)
25
+ puts format('%-30<key>s : %<value>s', key: 'Group folder', value: folder)
26
+ end
27
+ end
28
+
29
+ FilePath = Struct.new(
30
+ :source_file,
31
+ :target_html_file,
32
+ :target_clean_html_file,
33
+ :target_tailwind_config_file,
34
+ :target_settings_file,
35
+ :target_data_file,
36
+ :target_model_file,
37
+ :target_astro_file,
38
+ keyword_init: true
39
+ ) do
40
+ # rubocop:disable Metrics/AbcSize
41
+ def debug
42
+ puts format('%-30<key>s : %<value>s', key: 'Source file', value: source_file)
43
+ puts format('%-30<key>s : %<value>s', key: 'Target html file', value: target_html_file)
44
+ puts format('%-30<key>s : %<value>s', key: 'Target clean html file', value: target_clean_html_file)
45
+ puts format('%-30<key>s : %<value>s', key: 'Target tailwind config file', value: target_tailwind_config_file)
46
+ puts format('%-30<key>s : %<value>s', key: 'Target settings file', value: target_settings_file)
47
+ puts format('%-30<key>s : %<value>s', key: 'Target data file', value: target_data_file)
48
+ puts format('%-30<key>s : %<value>s', key: 'Target model file', value: target_model_file)
49
+ puts format('%-30<key>s : %<value>s', key: 'Target astro file', value: target_astro_file)
50
+ end
51
+ # rubocop:enable Metrics/AbcSize
52
+ end
53
+
54
+ class Component
55
+ attr_reader :name
56
+ attr_reader :design_system
57
+ attr_reader :group
58
+ attr_reader :absolute
59
+ attr_reader :relative
60
+
61
+ # Storage buckets for data that is extracted from the source file
62
+ attr_accessor :captured_comment_text
63
+ attr_accessor :captured_comment_list
64
+ attr_accessor :captured_tailwind_config
65
+
66
+ def initialize(name:, design_system:, group:, absolute:, relative:)
67
+ @name = name
68
+ @design_system = design_system
69
+ @group = group
70
+ @absolute = absolute
71
+ @relative = relative
72
+ end
73
+
74
+ def to_h
75
+ {
76
+ name: name,
77
+ design_system: design_system.to_h,
78
+ group: group.to_h,
79
+ absolute: absolute.to_h,
80
+ relative: relative.to_h
81
+ }
82
+ end
83
+
84
+ def debug
85
+ puts format('%-30<key>s : %<value>s', key: 'Component', value: name)
86
+ design_system.debug
87
+ group.debug
88
+ puts ':: Absolute paths'
89
+ absolute.debug
90
+ puts '::Relative paths'
91
+ relative.debug
92
+ end
93
+ end
94
+
95
+ attr_reader :uikit
96
+ # Location for raw components
97
+ attr_reader :source_root_path
98
+ # Location for component structures
99
+ attr_reader :target_root_path
100
+ attr_reader :current_design_system
101
+ attr_reader :components
102
+
103
+ def initialize(uikit, **args)
104
+ @uikit = uikit
105
+ @source_root_path = args[:source_root_path] || raise(ArgumentError, 'Missing source_root_path')
106
+ @target_root_path = args[:target_root_path] || raise(ArgumentError, 'Missing target_root_path')
107
+ end
108
+
109
+ class << self
110
+ def query(uikit, source_root_path:, target_root_path:)
111
+ instance = new(uikit, source_root_path: source_root_path, target_root_path: target_root_path)
112
+ instance.call
113
+ end
114
+ end
115
+
116
+ def call
117
+ @components = build_components.sort_by { |component| [component.design_system.name, component.group.key, component.name] }
118
+
119
+ self
120
+ end
121
+
122
+ # Flattened list of components in hash format
123
+ # @return [Array<Hash>] list
124
+ def to_h
125
+ components.map(&:to_h)
126
+ end
127
+
128
+ private
129
+
130
+ # rubocop:disable Metrics/AbcSize
131
+ def build_components
132
+ uikit.design_systems.flat_map do |design_system|
133
+ @current_design_system = design_system
134
+ design_system.groups.flat_map do |group|
135
+ group.files.map do |file|
136
+ Component.new(
137
+ name: file.file_name_only,
138
+ design_system: DesignSystem.new(**map_design_system),
139
+ group: Group.new(**map_group(group)),
140
+ absolute: FilePath.new(**map_absolute_file(file)),
141
+ relative: FilePath.new(**map_relative_file(file))
142
+ )
143
+ end
144
+ end
145
+ end
146
+ end
147
+ # rubocop:enable Metrics/AbcSize
148
+
149
+ def design_system_name
150
+ current_design_system.name
151
+ end
152
+
153
+ def source_path
154
+ File.join(source_root_path, design_system_name)
155
+ end
156
+
157
+ def target_path
158
+ File.join(target_root_path, design_system_name)
159
+ end
160
+
161
+ def map_design_system
162
+ {
163
+ name: design_system_name,
164
+ source_path: source_path,
165
+ target_path: target_path
166
+ }
167
+ end
168
+
169
+ def map_group(group)
170
+ {
171
+ key: group.key,
172
+ type: group.type,
173
+ sub_keys: group.sub_keys,
174
+ folder: group.folder
175
+ }
176
+ end
177
+
178
+ def map_relative_file(file)
179
+ {
180
+ source_file: file.file,
181
+ target_html_file: file.target.html_file,
182
+ target_clean_html_file: file.target.clean_html_file,
183
+ target_tailwind_config_file: file.target.tailwind_config_file,
184
+ target_settings_file: file.target.settings_file,
185
+ target_data_file: file.target.data_file,
186
+ target_model_file: file.target.model_file,
187
+ target_astro_file: file.target.astro_file
188
+ }
189
+ end
190
+
191
+ # rubocop:disable Metrics/AbcSize
192
+ def map_absolute_file(file)
193
+ {
194
+ source_file: File.join(source_path, file.file),
195
+ target_html_file: File.join(target_path, file.target.html_file),
196
+ target_clean_html_file: File.join(target_path, file.target.clean_html_file),
197
+ target_tailwind_config_file: File.join(target_path, file.target.tailwind_config_file),
198
+ target_settings_file: File.join(target_path, file.target.settings_file),
199
+ target_data_file: File.join(target_path, file.target.data_file),
200
+ target_model_file: File.join(target_path, file.target.model_file),
201
+ target_astro_file: File.join(target_path, file.target.astro_file)
202
+ }
203
+ end
204
+ # rubocop:enable Metrics/AbcSize
205
+ end
206
+ end
207
+ end
@@ -54,10 +54,10 @@ module TailwindDsl
54
54
  end
55
55
 
56
56
  def query_components
57
- RawComponentQuery.query(uikit,
58
- source_root_path: source_root_path,
59
- target_root_path: target_root_path)
60
- .components
57
+ ComponentQuery.query(uikit,
58
+ source_root_path: source_root_path,
59
+ target_root_path: target_root_path)
60
+ .components
61
61
  end
62
62
 
63
63
  def process_components
@@ -11,12 +11,27 @@ module TailwindDsl
11
11
  component.absolute.target_data_file
12
12
  end
13
13
 
14
+ # rubocop:disable Metrics/AbcSize
14
15
  def extract
15
- puts 'do some magic and write to target_file'
16
- puts "target_file: #{target_file}"
17
- File.write(target_file, 'GTP3 data')
18
- # do some GPT3 magic
16
+ builder = Gpt3::Builder::Gpt3Builder.init
17
+
18
+ tokens = 250
19
+
20
+ source_file = component.absolute.target_clean_html_file
21
+ source = File.read(source_file)
22
+
23
+ target_file = component.absolute.target_data_file
24
+ component_type = component.group.sub_keys.last
25
+
26
+ builder
27
+ .start("Extract JSON data from '#{component_type}' HTML component")
28
+ .message('HTML:')
29
+ .example(source)
30
+ .message('JSON:')
31
+ .complete(engine: 'code-davinci-002', max_tokens: tokens, suffix: "\n")
32
+ .write_result(target_file)
19
33
  end
34
+ # rubocop:enable Metrics/AbcSize
20
35
  end
21
36
  end
22
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindDsl
4
- VERSION = '0.0.28'
4
+ VERSION = '0.0.29'
5
5
  end
data/lib/tailwind_dsl.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'cmdlet'
4
+ require 'gpt3/builder'
4
5
 
5
6
  require_relative 'tailwind_dsl/version'
6
7
  # require_relative '_'
7
8
 
9
+ require_relative 'tailwind_dsl/etl/component_query'
10
+
8
11
  require_relative 'tailwind_dsl/etl/raw_components/load'
9
12
  require_relative 'tailwind_dsl/etl/raw_components/transformer'
10
13
 
@@ -15,7 +18,6 @@ require_relative 'tailwind_dsl/etl/raw_components/schema/group'
15
18
  require_relative 'tailwind_dsl/etl/raw_components/schema/design_system'
16
19
  require_relative 'tailwind_dsl/etl/raw_components/schema/uikit'
17
20
 
18
- require_relative 'tailwind_dsl/etl/component_structures/raw_component_query'
19
21
  require_relative 'tailwind_dsl/etl/component_structures/generator'
20
22
 
21
23
  require_relative 'tailwind_dsl/etl/extractors/base_extractor'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "tailwind_dsl",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "tailwind_dsl",
9
- "version": "0.0.28",
9
+ "version": "0.0.29",
10
10
  "devDependencies": {
11
11
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
12
12
  "@semantic-release/changelog": "^6.0.1",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind_dsl",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "Tailwind DSL will build tailwind websites useing Domain Specific Language conventions",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailwind_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-24 00:00:00.000000000 Z
11
+ date: 2022-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdlet
@@ -2174,8 +2174,8 @@ files:
2174
2174
  - lib/_.rb
2175
2175
  - lib/tailwind_dsl.rb
2176
2176
  - lib/tailwind_dsl/astro_demo/generate_astro_page_data.rb
2177
+ - lib/tailwind_dsl/etl/component_query.rb
2177
2178
  - lib/tailwind_dsl/etl/component_structures/generator.rb
2178
- - lib/tailwind_dsl/etl/component_structures/raw_component_query.rb
2179
2179
  - lib/tailwind_dsl/etl/element.rb
2180
2180
  - lib/tailwind_dsl/etl/extractors/base_extractor.rb
2181
2181
  - lib/tailwind_dsl/etl/extractors/batch_extraction.rb
@@ -1,215 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This is Reusable across concerns, it should be in it's own folder or in the ETL root
4
- # Rename to component_list or component_query
5
-
6
- module TailwindDsl
7
- module Etl
8
- module ComponentStructures
9
- # Raw Component Query will return a list of raw components that are available for processing
10
- #
11
- # This is a two pass process:
12
- # 1. Query the raw component folder for all files that match the pattern and build up a graph with required information
13
-
14
- # puts '%-20s %s' % ['name', name]
15
- # puts '%-20s %s' % ['source_path', source_path]
16
- # puts '%-20s %s' % ['target_path', target_path]
17
- # 2. Flatten the graph into a list of rows
18
- class RawComponentQuery
19
- DesignSystem = Struct.new(:name, :source_path, :target_path, keyword_init: true) do
20
- def debug
21
- puts format('%-30<key>s : %<value>s', key: 'Design system', value: name)
22
- puts format('%-30<key>s : %<value>s', key: 'Source path', value: source_path)
23
- puts format('%-30<key>s : %<value>s', key: 'Target path', value: target_path)
24
- end
25
- end
26
-
27
- Group = Struct.new(:key, :type, :sub_keys, :folder, keyword_init: true) do
28
- def debug
29
- puts format('%-30<key>s : %<value>s', key: 'Group key', value: key)
30
- puts format('%-30<key>s : %<value>s', key: 'Group type', value: type)
31
- puts format('%-30<key>s : %<value>s', key: 'Group sub keys', value: sub_keys)
32
- puts format('%-30<key>s : %<value>s', key: 'Group folder', value: folder)
33
- end
34
- end
35
-
36
- FilePath = Struct.new(
37
- :source_file,
38
- :target_html_file,
39
- :target_clean_html_file,
40
- :target_tailwind_config_file,
41
- :target_settings_file,
42
- :target_data_file,
43
- :target_model_file,
44
- :target_astro_file,
45
- keyword_init: true
46
- ) do
47
- # rubocop:disable Metrics/AbcSize
48
- def debug
49
- puts format('%-30<key>s : %<value>s', key: 'Source file', value: source_file)
50
- puts format('%-30<key>s : %<value>s', key: 'Target html file', value: target_html_file)
51
- puts format('%-30<key>s : %<value>s', key: 'Target clean html file', value: target_clean_html_file)
52
- puts format('%-30<key>s : %<value>s', key: 'Target tailwind config file', value: target_tailwind_config_file)
53
- puts format('%-30<key>s : %<value>s', key: 'Target settings file', value: target_settings_file)
54
- puts format('%-30<key>s : %<value>s', key: 'Target data file', value: target_data_file)
55
- puts format('%-30<key>s : %<value>s', key: 'Target model file', value: target_model_file)
56
- puts format('%-30<key>s : %<value>s', key: 'Target astro file', value: target_astro_file)
57
- end
58
- # rubocop:enable Metrics/AbcSize
59
- end
60
-
61
- class Component
62
- attr_reader :name
63
- attr_reader :design_system
64
- attr_reader :group
65
- attr_reader :absolute
66
- attr_reader :relative
67
-
68
- # Storage buckets for data that is extracted from the source file
69
- attr_accessor :captured_comment_text
70
- attr_accessor :captured_comment_list
71
- attr_accessor :captured_tailwind_config
72
-
73
- def initialize(name:, design_system:, group:, absolute:, relative:)
74
- @name = name
75
- @design_system = design_system
76
- @group = group
77
- @absolute = absolute
78
- @relative = relative
79
- end
80
-
81
- def to_h
82
- {
83
- name: name,
84
- design_system: design_system.to_h,
85
- group: group.to_h,
86
- absolute: absolute.to_h,
87
- relative: relative.to_h
88
- }
89
- end
90
-
91
- def debug
92
- puts format('%-30<key>s : %<value>s', key: 'Component', value: name)
93
- design_system.debug
94
- group.debug
95
- puts ':: Absolute paths'
96
- absolute.debug
97
- puts '::Relative paths'
98
- relative.debug
99
- end
100
- end
101
-
102
- attr_reader :uikit
103
- # Location for raw components
104
- attr_reader :source_root_path
105
- # Location for component structures
106
- attr_reader :target_root_path
107
- attr_reader :current_design_system
108
- attr_reader :components
109
-
110
- def initialize(uikit, **args)
111
- @uikit = uikit
112
- @source_root_path = args[:source_root_path] || raise(ArgumentError, 'Missing source_root_path')
113
- @target_root_path = args[:target_root_path] || raise(ArgumentError, 'Missing target_root_path')
114
- end
115
-
116
- class << self
117
- def query(uikit, source_root_path:, target_root_path:)
118
- instance = new(uikit, source_root_path: source_root_path, target_root_path: target_root_path)
119
- instance.call
120
- end
121
- end
122
-
123
- def call
124
- @components = build_components.sort_by { |component| [component.design_system.name, component.group.key, component.name] }
125
-
126
- self
127
- end
128
-
129
- # Flattened list of components in hash format
130
- # @return [Array<Hash>] list
131
- def to_h
132
- components.map(&:to_h)
133
- end
134
-
135
- private
136
-
137
- # rubocop:disable Metrics/AbcSize
138
- def build_components
139
- uikit.design_systems.flat_map do |design_system|
140
- @current_design_system = design_system
141
- design_system.groups.flat_map do |group|
142
- group.files.map do |file|
143
- Component.new(
144
- name: file.file_name_only,
145
- design_system: DesignSystem.new(**map_design_system),
146
- group: Group.new(**map_group(group)),
147
- absolute: FilePath.new(**map_absolute_file(file)),
148
- relative: FilePath.new(**map_relative_file(file))
149
- )
150
- end
151
- end
152
- end
153
- end
154
- # rubocop:enable Metrics/AbcSize
155
-
156
- def design_system_name
157
- current_design_system.name
158
- end
159
-
160
- def source_path
161
- File.join(source_root_path, design_system_name)
162
- end
163
-
164
- def target_path
165
- File.join(target_root_path, design_system_name)
166
- end
167
-
168
- def map_design_system
169
- {
170
- name: design_system_name,
171
- source_path: source_path,
172
- target_path: target_path
173
- }
174
- end
175
-
176
- def map_group(group)
177
- {
178
- key: group.key,
179
- type: group.type,
180
- sub_keys: group.sub_keys,
181
- folder: group.folder
182
- }
183
- end
184
-
185
- def map_relative_file(file)
186
- {
187
- source_file: file.file,
188
- target_html_file: file.target.html_file,
189
- target_clean_html_file: file.target.clean_html_file,
190
- target_tailwind_config_file: file.target.tailwind_config_file,
191
- target_settings_file: file.target.settings_file,
192
- target_data_file: file.target.data_file,
193
- target_model_file: file.target.model_file,
194
- target_astro_file: file.target.astro_file
195
- }
196
- end
197
-
198
- # rubocop:disable Metrics/AbcSize
199
- def map_absolute_file(file)
200
- {
201
- source_file: File.join(source_path, file.file),
202
- target_html_file: File.join(target_path, file.target.html_file),
203
- target_clean_html_file: File.join(target_path, file.target.clean_html_file),
204
- target_tailwind_config_file: File.join(target_path, file.target.tailwind_config_file),
205
- target_settings_file: File.join(target_path, file.target.settings_file),
206
- target_data_file: File.join(target_path, file.target.data_file),
207
- target_model_file: File.join(target_path, file.target.model_file),
208
- target_astro_file: File.join(target_path, file.target.astro_file)
209
- }
210
- end
211
- # rubocop:enable Metrics/AbcSize
212
- end
213
- end
214
- end
215
- end