k_builder 0.0.51 → 0.0.53

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 528f2587aacba6aa1d13d32737aa081b3ebb5364d3bc7e4628a2935a3746ff15
4
- data.tar.gz: bb780d8e64e7c814e0b51c8561537a2cbdc31a1ab81f5ee4c78e8d3bb3fa1e89
3
+ metadata.gz: 122c7daee609c40dbd918d5bb98640c3850d3cb0c54eeabee10e4d4082c036f3
4
+ data.tar.gz: 3c2041cd23f31b624860a141858f0c54ac995cf49b277bd591acb94a37cb1456
5
5
  SHA512:
6
- metadata.gz: 2d1dfa3e5875b691576390c970d8005036244566277fee71bbaebe5fc8e63e43588b87780c7616d8e5e07df838dcc3f2ccbf2d4edad8689d2308b8ce41e780e0
7
- data.tar.gz: 2eda2bb2b6caa396b0a7ffa0052d22e1bd98fc2931fbb3eb1352ff0b2e0c4fe86880c70e947f456d862d7279bf862f948ffb1c8eea9f9581b29257eb75ded468
6
+ metadata.gz: ae5aa592ffe9845c5438a80761a2ee8dccf358d4d32cfa6f84926038d64433c9e041911ba464c29811617b871a3c174baadb23d2dadb57bf76bcd9de44487ff9
7
+ data.tar.gz: c009caabf877b46d424e529bce376477835153338eef1b6bd2fd833fdbfb3b7cca157238823efd86aa44513c0ba5bd7e7fab5571a9799666ba9ab81624e4cb7f
data/.rubocop.yml CHANGED
@@ -73,6 +73,9 @@ Layout/EmptyLineBetweenDefs:
73
73
  Exclude:
74
74
  - "**/spec/**/*"
75
75
 
76
+ Style/Documentation:
77
+ Enabled: false
78
+
76
79
  Lint/AmbiguousBlockAssociation:
77
80
  Exclude:
78
81
  - "**/spec/**/*"
data/Rakefile CHANGED
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ GEM_NAME = 'k_builder'
4
+
3
5
  require 'bundler/gem_tasks'
4
6
  require 'rspec/core/rake_task'
7
+ require 'k_builder/version'
5
8
 
6
9
  RSpec::Core::RakeTask.new(:spec)
7
10
 
@@ -14,4 +17,15 @@ Rake::ExtensionTask.new('k_builder') do |ext|
14
17
  ext.lib_dir = 'lib/k_builder'
15
18
  end
16
19
 
20
+ desc 'Publish the gem to RubyGems.org'
21
+ task :publish do
22
+ system 'gem build'
23
+ system "gem push #{GEM_NAME}-#{KBuilder::VERSION}.gem"
24
+ end
25
+
26
+ desc 'Remove old *.gem files'
27
+ task :clean do
28
+ system 'rm *.gem'
29
+ end
30
+
17
31
  task default: %i[clobber compile spec]
data/k_builder.gemspec CHANGED
@@ -39,6 +39,8 @@ Gem::Specification.new do |spec|
39
39
  # spec.extensions = ['ext/k_builder/extconf.rb']
40
40
 
41
41
  spec.add_dependency 'handlebars-helpers', '~> 0'
42
+ spec.add_dependency 'k_log', '~> 0'
43
+ spec.add_dependency 'k_util', '~> 0'
42
44
  # spec.add_dependency "anyway_config" , ">= 2.0.0"
43
45
  # spec.add_dependency "config" , ">= 3.0.0"
44
46
  end
data/lib/k_builder.rb CHANGED
@@ -4,10 +4,11 @@ require 'k_builder/version'
4
4
  require 'k_builder/base_builder'
5
5
  require 'k_builder/base_configuration'
6
6
  require 'k_builder/configuration'
7
- require 'k_builder/data_helper'
8
7
  require 'k_builder/file_segments'
9
8
  require 'k_builder/named_folders'
10
9
  require 'k_builder/layered_folders'
10
+ require 'k_log'
11
+ require 'k_util'
11
12
 
12
13
  require 'handlebars/helpers/template'
13
14
 
@@ -15,5 +16,15 @@ module KBuilder
15
16
  # raise KBuilder::Error, 'Sample message'
16
17
  class Error < StandardError; end
17
18
 
18
- # Your code goes here...
19
+ # Need to move this into a KLog factory
20
+ def self.configure_logger
21
+ logger = Logger.new($stdout)
22
+ logger.level = Logger::DEBUG
23
+ logger.formatter = KLog::LogFormatter.new
24
+ KLog::LogUtil.new(logger)
25
+ end
19
26
  end
27
+
28
+ L = KBuilder.configure_logger
29
+
30
+ puts "KBuilder::Version: #{KBuilder::VERSION}" if ENV['KLUE_DEBUG']&.to_s&.downcase == 'true'
@@ -22,7 +22,7 @@ module KBuilder
22
22
  instance_variables.each do |var|
23
23
  value = instance_variable_get(var)
24
24
 
25
- value = KBuilder.data.struct_to_hash(value) if complex_type?(value)
25
+ value = KUtil.data.to_hash(value) if complex_type?(value)
26
26
 
27
27
  hash[var.to_s.delete('@')] = value
28
28
  end
@@ -42,19 +42,22 @@ module KBuilder
42
42
 
43
43
  # rubocop:disable Metrics/AbcSize
44
44
  def debug
45
- puts '-' * 120
46
- puts 'kbuilder base configuration'
45
+ L.subheading 'kbuilder base configuration'
47
46
 
48
- puts 'target_folders'
47
+ L.section_heading 'target_folders'
49
48
  target_folders.folders.each_key do |key|
50
49
  folder = target_folders.folders[key]
51
- kv key.to_s, folder
50
+ L.kv key.to_s, folder
52
51
  end
52
+ L.info ''
53
53
 
54
- puts 'template folders (search order)'
55
- template_folders.ordered_folders.each do |folder|
56
- puts folder.to_s
54
+ L.section_heading 'template folders (search order)'
55
+
56
+ template_folders.ordered_keys.each do |key|
57
+ folder = template_folders.folders[key]
58
+ L.kv key.to_s, folder
57
59
  end
60
+ ''
58
61
  end
59
62
  # rubocop:enable Metrics/AbcSize
60
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KBuilder
4
- VERSION = '0.0.51'
4
+ VERSION = '0.0.53'
5
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.51
4
+ version: 0.0.53
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-03-30 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: handlebars-helpers
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: k_log
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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: k_util
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: " K Builder provides various fluent builders for initializing applications
28
56
  with different language requirements\n"
29
57
  email:
@@ -56,7 +84,6 @@ files:
56
84
  - lib/k_builder/base_builder.rb
57
85
  - lib/k_builder/base_configuration.rb
58
86
  - lib/k_builder/configuration.rb
59
- - lib/k_builder/data_helper.rb
60
87
  - lib/k_builder/file_segments.rb
61
88
  - lib/k_builder/layered_folders.rb
62
89
  - lib/k_builder/named_folders.rb
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Attach data helper to the KBuilder module
4
- module KBuilder
5
- # Data helpers/utils for Kbuilder
6
- class << self
7
- attr_writer :data
8
- end
9
-
10
- def self.data
11
- @data ||= DataHelper.new
12
- end
13
-
14
- # Helper methods attached to the namespace for working with Data
15
- #
16
- # Usage: KBuilder.data.to_struct(data)
17
- class DataHelper
18
- # Convert a hash into a deep OpenStruct or array an array
19
- # of objects into an array of OpenStruct
20
- def to_struct(data)
21
- case data
22
- when Hash
23
- OpenStruct.new(data.transform_values { |v| to_struct(v) })
24
-
25
- when Array
26
- data.map { |o| to_struct(o) }
27
-
28
- else
29
- # Some primitave type: String, True/False, Symbol or an ObjectStruct
30
- data
31
- end
32
- end
33
-
34
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
35
- def struct_to_hash(data)
36
- # No test yet
37
- if data.is_a?(Array)
38
- return data.map { |v| v.is_a?(OpenStruct) ? struct_to_hash(v) : v }
39
- end
40
-
41
- return struct_to_hash(data.to_h) if !data.is_a?(Hash) && data.respond_to?(:to_h)
42
-
43
- data.each_pair.with_object({}) do |(key, value), hash|
44
- case value
45
- when OpenStruct, Struct, Hash
46
- hash[key] = struct_to_hash(value)
47
- when Array
48
- # No test yet
49
- values = value.map do |v|
50
- v.is_a?(OpenStruct) || v.is_a?(Struct) || v.is_a?(Hash) ? struct_to_hash(v) : v
51
- end
52
- hash[key] = values
53
- else
54
- hash[key] = value
55
- end
56
- end
57
- end
58
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
59
-
60
- def clean_symbol(value)
61
- return value if value.nil?
62
-
63
- value.is_a?(Symbol) ? value.to_s : value
64
- end
65
- end
66
- end