tailwind_dsl 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6646b23144a973701ff3a0357cdf6eb27fcc34e26690d2fdbcd77abf1b4767b
4
- data.tar.gz: 1930985fae4778a5d7576ba843f2f727c634c14802fa3c572d0513df5e2eb3f3
3
+ metadata.gz: 5c203889b4310594acefe53d47df83e002a6b824cb29dacaeb94e79b54f31da3
4
+ data.tar.gz: 5904e14763b77cb30a64c6aab0df1bbe50dca9137c5d78b95e3b0a1a1cea1df4
5
5
  SHA512:
6
- metadata.gz: a6ccea6907b5a4a1ff3cdc20fa20d0ce6dc814890d1cc4524e2fba9b124b85d599c5ae1046de94ddf10b20bde5292ddf79cdd7f0d0c38d6fa117a0bf7bb73ee1
7
- data.tar.gz: 8feb59692ddaf59ffe373c1492e08e45dfe546ab63bfc09554afe47322975ad0fb8de5ec91046bb506b0ad303543157a1c0e86c0c5098db85098d12d059ebfc5
6
+ metadata.gz: 7afe62703ff5c4cce8f5298821df980f00c0625e9b389f393e41349a016e9c463f04cbed97c15d71826d57dde9b9b1874ec9ec8b61f1ccbb120ac748cae71e30
7
+ data.tar.gz: 1933129c10fb231930cc6ada1525dba92b2b361729965b82712b0fa7bcf4b401bb0cc8e1039e8d2e1ad4cd1551a9d2c8f0e81940c09d055d66f3e26811f99ce5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.0.15](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.14...v0.0.15) (2022-10-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * refactor argument names ([3cb3a86](https://github.com/klueless-io/tailwind_dsl/commit/3cb3a869970fbe5a58afe5f1dc0cecf76b615433))
7
+
1
8
  ## [0.0.14](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.13...v0.0.14) (2022-10-18)
2
9
 
3
10
 
@@ -8,14 +8,19 @@ module TailwindDsl
8
8
  attr_reader :components
9
9
  attr_reader :target_root_path
10
10
  attr_reader :batch_size
11
+ attr_reader :batch_left
11
12
  attr_reader :use_prompt
13
+ attr_reader :filter_design_system
14
+ attr_reader :dry_run
12
15
 
13
- def initialize(components, target_root_path, batch_size: 1, use_prompt: false, filter_design_system: nil)
16
+ def initialize(components, target_root_path, **args)
14
17
  @components = components
15
18
  @target_root_path = target_root_path
16
- @batch_size = batch_size
19
+ @batch_size = args[:batch_size] || 1
17
20
  @batch_left = batch_size
18
- @use_prompt = use_prompt
21
+ @use_prompt = args[:use_prompt] || false
22
+ @filter_design_system = args[:filter_design_system] || nil
23
+ @dry_run = args[:dry_run] || false
19
24
  end
20
25
 
21
26
  # Goal: Extract the next (batch_size) component models using GPT3 and save them to target_root_path
@@ -28,15 +33,35 @@ module TailwindDsl
28
33
  # if :use_prompt is true then display the input/output files and ask if you wish to process the component or skip.
29
34
  # process the component by calling the GPT3 API and save the results to the target folder.
30
35
 
31
- def extract; end
36
+ def extract
37
+ filter_components.each do |component|
38
+ puts "Processing: #{component.design_system.name} -> #{component.group.key} -> #{component.name} -> remaining#: #{batch_left}"
39
+ # component_model_path = File.join(target_root_path, component.design_system.name, component.group_hierarchy, "#{component.name}.model.rb")
40
+ # next if File.exist?(component_model_path)
32
41
 
33
- # def components
34
- # @components ||= components.design_systems.map do |design_system|
35
- # design_system.components.map do |component|
36
- # Component.new(design_system, component, source_root_path, target_root_path)
37
- # end
38
- # end.flatten
39
- # end
42
+ # if use_prompt
43
+ # puts "Input: #{component.cleansed_html_path}"
44
+ # puts "Output: #{component_model_path}"
45
+ # puts 'Process? (y/n)'
46
+ # next unless STDIN.gets.chomp == 'y'
47
+ # end
48
+
49
+ # puts "Processing: #{component_model_path}"
50
+ @batch_left -= 1
51
+ break if batch_left.zero?
52
+
53
+ next if dry_run
54
+
55
+ # model = Gpt3::ComponentModel.new(component.cleansed_html_path)
56
+ # model.save(component_model_path)
57
+ end
58
+ end
59
+
60
+ def filter_components
61
+ return components unless filter_design_system
62
+
63
+ components.select { |component| component.design_system.name == filter_design_system }
64
+ end
40
65
  end
41
66
  end
42
67
  end
@@ -57,17 +57,18 @@ module TailwindDsl
57
57
  def query_components
58
58
  RawComponentQuery.query(uikit,
59
59
  source_root_path: source_root_path,
60
- target_root_path: target_root_path).records
60
+ target_root_path: target_root_path)
61
+ .components
61
62
  end
62
63
 
63
64
  def process_components
64
65
  @components.each do |component|
65
- unless File.exist?(component.absolute_path.source_file)
66
- puts "Source file does not exist: #{component.absolute_path.source_file}"
66
+ unless File.exist?(component.absolute.source_file)
67
+ puts "Source file does not exist: #{component.absolute.source_file}"
67
68
  next
68
69
  end
69
70
 
70
- # puts "DSN: #{component.design_system.name}, GRP: #{component.group.type}, FILE: #{component.relative_path.source_file}"
71
+ # puts "DSN: #{component.design_system.name}, GRP: #{component.group.type}, FILE: #{component.relative.source_file}"
71
72
 
72
73
  process_component(component)
73
74
  end
@@ -117,23 +118,23 @@ module TailwindDsl
117
118
  # rules:
118
119
  # if the html file exists, then read the settings file, if the settings has html overwrite, then overwrite the html file
119
120
  # overwrite = true
120
- FileUtils.cp_r(component.absolute_path.source_file, component.absolute_path.target_html_file, remove_destination: true) # if overwrite
121
+ FileUtils.cp_r(component.absolute.source_file, component.absolute.target_html_file, remove_destination: true) # if overwrite
121
122
  end
122
123
 
123
124
  def create_clean_html_file(component)
124
- html = File.read(component.absolute_path.source_file) || ''
125
+ html = File.read(component.absolute.source_file) || ''
125
126
  component.captured_comment_list = html.scan(COMMENT_REGEX)
126
127
  component.captured_comment_text = component.captured_comment_list.join("\n")
127
128
 
128
129
  html = html.gsub(COMMENT_REGEX, '').gsub(BLANK_LINE_REGEX, "\n").lstrip
129
130
 
130
- File.write(component.absolute_path.target_clean_html_file, html)
131
+ File.write(component.absolute.target_clean_html_file, html)
131
132
  end
132
133
 
133
134
  def create_tailwind_config_file(component)
134
135
  component.captured_tailwind_config = extract_tailwind_config(component)
135
136
 
136
- File.write(component.absolute_path.target_tailwind_config_file, component.captured_tailwind_config) if component.captured_tailwind_config
137
+ File.write(component.absolute.target_tailwind_config_file, component.captured_tailwind_config) if component.captured_tailwind_config
137
138
  end
138
139
 
139
140
  def create_settings_file(component)
@@ -169,7 +170,7 @@ module TailwindDsl
169
170
  tailwind_config: tailwind_config_settings(component.captured_tailwind_config)
170
171
  }
171
172
 
172
- File.write(component.absolute_path.target_settings_file, JSON.pretty_generate(settings))
173
+ File.write(component.absolute.target_settings_file, JSON.pretty_generate(settings))
173
174
  end
174
175
 
175
176
  def extract_tailwind_config(component)
@@ -33,30 +33,33 @@ module TailwindDsl
33
33
  :target_astro_file, keyword_init: true
34
34
  )
35
35
 
36
- class Record
36
+ class Component
37
+ attr_reader :name
37
38
  attr_reader :design_system
38
39
  attr_reader :group
39
- attr_reader :absolute_path
40
- attr_reader :relative_path
40
+ attr_reader :absolute
41
+ attr_reader :relative
41
42
 
42
43
  # Storage buckets for data that is extracted from the source file
43
44
  attr_accessor :captured_comment_text
44
45
  attr_accessor :captured_comment_list
45
46
  attr_accessor :captured_tailwind_config
46
47
 
47
- def initialize(design_system:, group:, absolute_path:, relative_path:)
48
+ def initialize(name:, design_system:, group:, absolute:, relative:)
49
+ @name = name
48
50
  @design_system = design_system
49
51
  @group = group
50
- @absolute_path = absolute_path
51
- @relative_path = relative_path
52
+ @absolute = absolute
53
+ @relative = relative
52
54
  end
53
55
 
54
56
  def to_h
55
57
  {
58
+ name: name,
56
59
  design_system: design_system.to_h,
57
60
  group: group.to_h,
58
- absolute_path: absolute_path.to_h,
59
- relative_path: relative_path.to_h
61
+ absolute: absolute.to_h,
62
+ relative: relative.to_h
60
63
  }
61
64
  end
62
65
  end
@@ -67,7 +70,7 @@ module TailwindDsl
67
70
  # Location for component structures
68
71
  attr_reader :target_root_path
69
72
  attr_reader :current_design_system
70
- attr_reader :records
73
+ attr_reader :components
71
74
 
72
75
  def initialize(uikit, **args)
73
76
  @uikit = uikit
@@ -83,34 +86,37 @@ module TailwindDsl
83
86
  end
84
87
 
85
88
  def call
86
- @records = build_records
89
+ @components = build_components
87
90
 
88
91
  self
89
92
  end
90
93
 
91
- # Flattened list of records in hash format
94
+ # Flattened list of components in hash format
92
95
  # @return [Array<Hash>] list
93
96
  def to_h
94
- records.map(&:to_h)
97
+ components.map(&:to_h)
95
98
  end
96
99
 
97
100
  private
98
101
 
99
- def build_records
102
+ # rubocop:disable Metrics/AbcSize
103
+ def build_components
100
104
  uikit.design_systems.flat_map do |design_system|
101
105
  @current_design_system = design_system
102
106
  design_system.groups.flat_map do |group|
103
107
  group.files.map do |file|
104
- Record.new(
108
+ Component.new(
109
+ name: file.file_name_only,
105
110
  design_system: DesignSystem.new(**map_design_system),
106
111
  group: Group.new(**map_group(group)),
107
- absolute_path: FilePath.new(**map_absolute_file(file)),
108
- relative_path: FilePath.new(**map_relative_file(file))
112
+ absolute: FilePath.new(**map_absolute_file(file)),
113
+ relative: FilePath.new(**map_relative_file(file))
109
114
  )
110
115
  end
111
116
  end
112
117
  end
113
118
  end
119
+ # rubocop:enable Metrics/AbcSize
114
120
 
115
121
  def design_system_name
116
122
  current_design_system.name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindDsl
4
- VERSION = '0.0.15'
4
+ VERSION = '0.0.16'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "tailwind_dsl",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "tailwind_dsl",
9
- "version": "0.0.15",
9
+ "version": "0.0.16",
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.15",
3
+ "version": "0.0.16",
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.15
4
+ version: 0.0.16
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-18 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdlet