bauk-core 0.0.4 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeceb73136dd40e3e06fcad0b81192f0f065a9a011763c8e39041dbdfdc75d79
4
- data.tar.gz: 67cfd93342ff4036e595d91b6e63cff6d8c08c79efa72393b076fd3d6f0fd010
3
+ metadata.gz: f9309ceca9c857c2f60512848824377d811b1495b8102fb8c641ea36d296f001
4
+ data.tar.gz: 2ddbc0cb688f587216a91138b0ee1b0edfb8ce9cea160ca385ea0e89e952e2f6
5
5
  SHA512:
6
- metadata.gz: 4dec1c952f04b798ef518f26589fe2c4b0c2323a2c46521130d8e82b637f6aa6d01bdb56946d671e6ac146a3b07d15e5cedf6c3c480d0f0d224fcd0af0b98b54
7
- data.tar.gz: 4b9f42cd66148aba5bca02650dd30fe2d300802588b450d9f6b290767be6a8405b032dd0837378044e2434d626f2efa78e3ab847ed5f7efe5c293cec7be06e52
6
+ metadata.gz: cf8fac1f2f4c1b6146f7e3d4a20287d3d80ffb1a8b2db91f65c6ec9dab9366409d3b8e6458d7807561c9a51318ab07ff272f7dece96c138dbd686845b8ebc180
7
+ data.tar.gz: a9828e67695d0fa053abcb7e737cb1ad18cd355f4971265769c6f7b338969430acfe4abeb6e17827ed0f9f4ccfbc2080a93b169b392ed921f7a51790fa0ea2ca
data/.gitignore CHANGED
@@ -10,6 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
 
13
- /Gemfile.lock
14
-
15
- /rubocop/
13
+ /.bauk/
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bauk-core (0.0.6)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ diff-lcs (1.3)
11
+ jaro_winkler (1.5.3)
12
+ parallel (1.17.0)
13
+ parser (2.6.3.0)
14
+ ast (~> 2.4.0)
15
+ rainbow (3.0.0)
16
+ rake (10.5.0)
17
+ rspec (3.8.0)
18
+ rspec-core (~> 3.8.0)
19
+ rspec-expectations (~> 3.8.0)
20
+ rspec-mocks (~> 3.8.0)
21
+ rspec-core (3.8.2)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-expectations (3.8.4)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.8.0)
26
+ rspec-mocks (3.8.1)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-support (3.8.2)
30
+ rubocop (0.74.0)
31
+ jaro_winkler (~> 1.5.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 2.6)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ ruby-progressbar (~> 1.7)
36
+ unicode-display_width (>= 1.4.0, < 1.7)
37
+ ruby-progressbar (1.10.1)
38
+ unicode-display_width (1.6.0)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bauk-core!
45
+ bundler (~> 2.0)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rubocop (~> 0.74)
49
+
50
+ BUNDLED WITH
51
+ 2.1.4
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Array
2
4
  def join_custom(map = {})
3
5
  map[:delim] ||= ', '
4
6
  map[:end_delim] ||= ' and '
5
7
  case length
6
8
  when 0
7
- ""
9
+ ''
8
10
  when 1
9
11
  self[0].to_s.dup
10
12
  else
@@ -19,7 +19,6 @@ module Bauk
19
19
  class BaseParser
20
20
  require 'optparse'
21
21
  require 'bauk/utils/log'
22
- require 'bauk/utils/hash_utils'
23
22
  include Log
24
23
  # Accepts a hash of actions. E.g:
25
24
  # BaseParser.new({
@@ -27,7 +26,7 @@ module Bauk
27
26
  # # opts.on ...
28
27
  # end,
29
28
  # sub_action_a: {
30
- # aliases: %w[a action_a],
29
+ # aliases: %i[a action_a],
31
30
  # info: 'Please choose me!',
32
31
  # opts: lambda do |opts|
33
32
  # # Only accesible if 'sub_action_a' chosen
@@ -112,7 +111,7 @@ module Bauk
112
111
  # Lists available child actions based on the current @action_chain
113
112
  def available_actions
114
113
  # Put *'s if this has an action
115
- ret = "#{program_name} - Available actions (--help for more info):\n"
114
+ ret = "#{program_name} - Available actions (--help for more info):\n".dup
116
115
  max = 0
117
116
  ca = current_action only_child_actions: true
118
117
  ca.each_key { |key| max = key.length if key.length > max }
@@ -15,16 +15,27 @@ module Bauk
15
15
  def self.create(name)
16
16
  log = loggers[name][:instance]
17
17
  if log.nil?
18
- log = Log4r::Logger.new(name)
18
+ log = Log4r::Logger.new(logger_name name)
19
19
  log.level = Log.loggers[name][:level]
20
20
  Log.loggers[name][:outputters].each { |o| log.add o }
21
- log.debug("Initialized loger #{name} to: #{log.level}")
21
+ log.debug("Initialized loger #{name} to log level: #{log.level}")
22
22
  loggers[name] = loggers[name].clone # Take default values
23
23
  loggers[name][:instance] = log
24
24
  end
25
25
  log
26
26
  end
27
27
 
28
+ # Function to turn a name into a more valid logger name
29
+ # e.g. The::Best::Class -> TB.class
30
+ def self.logger_name(name)
31
+ logger_parts = name.split '::'
32
+ logger_name = logger_parts.pop
33
+ unless logger_parts.empty?
34
+ logger_name = [logger_parts.map {|p| p[0]}.join(''), logger_name].join('.')
35
+ end
36
+ logger_name
37
+ end
38
+
28
39
  # Increases logging from all loggers, unless a name is specified
29
40
  # (See set_log_level for runes on name provided).
30
41
  # Due to the inverse of log4r, more logging means a lower log level
@@ -93,7 +104,11 @@ module Bauk
93
104
 
94
105
  # Used to access log4r inside a class which includes this class
95
106
  def log
96
- @log = Log.create(self.class.name || 'anonymous') if @log.nil?
107
+ if @log.nil?
108
+ logger_name = self.class.name
109
+ logger_name = "#{self.name}@" if self.respond_to? "name"
110
+ @log = Log.create(logger_name || 'anonymous') if @log.nil?
111
+ end
97
112
  @log
98
113
  end
99
114
 
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Object
4
+ def symbolize
5
+ self
6
+ end
7
+ end
8
+ class Hash
9
+ def symbolize
10
+ reduce({}) do |memo, (k, v)|
11
+ memo.tap do |m|
12
+ m[k.to_sym] = v.respond_to?(:symbolize) ? v.symbolize() : v
13
+ end
14
+ end
15
+ end
16
+ end
17
+ class Array
18
+ def symbolize
19
+ each_with_object([]) do |v, memo|
20
+ memo.push v.respond_to?(:symbolize) ? v.symbolize() : v
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bauk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Jasko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - ".travis.yml"
80
80
  - CODE_OF_CONDUCT.md
81
81
  - Gemfile
82
+ - Gemfile.lock
82
83
  - LICENSE.txt
83
84
  - README.md
84
85
  - Rakefile
@@ -90,6 +91,7 @@ files:
90
91
  - lib/bauk/utils/array_utils.rb
91
92
  - lib/bauk/utils/base_parser.rb
92
93
  - lib/bauk/utils/log.rb
94
+ - lib/bauk/utils/symbolize.rb
93
95
  - lib/bauk/utils/user_input.rb
94
96
  homepage: https://gitlab.com/BAUK/bauk-core
95
97
  licenses: