k_builder 0.0.55 → 0.0.56

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: 3f0600bab4a6de1743b8be1d7f14f4cc20e997edc60201e920fd3102086472bf
4
- data.tar.gz: ad10a064ebf45d8e73aac310b7c6725193f3cf36bacc847f0fe2e312919c0b1b
3
+ metadata.gz: 758519925163c21cae5ef6bd99798577d7481f6bff55d6ce51599ee15bdd1baa
4
+ data.tar.gz: 89fbffd295334411d71ea48279838e13029ed01e3fa9c5b76be2aea7f1d44c8b
5
5
  SHA512:
6
- metadata.gz: b3c82683757bf60d630b3e9e6827b57abbaca1bbd83b132e7dd1433961f8946acd651beb5eebf8614cbcd5ad544ea7aa8b7bfd7a7c48feadf87a3e0d8c651acf
7
- data.tar.gz: d8c7778a7501ccf7a76611bf15aae7d3824658e48e5249c2a1f7879fad7b18ae354323fe92794171737b1ddd386e38ab254f9f399895acd8af86014f3688e98c
6
+ metadata.gz: a620cc2730bdac7d129de3b7975967d2bea5819213091c7c551a4ed59a480f994617f08fb2649c9aeb46968181f0dea956875c3c6e87d456eacbe29310ab5295
7
+ data.tar.gz: 3bd54f3c7e9869fbb232239096ac201a62299b292fffa00cfd3612a7fb7f2b43b9242e86d6821142f1ed4743d7e68cff3d2e10789342dd346a8abb2241b3e9c7
@@ -1,55 +1,63 @@
1
- # frozen_string_literal: true
2
-
3
- module KBuilder
4
- # Base configuration object for all k_builder* GEM
5
- class BaseConfiguration
6
- def self.attach_to(klass_me, klass_target, accessor_name)
7
- # Create a memoized getter to an instance of the attaching class (:klass_me)
8
- #
9
- # def third_party
10
- # @third_party ||= KBuilder::ThirdPartyGem::Configuration.new
11
- # end
12
- klass_target.send(:define_method, accessor_name) do
13
- return instance_variable_get("@#{accessor_name}") if instance_variable_defined?("@#{accessor_name}")
14
-
15
- instance_variable_set("@#{accessor_name}", klass_me.new)
16
- end
17
- end
18
-
19
- # move out into module
20
- def to_h
21
- hash = {}
22
- instance_variables.each do |var|
23
- value = instance_variable_get(var)
24
-
25
- value = KUtil.data.to_hash(value) if complex_type?(value)
26
-
27
- hash[var.to_s.delete('@')] = value
28
- end
29
- hash
30
- end
31
-
32
- # Any basic (aka primitive) type
33
- def basic_type?(value)
34
- value.is_a?(String) ||
35
- value.is_a?(Symbol) ||
36
- value.is_a?(FalseClass) ||
37
- value.is_a?(TrueClass) ||
38
- value.is_a?(Integer) ||
39
- value.is_a?(Float)
40
- end
41
-
42
- # Anything container that is not a regular class
43
- def complex_type?(value)
44
- value.is_a?(Array) ||
45
- value.is_a?(Hash) ||
46
- value.is_a?(Struct) ||
47
- value.is_a?(OpenStruct) ||
48
- value.respond_to?(:to_h)
49
- end
50
-
51
- def kv(name, value)
52
- puts "#{name.rjust(30)} : #{value}"
53
- end
54
- end
55
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KBuilder
4
+ # Base configuration object for all k_builder* GEM
5
+ class BaseConfiguration
6
+ class << self
7
+ # Attach a child configuration with it's own settings to a parent configuration
8
+ #
9
+ # @param [Class] klass_child what class would you like as the child
10
+ # @param [Class] klass_parent what class would you like to extend with a new child configuration
11
+ # @param [Symbol] accessor_name what is the name of the accessor that you are adding
12
+ def attach_config_to_parent(klass_child, klass_parent, accessor_name)
13
+ # Create a memoized getter to an instance of the attaching class (:klass_child)
14
+ #
15
+ # def third_party
16
+ # @third_party ||= KBuilder::ThirdPartyGem::Configuration.new
17
+ # end
18
+ klass_parent.send(:define_method, accessor_name) do
19
+ return instance_variable_get("@#{accessor_name}") if instance_variable_defined?("@#{accessor_name}")
20
+
21
+ instance_variable_set("@#{accessor_name}", klass_child.new)
22
+ end
23
+ end
24
+ alias attach_to attach_config_to_parent
25
+ end
26
+
27
+ # move out into module
28
+ def to_h
29
+ hash = {}
30
+ instance_variables.each do |var|
31
+ value = instance_variable_get(var)
32
+
33
+ value = KUtil.data.to_hash(value) if complex_type?(value)
34
+
35
+ hash[var.to_s.delete('@')] = value
36
+ end
37
+ hash
38
+ end
39
+
40
+ # Any basic (aka primitive) type
41
+ def basic_type?(value)
42
+ value.is_a?(String) ||
43
+ value.is_a?(Symbol) ||
44
+ value.is_a?(FalseClass) ||
45
+ value.is_a?(TrueClass) ||
46
+ value.is_a?(Integer) ||
47
+ value.is_a?(Float)
48
+ end
49
+
50
+ # Anything container that is not a regular class
51
+ def complex_type?(value)
52
+ value.is_a?(Array) ||
53
+ value.is_a?(Hash) ||
54
+ value.is_a?(Struct) ||
55
+ value.is_a?(OpenStruct) ||
56
+ value.respond_to?(:to_h)
57
+ end
58
+
59
+ def kv(name, value)
60
+ puts "#{name.rjust(30)} : #{value}"
61
+ end
62
+ end
63
+ end
@@ -1,66 +1,72 @@
1
- # frozen_string_literal: true
2
-
3
- # Attach configuration to the KBuilder module
4
- module KBuilder
5
- # Configuration for webpack5/builder
6
- class << self
7
- attr_writer :configuration
8
- end
9
-
10
- def self.configuration
11
- @configuration ||= Configuration.new
12
- end
13
-
14
- def self.reset
15
- @configuration = Configuration.new
16
- end
17
-
18
- def self.configure
19
- yield(configuration)
20
- end
21
-
22
- # Configuration class
23
- class Configuration < BaseConfiguration
24
- include KLog::Logging
25
-
26
- attr_accessor :target_folders
27
- attr_accessor :template_folders
28
-
29
- def initialize
30
- super
31
- # @target_folder = Dir.getwd
32
- # @template_folder = File.join(Dir.getwd, '.templates')
33
- # @global_template_folder = nil
34
- @target_folders = KType::NamedFolders.new
35
- @template_folders = KType::LayeredFolders.new
36
- end
37
-
38
- def initialize_copy(orig)
39
- super(orig)
40
-
41
- @target_folders = orig.target_folders.clone
42
- @template_folders = orig.template_folders.clone
43
- end
44
-
45
- # rubocop:disable Metrics/AbcSize
46
- def debug
47
- log.subheading 'kbuilder base configuration'
48
-
49
- log.section_heading 'target_folders'
50
- target_folders.folders.each_key do |key|
51
- folder = target_folders.folders[key]
52
- log.kv key.to_s, folder
53
- end
54
- log.info ''
55
-
56
- log.section_heading 'template folders (search order)'
57
-
58
- template_folders.ordered_keys.each do |key|
59
- folder = template_folders.folders[key]
60
- log.kv key.to_s, folder
61
- end
62
- ''
63
- end
64
- # rubocop:enable Metrics/AbcSize
65
- end
66
- end
1
+ # frozen_string_literal: true
2
+
3
+ # Attach configuration to the KBuilder module
4
+ module KBuilder
5
+ # Configuration for webpack5/builder
6
+ class << self
7
+ attr_writer :configuration
8
+ end
9
+
10
+ def self.configuration
11
+ @configuration ||= Configuration.new
12
+ end
13
+
14
+ def self.reset
15
+ @configuration = Configuration.new
16
+ end
17
+
18
+ def self.configure
19
+ yield(configuration)
20
+ end
21
+
22
+ # Does this class need to move out into k_types?
23
+ # It is being used with k_manager in a similar fashion
24
+ #
25
+ # Configuration class
26
+ class Configuration < BaseConfiguration
27
+ include KLog::Logging
28
+
29
+ # Target folders provide a set named folders that can be written to
30
+ attr_accessor :target_folders
31
+
32
+ # Template folders provides layered folders that templates can exist within
33
+ attr_accessor :template_folders
34
+
35
+ def initialize
36
+ super
37
+ # @target_folder = Dir.getwd
38
+ # @template_folder = File.join(Dir.getwd, '.templates')
39
+ # @global_template_folder = nil
40
+ @target_folders = KType::NamedFolders.new
41
+ @template_folders = KType::LayeredFolders.new
42
+ end
43
+
44
+ def initialize_copy(orig)
45
+ super(orig)
46
+
47
+ @target_folders = orig.target_folders.clone
48
+ @template_folders = orig.template_folders.clone
49
+ end
50
+
51
+ # rubocop:disable Metrics/AbcSize
52
+ def debug
53
+ log.subheading 'kbuilder base configuration'
54
+
55
+ log.section_heading 'target_folders'
56
+ target_folders.folders.each_key do |key|
57
+ folder = target_folders.folders[key]
58
+ log.kv key.to_s, folder
59
+ end
60
+ log.info ''
61
+
62
+ log.section_heading 'template folders (search order)'
63
+
64
+ template_folders.ordered_keys.each do |key|
65
+ folder = template_folders.folders[key]
66
+ log.kv key.to_s, folder
67
+ end
68
+ ''
69
+ end
70
+ # rubocop:enable Metrics/AbcSize
71
+ end
72
+ end
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module KBuilder
4
- VERSION = '0.0.55'
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KBuilder
4
+ VERSION = '0.0.56'
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.55
4
+ version: 0.0.56
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-05 00:00:00.000000000 Z
11
+ date: 2021-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: handlebars-helpers