bbk-utils 1.1.4.347221 → 1.1.5.353300

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: e601361c651d61761ffbe5cd14b0162a1478d8719040fe23e69f372a6e6e2f22
4
- data.tar.gz: 6a2e93d96f97fd5686d6e1a66e57dc86ae918d92a0914154cd2f4f85ca725af3
3
+ metadata.gz: d3f70f9fbf1ff06e4c07e1e250b5cea23ceabc4145b84e7f4a5f78a41d57ccb6
4
+ data.tar.gz: f2617d5dc122177c441a81a55d9737d7138776c3e28768f56527338c6d42d918
5
5
  SHA512:
6
- metadata.gz: d0cb09b8b53016c4462a441bc640fdee4d9ff8bb0bf35c4d2c71c647b88643157788536f1689031beb42ec2b2dfdd4ef620aa3ac1489737820a6c4a83cf4f423
7
- data.tar.gz: 17281a82684e76a490f8dd8140684648c4317dc9fbee6dfc9eaa3d9f75b019f828c48604de28b1399c8904f7aa8cb2be00ac2aea43cbd37f6014c3c8102c6b55
6
+ metadata.gz: d229edde9688ebdadc548c92a891e5c65075d0cd87ec3b6f050d0b2f4e96d82df660eccfbb57719402f022f4170b3a549e8390018cb6dbbe9e65b1010669b800
7
+ data.tar.gz: f28655757bb8dd10c73e32388d573540c1f910fe895ff4c45a6bab78c74caec3d9e5d896f30bdefe8563b7fc6001b3190d25b3db1a2fad191a542e0a04ad83b2
data/Gemfile.lock CHANGED
@@ -1,10 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bbk-utils (1.1.4.347221)
4
+ bbk-utils (1.1.5)
5
5
  activesupport (>= 7.0)
6
6
  russian
7
- securerandom (~> 0.3.2)
8
7
 
9
8
  GEM
10
9
  remote: https://rubygems.org/
@@ -32,12 +31,12 @@ GEM
32
31
  thread_safe (~> 0.3, >= 0.3.1)
33
32
  base64 (0.3.0)
34
33
  benchmark (0.5.0)
35
- bigdecimal (3.3.1)
34
+ bigdecimal (4.0.1)
36
35
  byebug (11.1.3)
37
36
  coercible (1.0.0)
38
37
  descendants_tracker (~> 0.0.1)
39
38
  concurrent-ruby (1.2.2)
40
- connection_pool (2.5.5)
39
+ connection_pool (2.5.0)
41
40
  descendants_tracker (0.0.4)
42
41
  thread_safe (~> 0.3, >= 0.3.1)
43
42
  diff-lcs (1.6.0)
@@ -63,13 +62,16 @@ GEM
63
62
  launchy (2.5.0)
64
63
  addressable (~> 2.7)
65
64
  logger (1.7.0)
66
- minitest (5.26.1)
65
+ minitest (6.0.1)
66
+ prism (~> 1.5)
67
67
  mutex_m (0.3.0)
68
68
  parallel (1.21.0)
69
69
  parser (3.0.3.1)
70
70
  ast (~> 2.4.1)
71
71
  path_expander (1.1.0)
72
+ prism (1.9.0)
72
73
  public_suffix (4.0.6)
74
+ racc (1.8.1)
73
75
  rainbow (3.0.0)
74
76
  rake (12.3.3)
75
77
  reek (6.0.6)
@@ -122,7 +124,7 @@ GEM
122
124
  virtus (~> 1.0)
123
125
  russian (0.6.0)
124
126
  i18n (>= 0.5.0)
125
- securerandom (0.3.2)
127
+ securerandom (0.4.1)
126
128
  sexp_processor (4.16.0)
127
129
  simplecov (0.21.2)
128
130
  docile (~> 1.1)
@@ -159,6 +161,7 @@ DEPENDENCIES
159
161
  bundler (~> 2.0)
160
162
  byebug
161
163
  faker (~> 2.4)
164
+ racc
162
165
  rake (~> 12.0)
163
166
  rspec (~> 3.0)
164
167
  rspec_junit_formatter
@@ -168,6 +171,7 @@ DEPENDENCIES
168
171
  simplecov
169
172
  simplecov-cobertura
170
173
  simplecov-console
174
+ terminal-table
171
175
 
172
176
  BUNDLED WITH
173
177
  2.2.33
@@ -0,0 +1,163 @@
1
+ require 'yaml'
2
+ require 'optparse'
3
+
4
+
5
+ module BBK
6
+ module Utils
7
+ module Cli
8
+ class EnvDocs
9
+
10
+ def self.run(*args) new.run(*args) end
11
+
12
+ def run(*args)
13
+ options = {
14
+ config: './.env_docs.yml',
15
+ output: './env_docs.md'
16
+ }
17
+
18
+ OptionParser.new do |opts|
19
+ opts.banner = "Usage: env_docs [options]"
20
+
21
+ opts.on("-c", "--config CONFIG", "Path to config file (default: #{options[:config]})") do |c|
22
+ options[:config] = c
23
+ end
24
+
25
+ opts.on("-o", "--output OUTPUT", "Path to output file (default: #{options[:output]})") do |o|
26
+ options[:output] = o
27
+ end
28
+
29
+ opts.on("-h", "--help", "Prints this help") do
30
+ puts opts
31
+ exit
32
+ end
33
+ end.parse!(args)
34
+
35
+ output_file = Rails.root.join(options[:output])
36
+ config_file = Rails.root.join(options[:config])
37
+
38
+ if File.exist?(config_file)
39
+ config = YAML.load_file(config_file) || {}
40
+ else
41
+ puts "Config file not found: #{config_file}. Continuing without config."
42
+ config = {}
43
+ end
44
+
45
+ cfg = BBK::Utils::Config.instance.as_json.deep_dup
46
+ cfg = cfg[BBK::Utils::Config.instance.name] unless BBK::Utils::Config.instance.name.nil?
47
+
48
+ BBK::Utils::Config.instance.send(:store_with_subconfigs).each do |k, v|
49
+ if v[:default]&.class&.to_s == "Fugit::Duration"
50
+ cfg[k][:default] = v[:default].original
51
+ end
52
+
53
+ if v[:default]
54
+ cfg[k][:class] = "#{v[:default].class}"
55
+ end
56
+ end
57
+
58
+ env_prefix_order = config.fetch('env_prefix_order', [])
59
+
60
+ matching, remaining = separate(cfg, env_prefix_order)
61
+
62
+ File.open(output_file, 'w') do |file|
63
+ file.puts "# Переменные окружения\n\n"
64
+ file.puts to_markdown(matching)
65
+ file.puts "\n\n"
66
+ file.puts to_markdown(remaining.sort)
67
+ end
68
+
69
+ puts "Documentation saved to: #{output_file}"
70
+ end
71
+
72
+ def separate(cfg, env_prefix_order)
73
+ matching = {}
74
+ remaining = {}
75
+
76
+ cfg.each do |key, value|
77
+ matched = env_prefix_order.any? do |prefix|
78
+ key == prefix || key.start_with?(prefix + '_')
79
+ end
80
+
81
+ if matched
82
+ matching[key] = value
83
+ else
84
+ remaining[key] = value
85
+ end
86
+ end
87
+
88
+ [matching, remaining]
89
+ end
90
+
91
+ def to_markdown(cfg, columns = { :env => "Название", :desc => "Описание", :default => "По умолчанию", :class => "Тип"} )
92
+ rows = cfg_to_array(cfg, columns.keys)
93
+
94
+ create_markdown_table(rows, columns.values)
95
+ end
96
+
97
+
98
+ def cfg_to_array(cfg, keys)
99
+ cfg.each_with_object([]) do |entry, rows|
100
+ rows << keys.each_with_object([]) do |key, row|
101
+ row << entry[1][key]
102
+ end
103
+ end
104
+ end
105
+
106
+ def create_markdown_table(rows, headers = [])
107
+ return "| No data |" if rows.empty?
108
+
109
+ column_widths = if headers.size != 0
110
+ headers.map(&:size)
111
+ else
112
+ Array.new(rows[0].count, 0)
113
+ end
114
+
115
+ rows.each do |row|
116
+ row.each_with_index do |string, i|
117
+ column_widths[i] = string.to_s.size if string.present? && string.to_s.size > column_widths[i]
118
+ end
119
+ end
120
+
121
+ markdown_table = []
122
+
123
+ # Создаем заголовок таблицы, если он есть
124
+ if headers.size != 0
125
+ header_string = "|"
126
+ separator_string = "|"
127
+
128
+ headers.each_with_index do |header, col|
129
+ header_string += " #{header.ljust(column_widths[col])} |"
130
+ separator_string += "-#{'-' * column_widths[col]}-|"
131
+ end
132
+
133
+ markdown_table << header_string
134
+ markdown_table << separator_string
135
+ end
136
+
137
+ # Создаем строки данных
138
+ rows_string = []
139
+ rows.each do |row|
140
+ row_string = "|"
141
+ row.each_with_index do |data, col|
142
+ value = (data || '').to_s
143
+ row_string += " #{value.ljust(column_widths[col])} |"
144
+ end
145
+ rows_string << row_string
146
+ end
147
+ markdown_table += rows_string
148
+
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ # "BILLING_ENABLED"=>
156
+ # {:env=>"BILLING_ENABLED",
157
+ # :file=>nil,
158
+ # :required=>false,
159
+ # :default=>false,
160
+ # :desc=>"Send data to billing by api",
161
+ # :bool=>true,
162
+ # :type=>
163
+ # #<Method: BBK::Utils::Config::BooleanCaster.cast(value) /home/user/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bbk-utils-1.1.2.304819/lib/bbk/utils/config.rb:27
@@ -3,7 +3,7 @@
3
3
  module BBK
4
4
  module Utils
5
5
 
6
- VERSION = '1.1.4'
6
+ VERSION = '1.1.5'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbk-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4.347221
4
+ version: 1.1.5.353300
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-16 00:00:00.000000000 Z
11
+ date: 2026-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.0'
27
- - !ruby/object:Gem::Dependency
28
- name: securerandom
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 0.3.2
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.3.2
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: russian
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +94,20 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: terminal-table
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: byebug
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: racc
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rubycritic
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -233,6 +247,7 @@ files:
233
247
  - bin/console
234
248
  - bin/setup
235
249
  - lib/bbk/utils.rb
250
+ - lib/bbk/utils/cli/env_docs.rb
236
251
  - lib/bbk/utils/combined_logger.rb
237
252
  - lib/bbk/utils/config.rb
238
253
  - lib/bbk/utils/crypt.rb