k_builder 0.0.71 → 0.0.73
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/a.txt +0 -0
- data/hooks/update-version +1 -1
- data/k_builder.gemspec +2 -2
- data/lib/k_builder/base_builder.rb +8 -7
- data/lib/k_builder/configuration_extension.rb +44 -0
- data/lib/k_builder/version.rb +1 -1
- data/lib/k_builder.rb +3 -3
- metadata +19 -4
- data/lib/k_builder/base_configuration.rb +0 -64
- data/lib/k_builder/configuration.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71d70294c1dc49e1fc67dd77f71414019a3814f44057831273bc79d815146f05
|
4
|
+
data.tar.gz: 5d18531c4d7f4ddb2c1cafb8297bf7d2e0c3f708526464d2d700ea7750eb048f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f5059460b2ab02d3708de1019a7ca2a9b4974c13e7f6da9b0c1d0aa720cdbdaabd29e3d9cb1451ce3b3db11211bd3fc9fd76edf4d284f12e48d0287ee328289
|
7
|
+
data.tar.gz: b02df37b1b11213b71e364d2c881de6df3e09ce355ada72807d30d6a37cca4a3fa263c8539e05cd582a64e3456c10b0ef74fed0a64de711c20bcf4c217fe546d
|
data/a.txt
ADDED
File without changes
|
data/hooks/update-version
CHANGED
data/k_builder.gemspec
CHANGED
@@ -38,11 +38,11 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.require_paths = ['lib']
|
39
39
|
# spec.extensions = ['ext/k_builder/extconf.rb']
|
40
40
|
spec.add_dependency 'handlebars-helpers', '~> 0'
|
41
|
+
spec.add_dependency 'k_config', '~> 0'
|
41
42
|
spec.add_dependency 'k_log', '~> 0'
|
42
43
|
spec.add_dependency 'k_type', '~> 0'
|
43
44
|
spec.add_dependency 'k_util', '~> 0'
|
44
45
|
spec.add_dependency 'rubocop', '~> 1.8'
|
45
46
|
|
46
|
-
|
47
|
-
# spec.add_dependency "config" , ">= 3.0.0"
|
47
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
48
48
|
end
|
@@ -54,7 +54,7 @@ module KBuilder
|
|
54
54
|
|
55
55
|
# assigns a builder hash and defines builder methods
|
56
56
|
def initialize(configuration = nil)
|
57
|
-
configuration =
|
57
|
+
configuration = KConfig.configuration if configuration.nil?
|
58
58
|
|
59
59
|
@configuration = configuration
|
60
60
|
|
@@ -130,7 +130,7 @@ module KBuilder
|
|
130
130
|
}
|
131
131
|
end
|
132
132
|
|
133
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
133
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
134
134
|
def add_file(file, **opts)
|
135
135
|
# move to command
|
136
136
|
full_file = target_file(file, **opts) # opts.key?(:folder_key) || opts.key?(:folder) ? target_file(file, folder: opts[:folder], folder_key: opts[:folder_key]) : target_file(file)
|
@@ -157,7 +157,7 @@ module KBuilder
|
|
157
157
|
|
158
158
|
self
|
159
159
|
end
|
160
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
160
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
161
161
|
|
162
162
|
def play_actions(actions)
|
163
163
|
actions.reject { |action| action[:played] }.each do |action|
|
@@ -171,6 +171,7 @@ module KBuilder
|
|
171
171
|
end
|
172
172
|
|
173
173
|
# certain actions (e.g. set_current_folder) will run independently to play
|
174
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
174
175
|
def run_action(action)
|
175
176
|
case action[:action]
|
176
177
|
when :add_file
|
@@ -191,6 +192,7 @@ module KBuilder
|
|
191
192
|
log.error "Unknown action: #{action[:action]}"
|
192
193
|
end
|
193
194
|
end
|
195
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
194
196
|
|
195
197
|
alias touch add_file # it is expected that you would not supply any options, just a file name
|
196
198
|
|
@@ -541,7 +543,6 @@ module KBuilder
|
|
541
543
|
# FROM k_dsl
|
542
544
|
# system "/usr/local/bin/zsh #{output_file}" if execution_context == :system
|
543
545
|
# fork { exec("/usr/local/bin/zsh #{output_file}") } if execution_context == :fork
|
544
|
-
|
545
546
|
end
|
546
547
|
alias rc run_command
|
547
548
|
|
@@ -562,13 +563,13 @@ module KBuilder
|
|
562
563
|
|
563
564
|
Dir.chdir(tf) do
|
564
565
|
output, status = Open3.capture2(script) # , **opts)
|
565
|
-
|
566
|
+
|
566
567
|
unless status.success?
|
567
|
-
log.error(
|
568
|
+
log.error('Script failed')
|
568
569
|
puts script
|
569
570
|
return nil
|
570
571
|
end
|
571
|
-
|
572
|
+
|
572
573
|
return output
|
573
574
|
end
|
574
575
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Attach configuration to the KBuilder module
|
4
|
+
module KBuilder
|
5
|
+
module ConfigurationExtension
|
6
|
+
# Target folders provide a set of named folders that can be written to
|
7
|
+
def target_folders=(value)
|
8
|
+
@target_folders = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def target_folders
|
12
|
+
@target_folders ||= KType::NamedFolders.new
|
13
|
+
end
|
14
|
+
|
15
|
+
# Template folders provides layered folders that templates can exist within
|
16
|
+
def template_folders=(value)
|
17
|
+
@template_folders = value
|
18
|
+
end
|
19
|
+
|
20
|
+
def template_folders
|
21
|
+
@template_folders ||= KType::LayeredFolders.new
|
22
|
+
end
|
23
|
+
|
24
|
+
# Custom debug method for k_builder
|
25
|
+
#
|
26
|
+
# usage:
|
27
|
+
# config.debug(:k_builder_debug)
|
28
|
+
def k_builder_debug
|
29
|
+
target_folders.debug(title: 'target_folders')
|
30
|
+
|
31
|
+
template_folders.debug(title: 'template folders (search order)')
|
32
|
+
''
|
33
|
+
end
|
34
|
+
|
35
|
+
# Custom initialize_copy method for k_builder. This is called during clone
|
36
|
+
def k_builder_initialize_copy(orig)
|
37
|
+
@target_folders = orig.target_folders.clone
|
38
|
+
@template_folders = orig.template_folders.clone
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
puts 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
44
|
+
KConfig::Configuration.register(:k_builder, KBuilder::ConfigurationExtension)
|
data/lib/k_builder/version.rb
CHANGED
data/lib/k_builder.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rubocop'
|
4
|
-
require
|
4
|
+
require 'open3'
|
5
5
|
|
6
|
+
require 'k_config'
|
6
7
|
require 'k_log'
|
7
8
|
require 'k_util'
|
8
9
|
require 'k_type'
|
9
10
|
require 'k_builder/version'
|
10
11
|
require 'k_builder/base_builder'
|
11
|
-
require 'k_builder/
|
12
|
-
require 'k_builder/configuration'
|
12
|
+
require 'k_builder/configuration_extension'
|
13
13
|
require 'k_builder/file_segments'
|
14
14
|
|
15
15
|
# should commands be in their own gem?
|
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.73
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: handlebars-helpers
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: k_config
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: k_log
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +117,7 @@ files:
|
|
103
117
|
- Sample.drawio
|
104
118
|
- Sample.xml
|
105
119
|
- USAGE.md
|
120
|
+
- a.txt
|
106
121
|
- bin/console
|
107
122
|
- bin/k
|
108
123
|
- bin/kgitsync
|
@@ -113,11 +128,10 @@ files:
|
|
113
128
|
- k_builder.gemspec
|
114
129
|
- lib/k_builder.rb
|
115
130
|
- lib/k_builder/base_builder.rb
|
116
|
-
- lib/k_builder/base_configuration.rb
|
117
131
|
- lib/k_builder/commands/base_command.rb
|
118
132
|
- lib/k_builder/commands/code_syntax_highlighter_command.rb
|
119
133
|
- lib/k_builder/commands/rubo_cop_command.rb
|
120
|
-
- lib/k_builder/
|
134
|
+
- lib/k_builder/configuration_extension.rb
|
121
135
|
- lib/k_builder/file_segments.rb
|
122
136
|
- lib/k_builder/version.rb
|
123
137
|
- usage/_out1.png
|
@@ -134,6 +148,7 @@ metadata:
|
|
134
148
|
homepage_uri: http://appydave.com
|
135
149
|
source_code_uri: https://github.com/klueless-io/k_builder
|
136
150
|
changelog_uri: https://github.com/klueless-io/k_builder/commits/master
|
151
|
+
rubygems_mfa_required: 'true'
|
137
152
|
post_install_message:
|
138
153
|
rdoc_options: []
|
139
154
|
require_paths:
|
@@ -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
|