tailwind_dsl 0.0.7 → 0.0.9

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: 12b4cb1ead96f5fff7c3314de7a9c1cbf0acc4543749a16bd11ad1044f54c3bb
4
- data.tar.gz: afc589fd9df719bf67b6ab61088dd65345d39b617af6a5924f0a07a027991661
3
+ metadata.gz: 5dd15ed9d68116ddac73f9db7a46ed21a0b4b39eebf9d44116533a38bbb82de4
4
+ data.tar.gz: 77891a8ce328c52a31026b5166c5c8b36bbd49d8d92bfbb45cfe5f71ed18f307
5
5
  SHA512:
6
- metadata.gz: a88b93f3410119b8af4521b75fea20af52dfa84bae7b617ca163cfd3a600eeb36ff534ae470b2a99db4307313815657f05426618b3fbf32c08ba2b3d21658761
7
- data.tar.gz: b4bf2cc19b04b6ff284cfeba11c152921c869c989f53cb1efcca20aa2a3e71de84d08a544c7709512dd5bcd44a9d72c2e2470900d5e940c988dd58676654e403
6
+ metadata.gz: 5d7a1963927ef33b364afd4a66d5edf1d49302998406a75f70ed92265e7dc2e85bce394394707b8fac09fec456bb26a8f8e1a89970ba80d0824b8c7fc417b860
7
+ data.tar.gz: 30875df7abaf8519fdf7daa294a1eb81bc2721ad053a6e164965438b2c3211853bfcfe8bf054a2d419bcd80a41ee98e397c23e0af188dafb179d32205fd0c3e2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [0.0.8](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.7...v0.0.8) (2022-10-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add map_to to element ([216e93e](https://github.com/klueless-io/tailwind_dsl/commit/216e93ed8d1a59802132341b9501ee0921127061))
7
+
8
+ ## [0.0.7](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.6...v0.0.7) (2022-10-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add base element class with tests ([1845f67](https://github.com/klueless-io/tailwind_dsl/commit/1845f6769a3be7f81b2f8ed3c9e7e2e94d0b6861))
14
+ * json objects inherit element ([494908f](https://github.com/klueless-io/tailwind_dsl/commit/494908f840b562011038a387149cf3891ad3fe6c))
15
+
1
16
  ## [0.0.6](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.5...v0.0.6) (2022-10-12)
2
17
 
3
18
 
@@ -17,6 +17,34 @@ module TailwindDsl
17
17
 
18
18
  value || default
19
19
  end
20
+
21
+ # Map data to a class
22
+ #
23
+ # @param klass [Class] The class to map to
24
+ # @param data [Hash, Class] The data to map can be hash, an instance of the class or nil
25
+ def map_to(klass, data)
26
+ return nil if data.nil?
27
+
28
+ return data if data.is_a?(klass)
29
+ return klass.new(**data) if data.is_a?(Hash)
30
+
31
+ puts "Data of type: #{data.class} cannot be converted to #{klass}"
32
+ nil
33
+ end
34
+
35
+ # Add data onto an array
36
+ #
37
+ # @param target_list [Array] The array to add to
38
+ # @param data [Hash, Class] The data to add can be hash or an instance of the class. Nil data will not be added
39
+ def add_to_list(klass, target_list, data)
40
+ item = map_to(klass, data)
41
+
42
+ return nil if item.nil?
43
+
44
+ target_list << item
45
+
46
+ item
47
+ end
20
48
  end
21
49
  end
22
50
  end
@@ -14,17 +14,11 @@ module TailwindDsl
14
14
  def initialize(**args)
15
15
  @name = grab_arg(args, :name, guard: 'Missing name')
16
16
  @stats = grab_arg(args, :stats, default: {})
17
- @groups = grab_arg(args, :groups, default: []).map { |group| convert_group(group) }.compact
17
+ @groups = grab_arg(args, :groups, default: []).map { |group| map_to(Group, group) }.compact
18
18
  end
19
19
 
20
20
  def add_group(group)
21
- add = convert_group(group)
22
-
23
- return nil if add.nil?
24
-
25
- groups << add
26
-
27
- add
21
+ add_to_list(Group, groups, group)
28
22
  end
29
23
 
30
24
  def to_h
@@ -34,18 +28,6 @@ module TailwindDsl
34
28
  groups: groups.map(&:to_h)
35
29
  }
36
30
  end
37
-
38
- private
39
-
40
- def convert_group(group)
41
- return nil if group.nil?
42
-
43
- return group if group.is_a?(Group)
44
- return Group.new(**group) if group.is_a?(Hash)
45
-
46
- puts "Unknown group type: #{group.class}"
47
- nil
48
- end
49
31
  end
50
32
  end
51
33
  end
@@ -18,18 +18,11 @@ module TailwindDsl
18
18
  @type = grab_arg(args, :type, guard: 'Missing type')
19
19
  @folder = grab_arg(args, :folder, guard: 'Missing folder')
20
20
  @sub_keys = grab_arg(args, :sub_keys, guard: 'Missing sub_keys')
21
-
22
- @files = grab_arg(args, :files, default: []).map { |file| convert_file(file) }.compact
21
+ @files = grab_arg(args, :files, default: []).map { |file| map_to(SourceFile, file) }.compact
23
22
  end
24
23
 
25
24
  def add_file(file)
26
- add = convert_file(file)
27
-
28
- return nil if add.nil?
29
-
30
- files << add
31
-
32
- add
25
+ add_to_list(SourceFile, files, file)
33
26
  end
34
27
 
35
28
  def to_h
@@ -41,18 +34,6 @@ module TailwindDsl
41
34
  files: files.map(&:to_h)
42
35
  }
43
36
  end
44
-
45
- private
46
-
47
- def convert_file(file)
48
- return nil if file.nil?
49
-
50
- return file if file.is_a?(SourceFile)
51
- return SourceFile.new(**file) if file.is_a?(Hash)
52
-
53
- puts "Unknown file type: #{file.class}"
54
- nil
55
- end
56
37
  end
57
38
  end
58
39
  end
@@ -18,7 +18,7 @@ module TailwindDsl
18
18
  @file_name = grab_arg(args, :file_name, guard: 'Missing file_name')
19
19
  @file_name_only = grab_arg(args, :file_name_only, guard: 'Missing file_name_only')
20
20
  @file = grab_arg(args, :file, guard: 'Missing file')
21
- @target = convert_target(grab_arg(args, :target))
21
+ @target = map_to(TargetFile, grab_arg(args, :target))
22
22
  end
23
23
 
24
24
  def to_h
@@ -31,21 +31,6 @@ module TailwindDsl
31
31
  result[:target] = target.to_h if target
32
32
  result
33
33
  end
34
-
35
- private
36
-
37
- def convert_target(target)
38
- return nil if target.nil?
39
-
40
- case target
41
- when TargetFile
42
- target
43
- when Hash
44
- TargetFile.new(**target)
45
- else
46
- raise "Unknown target type: #{target.class}"
47
- end
48
- end
49
34
  end
50
35
  end
51
36
  end
@@ -6,7 +6,7 @@ module TailwindDsl
6
6
  # UiKit
7
7
  #
8
8
  # UiKit is a container for storing different tailwind design systems
9
- class UiKit
9
+ class UiKit < TailwindDsl::Etl::Element
10
10
  attr_accessor :design_systems
11
11
 
12
12
  # Pass in a document with the keys symbolized
@@ -23,7 +23,7 @@ module TailwindDsl
23
23
  end
24
24
 
25
25
  def add_design_system(design_system)
26
- add = convert_design_system(design_system)
26
+ add = map_to(DesignSystem, design_system)
27
27
 
28
28
  return nil if add.nil?
29
29
 
@@ -47,18 +47,6 @@ module TailwindDsl
47
47
  design_systems: design_systems.map(&:to_h)
48
48
  }
49
49
  end
50
-
51
- private
52
-
53
- def convert_design_system(design_system)
54
- return nil if design_system.nil?
55
-
56
- return design_system if design_system.is_a?(DesignSystem)
57
- return DesignSystem.new(**design_system) if design_system.is_a?(Hash)
58
-
59
- puts "Unknown design_system type: #{design_system.class}"
60
- nil
61
- end
62
50
  end
63
51
  end
64
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TailwindDsl
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.9'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "tailwind_dsl",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "tailwind_dsl",
9
- "version": "0.0.7",
9
+ "version": "0.0.9",
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.7",
3
+ "version": "0.0.9",
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailwind_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys