k_builder 0.0.56 → 0.0.57
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 +4 -4
- data/lib/k_builder.rb +1 -1
- data/lib/k_builder/base_configuration.rb +64 -63
- data/lib/k_builder/configuration.rb +72 -72
- data/lib/k_builder/version.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85fabea0178e317cd8bd8658d91b8813a143e48a8af8710465f5531cfba00535
|
4
|
+
data.tar.gz: b86a69632dac4f08256af550addfea622cd78d26dec7b92e5801f087bd917da7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e23dfcad31466228dca0ada1a183ff422878a0d5893358f3561fb545748c5a91f1b1e6ed123f5bae2d1117b72c4605cfc08e68c7c2993fb86df0387a2abe7325
|
7
|
+
data.tar.gz: 8c563d0d7aebb402540852839b55e14c639c1a451e837345b3913f72f6674a3db894089a966d107cc80b3d65ea1c3f720d3716e278bfeac4397c3231dca5c141
|
data/lib/k_builder.rb
CHANGED
@@ -20,5 +20,5 @@ if ENV['KLUE_DEBUG']&.to_s&.downcase == 'true'
|
|
20
20
|
namespace = 'KBuilder::Version'
|
21
21
|
file_path = $LOADED_FEATURES.find { |f| f.include?('k_builder/version') }
|
22
22
|
version = KBuilder::VERSION.ljust(9)
|
23
|
-
puts "#{namespace.ljust(
|
23
|
+
puts "#{namespace.ljust(35)} : #{version.ljust(9)} : #{file_path}"
|
24
24
|
end
|
@@ -1,63 +1,64 @@
|
|
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
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
value.is_a?(
|
45
|
-
value.is_a?(
|
46
|
-
value.is_a?(
|
47
|
-
value.is_a?(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
value.is_a?(
|
55
|
-
value.is_a?(
|
56
|
-
value.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
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
|
+
# This code is being moved into k_util (data)
|
41
|
+
# Any basic (aka primitive) type
|
42
|
+
def basic_type?(value)
|
43
|
+
value.is_a?(String) ||
|
44
|
+
value.is_a?(Symbol) ||
|
45
|
+
value.is_a?(FalseClass) ||
|
46
|
+
value.is_a?(TrueClass) ||
|
47
|
+
value.is_a?(Integer) ||
|
48
|
+
value.is_a?(Float)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Anything container that is not a regular class
|
52
|
+
def complex_type?(value)
|
53
|
+
value.is_a?(Array) ||
|
54
|
+
value.is_a?(Hash) ||
|
55
|
+
value.is_a?(Struct) ||
|
56
|
+
value.is_a?(OpenStruct) ||
|
57
|
+
value.respond_to?(:to_h)
|
58
|
+
end
|
59
|
+
|
60
|
+
def kv(name, value)
|
61
|
+
puts "#{name.rjust(30)} : #{value}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,72 +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
|
-
# 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
|
+
# 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
|
data/lib/k_builder/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KBuilder
|
4
|
-
VERSION = '0.0.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KBuilder
|
4
|
+
VERSION = '0.0.57'
|
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.
|
4
|
+
version: 0.0.57
|
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-
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: handlebars-helpers
|