k_builder 0.0.68 → 0.0.73
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/a.txt +0 -0
- data/hooks/pre-commit +2 -2
- data/hooks/update-version +1 -1
- data/k_builder.gemspec +2 -2
- data/lib/k_builder/base_builder.rb +93 -17
- data/lib/k_builder/configuration_extension.rb +44 -0
- data/lib/k_builder/version.rb +1 -1
- data/lib/k_builder.rb +3 -2
- metadata +19 -9
- data/lib/k_builder/assets/a.html +0 -235
- data/lib/k_builder/assets/b.html +0 -109
- data/lib/k_builder/assets/highlight.min.js +0 -1120
- data/lib/k_builder/assets/highlight_css +0 -1
- data/lib/k_builder/assets/ruby.min.js +0 -7
- data/lib/k_builder/base_configuration.rb +0 -64
- data/lib/k_builder/configuration.rb +0 -72
@@ -1 +0,0 @@
|
|
1
|
-
/Users/davidcruwys/dev/slides-addons/highlight_css
|
@@ -1,64 +0,0 @@
|
|
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 +0,0 @@
|
|
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
|
-
|
9
|
-
def configuration(name = :default)
|
10
|
-
@configuration ||= Hash.new do |h, key|
|
11
|
-
h[key] = KBuilder::Configuration.new
|
12
|
-
end
|
13
|
-
@configuration[name]
|
14
|
-
end
|
15
|
-
|
16
|
-
def reset(name = :default)
|
17
|
-
@configuration ||= Hash.new do |h, key|
|
18
|
-
h[key] = KBuilder::Configuration.new
|
19
|
-
end
|
20
|
-
@configuration[name] = KBuilder::Configuration.new
|
21
|
-
end
|
22
|
-
|
23
|
-
def configure(name = :default)
|
24
|
-
yield(configuration(name))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Does this class need to move out into k_types?
|
29
|
-
# It is being used with k_manager in a similar fashion
|
30
|
-
#
|
31
|
-
# Configuration class
|
32
|
-
class Configuration < BaseConfiguration
|
33
|
-
include KLog::Logging
|
34
|
-
|
35
|
-
# Target folders provide a set named folders that can be written to
|
36
|
-
attr_accessor :target_folders
|
37
|
-
|
38
|
-
# Template folders provides layered folders that templates can exist within
|
39
|
-
attr_accessor :template_folders
|
40
|
-
|
41
|
-
def initialize
|
42
|
-
super
|
43
|
-
# @target_folder = Dir.getwd
|
44
|
-
# @template_folder = File.join(Dir.getwd, '.templates')
|
45
|
-
# @global_template_folder = nil
|
46
|
-
@target_folders = KType::NamedFolders.new
|
47
|
-
@template_folders = KType::LayeredFolders.new
|
48
|
-
end
|
49
|
-
|
50
|
-
def initialize_copy(orig)
|
51
|
-
super(orig)
|
52
|
-
|
53
|
-
@target_folders = orig.target_folders.clone
|
54
|
-
@template_folders = orig.template_folders.clone
|
55
|
-
end
|
56
|
-
|
57
|
-
def debug(heading: 'kbuilder base configuration')
|
58
|
-
log.section_heading 'kbuilder base configuration' if heading
|
59
|
-
|
60
|
-
# TODO: Add name to configuration object
|
61
|
-
# Don't have support for name on the configuration object yet
|
62
|
-
# log.kv 'config name', name
|
63
|
-
|
64
|
-
target_folders.debug(title: 'target_folders')
|
65
|
-
|
66
|
-
# log.info ''
|
67
|
-
|
68
|
-
template_folders.debug(title: 'template folders (search order)')
|
69
|
-
''
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|