k_builder 0.0.55 → 0.0.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/k_builder/base_configuration.rb +63 -55
- data/lib/k_builder/configuration.rb +72 -66
- 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: 758519925163c21cae5ef6bd99798577d7481f6bff55d6ce51599ee15bdd1baa
|
4
|
+
data.tar.gz: 89fbffd295334411d71ea48279838e13029ed01e3fa9c5b76be2aea7f1d44c8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
hash
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
value.is_a?(
|
46
|
-
value.is_a?(
|
47
|
-
value.is_a?(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
''
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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.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.
|
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-
|
11
|
+
date: 2021-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: handlebars-helpers
|