tailwind_dsl 0.0.20 → 0.0.21

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: 59f2ab634f3b594b52b4c320dd148ad583f9bc9f3b7b9fecefc930b5997d4dca
4
- data.tar.gz: 149b69e1c9c976f29d87e4d6f333a6649df648bb8cd43979bd8ac327119ea019
3
+ metadata.gz: 7cd0c0909e9a48950228de203ff226826d232fa82798e57ce11513d8fb333ffa
4
+ data.tar.gz: 38307842f83d9d0f9d55aab36baba41e3e62b4f6ebffeacf80a27850757ece74
5
5
  SHA512:
6
- metadata.gz: 80de90f95be1c3a185718e37e1d81d06bd895f12af0c434e6f4a08c5ce45ad292653986d9d435bc73880e3293d33ecdfd0433b5cbf3ca6a4594a1b15152f22b3
7
- data.tar.gz: 6cb6df996df398e6651c365b99e5c401ff4ab300d68bc26477a186f20a519b245fd8df41bfeea22ca437aac36ed1d6330d236982489ecec783ee92a3c103f252
6
+ metadata.gz: 894085b30a5b7219cb9c02b31c6ea1ab187cf7a7a26b4c0c5e670b6ff079b56ac31cfd9f3bd707a0018dce2237d8d0f20733f013e830860dd70bfb6284d1634a
7
+ data.tar.gz: 155bbf81aa7e67918d4eb904f92a1f8f06fbd74537893e8cf3c7b4f3483428ff0a96797479b3e5473cc9c2dbfbd2ca8f83272757cba5254a3c32b5d0f071a391
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.0.20](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.19...v0.0.20) (2022-10-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * rename director to load ([db85a1b](https://github.com/klueless-io/tailwind_dsl/commit/db85a1b85804390865ec66dabe9d7561767c6578))
7
+
1
8
  ## [0.0.19](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.18...v0.0.19) (2022-10-21)
2
9
 
3
10
 
@@ -18,16 +18,23 @@ module TailwindDsl
18
18
  attr_reader :components
19
19
  attr_reader :target_root_path
20
20
  attr_reader :batch_size
21
- attr_reader :batch_left
22
21
  attr_reader :use_prompt
23
22
  attr_reader :filter_design_system
24
23
  attr_reader :extract_handler
25
24
 
25
+ # Create comment for this initialize method
26
+
27
+ # @param [Array] components list of components that can be used to extract data
28
+ # @param [String] target_root_path root directory where the extracted data will be written to, this is the root path for all design systems and groups
29
+ # @param [Hash] args
30
+ # @option args [Integer] :batch_size number of components to process, default is 1
31
+ # @option args [Boolean] :use_prompt console based prompt so the user can guide the extractor, default is false
32
+ # @option args [String] :filter_design_system name of the design system to filter on, default is nil meaning all
33
+ # @option args [Class] :extract_handler class that implements the extract_data and extract_model methods, default is Gpt3Extractor
26
34
  def initialize(components, target_root_path, **args)
27
35
  @components = components
28
36
  @target_root_path = target_root_path
29
37
  @batch_size = args[:batch_size] || 1
30
- @batch_left = batch_size
31
38
  @use_prompt = args[:use_prompt] || false
32
39
  @filter_design_system = args[:filter_design_system] || nil
33
40
  @extract_handler = (args[:extract_handler] || Gpt3Extractor).new
@@ -45,16 +52,17 @@ module TailwindDsl
45
52
  # if :use_prompt is true then display the input/output files and ask if you wish to process the component or skip.
46
53
  # process the component by calling the GPT3 API and save the results to the target folder.
47
54
 
48
- # rubocop:disable Metrics/AbcSize
49
55
  def extract
50
56
  guards
51
57
 
58
+ remaining = batch_size
59
+
52
60
  filter_components.each do |component|
53
- puts "Processing: #{component.design_system.name} -> #{component.group.key} -> #{component.name} -> remaining#: #{batch_left}"
61
+ # puts "Processing: #{component.design_system.name} -> #{component.group.key} -> #{component.name} -> remaining#: #{remaining}"
62
+
63
+ component_guards(component)
54
64
 
55
- component.debug
56
- # component_model_path = File.join(target_root_path, component.design_system.name, component.group_hierarchy, "#{component.name}.model.rb")
57
- # next if File.exist?(component_model_path)
65
+ next if data_file_exist?(component) && model_file_exist?(component)
58
66
 
59
67
  # if use_prompt
60
68
  # puts "Input: #{component.cleansed_html_path}"
@@ -63,21 +71,13 @@ module TailwindDsl
63
71
  # next unless STDIN.gets.chomp == 'y'
64
72
  # end
65
73
 
66
- # puts "Processing: #{component_model_path}"
67
-
68
- # next if extract_handler
69
-
70
- # model = Gpt3::ComponentModel.new(component.cleansed_html_path)
71
- # model.save(component_model_path)
72
-
73
- extract_handler.extract_data(component)
74
- extract_handler.extract_model(component)
74
+ extract_handler.extract_data(component) unless data_file_exist?(component)
75
+ extract_handler.extract_model(component) unless model_file_exist?(component)
75
76
 
76
- @batch_left -= 1
77
- break if batch_left.zero?
77
+ remaining -= 1
78
+ break if remaining.zero?
78
79
  end
79
80
  end
80
- # rubocop:enable Metrics/AbcSize
81
81
 
82
82
  private
83
83
 
@@ -88,11 +88,24 @@ module TailwindDsl
88
88
  raise 'Extract handler must implement extract_model method' unless extract_handler.respond_to?(:extract_model)
89
89
  end
90
90
 
91
+ def component_guards(component)
92
+ path = File.join(component.design_system.target_path, component.group.folder)
93
+ raise "Folder does not exist: '#{path}', make sure you run component structure generator first." unless File.exist?(path)
94
+ end
95
+
91
96
  def filter_components
92
97
  return components unless filter_design_system
93
98
 
94
99
  components.select { |component| component.design_system.name == filter_design_system }
95
100
  end
101
+
102
+ def data_file_exist?(component)
103
+ File.exist?(component.absolute.target_data_file)
104
+ end
105
+
106
+ def model_file_exist?(component)
107
+ File.exist?(component.absolute.target_model_file)
108
+ end
96
109
  end
97
110
  end
98
111
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Build/Translate COMPONENT STRUCTURE
4
+
3
5
  module TailwindDsl
4
6
  module Etl
5
7
  module ComponentStructures
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
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
+
3
6
  module TailwindDsl
4
7
  module Etl
5
8
  module ComponentStructures
@@ -118,7 +121,7 @@ module TailwindDsl
118
121
  end
119
122
 
120
123
  def call
121
- @components = build_components
124
+ @components = build_components.sort_by { |component| [component.design_system.name, component.group.key, component.name] }
122
125
 
123
126
  self
124
127
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindDsl
4
- VERSION = '0.0.20'
4
+ VERSION = '0.0.21'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "tailwind_dsl",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "tailwind_dsl",
9
- "version": "0.0.20",
9
+ "version": "0.0.21",
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.20",
3
+ "version": "0.0.21",
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.20
4
+ version: 0.0.21
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-21 00:00:00.000000000 Z
11
+ date: 2022-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdlet