dev_suite 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -5
- data/.vscode/extensions.json +8 -0
- data/.vscode/launch.json +39 -0
- data/.vscode/settings.json +28 -0
- data/Gemfile +4 -1
- data/Gemfile.lock +28 -2
- data/README.md +39 -31
- data/bin/rspec +27 -0
- data/lib/dev_suite/directory_tree/builder/base.rb +1 -1
- data/lib/dev_suite/directory_tree/builder/builder.rb +13 -0
- data/lib/dev_suite/directory_tree/builder.rb +1 -12
- data/lib/dev_suite/directory_tree/config/config.rb +1 -1
- data/lib/dev_suite/directory_tree/config/configuration.rb +18 -5
- data/lib/dev_suite/directory_tree/directory_tree.rb +0 -2
- data/lib/dev_suite/directory_tree/node/node.rb +12 -0
- data/lib/dev_suite/directory_tree/node.rb +1 -4
- data/lib/dev_suite/directory_tree/renderer/base.rb +1 -1
- data/lib/dev_suite/directory_tree/renderer/renderer.rb +14 -0
- data/lib/dev_suite/directory_tree/renderer.rb +1 -13
- data/lib/dev_suite/directory_tree/visualizer/base.rb +1 -1
- data/lib/dev_suite/directory_tree/visualizer/visualizer.rb +16 -0
- data/lib/dev_suite/directory_tree/visualizer.rb +1 -15
- data/lib/dev_suite/performance/config/config.rb +1 -1
- data/lib/dev_suite/performance/config/configuration.rb +3 -3
- data/lib/dev_suite/performance/data/data.rb +9 -0
- data/lib/dev_suite/performance/data.rb +1 -1
- data/lib/dev_suite/performance/profiler/base.rb +1 -1
- data/lib/dev_suite/performance/profiler/profiler.rb +16 -0
- data/lib/dev_suite/performance/profiler.rb +1 -20
- data/lib/dev_suite/performance/profiler_manager.rb +1 -0
- data/lib/dev_suite/performance/reporter/base.rb +1 -1
- data/lib/dev_suite/performance/reporter/reporter.rb +15 -0
- data/lib/dev_suite/performance/reporter.rb +1 -14
- data/lib/dev_suite/request_logger/adapter/adapter.rb +16 -12
- data/lib/dev_suite/request_logger/adapter/base.rb +1 -1
- data/lib/dev_suite/request_logger/adapter/faraday.rb +37 -0
- data/lib/dev_suite/request_logger/adapter/middleware/faraday.rb +22 -0
- data/lib/dev_suite/request_logger/adapter/net_http.rb +1 -0
- data/lib/dev_suite/request_logger/adapter.rb +1 -1
- data/lib/dev_suite/request_logger/config/config.rb +1 -1
- data/lib/dev_suite/request_logger/config/configuration.rb +2 -2
- data/lib/dev_suite/request_logger/extractor/base.rb +17 -0
- data/lib/dev_suite/request_logger/extractor/extractor.rb +22 -0
- data/lib/dev_suite/request_logger/extractor/faraday.rb +37 -0
- data/lib/dev_suite/request_logger/extractor/net_http.rb +36 -0
- data/lib/dev_suite/request_logger/extractor.rb +9 -0
- data/lib/dev_suite/request_logger/logger.rb +22 -28
- data/lib/dev_suite/request_logger/request.rb +19 -0
- data/lib/dev_suite/request_logger/request_logger.rb +3 -0
- data/lib/dev_suite/request_logger/response.rb +28 -0
- data/lib/dev_suite/utils/color/config/config.rb +1 -1
- data/lib/dev_suite/utils/color/config/configuration.rb +3 -3
- data/lib/dev_suite/utils/color/palette/base.rb +1 -14
- data/lib/dev_suite/utils/color/palette/palette.rb +16 -0
- data/lib/dev_suite/utils/color/palette.rb +1 -13
- data/lib/dev_suite/utils/color/strategy/base.rb +1 -1
- data/lib/dev_suite/utils/color/strategy/strategy.rb +20 -0
- data/lib/dev_suite/utils/color/strategy.rb +1 -19
- data/lib/dev_suite/utils/construct/component/base.rb +30 -0
- data/lib/dev_suite/utils/construct/component/component.rb +12 -0
- data/lib/dev_suite/utils/construct/component/initializer.rb +28 -0
- data/lib/dev_suite/utils/construct/component/manager.rb +57 -0
- data/lib/dev_suite/utils/construct/{config/configuration.rb → component.rb} +2 -4
- data/lib/dev_suite/utils/construct/config/attribute/attr_definition.rb +76 -0
- data/lib/dev_suite/utils/construct/config/attribute/attr_initialization.rb +22 -0
- data/lib/dev_suite/utils/construct/config/attribute/attr_resolving.rb +80 -0
- data/lib/dev_suite/utils/construct/config/attribute/attribute.rb +12 -3
- data/lib/dev_suite/utils/construct/config/base.rb +7 -2
- data/lib/dev_suite/utils/construct/config/config.rb +2 -10
- data/lib/dev_suite/utils/construct/config/dependency_handler.rb +56 -0
- data/lib/dev_suite/utils/construct/config/hook/hook.rb +10 -1
- data/lib/dev_suite/utils/construct/config/hook/hook_registry.rb +24 -0
- data/lib/dev_suite/utils/construct/config/hook/hook_runner.rb +20 -0
- data/lib/dev_suite/utils/construct/config/manager.rb +25 -17
- data/lib/dev_suite/utils/construct/construct.rb +1 -0
- data/lib/dev_suite/utils/dependency_loader.rb +71 -0
- data/lib/dev_suite/utils/file_loader/config/config.rb +1 -1
- data/lib/dev_suite/utils/file_loader/config/configuration.rb +1 -1
- data/lib/dev_suite/utils/file_loader/loader/base.rb +1 -1
- data/lib/dev_suite/utils/file_loader/loader/loader.rb +41 -0
- data/lib/dev_suite/utils/file_loader/loader.rb +2 -30
- data/lib/dev_suite/utils/table/config/config.rb +1 -1
- data/lib/dev_suite/utils/table/config/configuration.rb +2 -2
- data/lib/dev_suite/utils/table/formatter/formatter.rb +12 -0
- data/lib/dev_suite/utils/table/formatter.rb +1 -2
- data/lib/dev_suite/utils/table/renderer/base.rb +1 -1
- data/lib/dev_suite/utils/table/renderer/renderer.rb +16 -0
- data/lib/dev_suite/utils/table/renderer.rb +1 -13
- data/lib/dev_suite/utils/utils.rb +1 -0
- data/lib/dev_suite/version.rb +3 -1
- metadata +39 -6
- data/lib/dev_suite/utils/construct/config/attribute/manager.rb +0 -63
- data/lib/dev_suite/utils/construct/config/attribute/resolver.rb +0 -31
- data/lib/dev_suite/utils/construct/config/initializer.rb +0 -21
@@ -4,7 +4,7 @@ module DevSuite
|
|
4
4
|
module Utils
|
5
5
|
module FileLoader
|
6
6
|
module Config
|
7
|
-
class Configuration <
|
7
|
+
class Configuration < Utils::Construct::Config::Base
|
8
8
|
config_attr :loaders, default_value: [:text, :json, :yaml], type: :array
|
9
9
|
|
10
10
|
register_hook :after_initialize do
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DevSuite
|
4
|
+
module Utils
|
5
|
+
module FileLoader
|
6
|
+
module Loader
|
7
|
+
require_relative "base"
|
8
|
+
require_relative "text"
|
9
|
+
require_relative "json"
|
10
|
+
require_relative "yaml"
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def registry_loaders(registry, loader_symbols)
|
14
|
+
loader_classes = map_loaders(loader_symbols)
|
15
|
+
loader_classes.each do |loader|
|
16
|
+
registry.register(loader)
|
17
|
+
end
|
18
|
+
registry
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def map_loaders(loader_symbols)
|
24
|
+
loader_symbols.map do |symbol|
|
25
|
+
case symbol
|
26
|
+
when :json
|
27
|
+
Loader::Json
|
28
|
+
when :text
|
29
|
+
Loader::Text
|
30
|
+
when :yaml
|
31
|
+
Loader::Yaml
|
32
|
+
else
|
33
|
+
raise "Unknown loader: #{symbol}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -4,37 +4,9 @@ module DevSuite
|
|
4
4
|
module Utils
|
5
5
|
module FileLoader
|
6
6
|
module Loader
|
7
|
-
|
8
|
-
require_relative "loader/text"
|
9
|
-
require_relative "loader/json"
|
10
|
-
require_relative "loader/yaml"
|
7
|
+
include Construct::Component::Manager
|
11
8
|
|
12
|
-
|
13
|
-
def registry_loaders(registry, loader_symbols)
|
14
|
-
loader_classes = map_loaders(loader_symbols)
|
15
|
-
loader_classes.each do |loader|
|
16
|
-
registry.register(loader)
|
17
|
-
end
|
18
|
-
registry
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def map_loaders(loader_symbols)
|
24
|
-
loader_symbols.map do |symbol|
|
25
|
-
case symbol
|
26
|
-
when :json
|
27
|
-
Loader::Json
|
28
|
-
when :text
|
29
|
-
Loader::Text
|
30
|
-
when :yaml
|
31
|
-
Loader::Yaml
|
32
|
-
else
|
33
|
-
raise "Unknown loader: #{symbol}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
9
|
+
require_relative "loader/loader"
|
38
10
|
end
|
39
11
|
end
|
40
12
|
end
|
@@ -4,7 +4,7 @@ module DevSuite
|
|
4
4
|
module Utils
|
5
5
|
module Table
|
6
6
|
module Config
|
7
|
-
class Configuration <
|
7
|
+
class Configuration < Utils::Construct::Config::Base
|
8
8
|
set_default_settings(
|
9
9
|
colors: {
|
10
10
|
title: :cyan,
|
@@ -23,7 +23,7 @@ module DevSuite
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def resolve_renderer(value)
|
26
|
-
Renderer.
|
26
|
+
Renderer.build_component(value)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DevSuite
|
4
|
+
module Utils
|
5
|
+
module Table
|
6
|
+
module Renderer
|
7
|
+
include Construct::Component::Manager
|
8
|
+
|
9
|
+
require_relative "base"
|
10
|
+
require_relative "simple"
|
11
|
+
|
12
|
+
register_component(Simple)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -4,19 +4,7 @@ module DevSuite
|
|
4
4
|
module Utils
|
5
5
|
module Table
|
6
6
|
module Renderer
|
7
|
-
require_relative "renderer/
|
8
|
-
require_relative "renderer/simple"
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def create(type)
|
12
|
-
case type
|
13
|
-
when :simple
|
14
|
-
Simple.new
|
15
|
-
else
|
16
|
-
raise ArgumentError, "Unknown renderer type: #{type}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
7
|
+
require_relative "renderer/renderer"
|
20
8
|
end
|
21
9
|
end
|
22
10
|
end
|
data/lib/dev_suite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_suite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huy Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark
|
@@ -67,6 +67,9 @@ files:
|
|
67
67
|
- ".rubocop.yml"
|
68
68
|
- ".tool-versions"
|
69
69
|
- ".travis.yml"
|
70
|
+
- ".vscode/extensions.json"
|
71
|
+
- ".vscode/launch.json"
|
72
|
+
- ".vscode/settings.json"
|
70
73
|
- CODE_OF_CONDUCT.md
|
71
74
|
- Gemfile
|
72
75
|
- Gemfile.lock
|
@@ -74,6 +77,7 @@ files:
|
|
74
77
|
- README.md
|
75
78
|
- Rakefile
|
76
79
|
- bin/console
|
80
|
+
- bin/rspec
|
77
81
|
- bin/setup
|
78
82
|
- dev_suite.gemspec
|
79
83
|
- exe/devsuite
|
@@ -88,6 +92,7 @@ files:
|
|
88
92
|
- lib/dev_suite/directory_tree.rb
|
89
93
|
- lib/dev_suite/directory_tree/builder.rb
|
90
94
|
- lib/dev_suite/directory_tree/builder/base.rb
|
95
|
+
- lib/dev_suite/directory_tree/builder/builder.rb
|
91
96
|
- lib/dev_suite/directory_tree/config.rb
|
92
97
|
- lib/dev_suite/directory_tree/config/config.rb
|
93
98
|
- lib/dev_suite/directory_tree/config/configuration.rb
|
@@ -96,41 +101,56 @@ files:
|
|
96
101
|
- lib/dev_suite/directory_tree/node/base.rb
|
97
102
|
- lib/dev_suite/directory_tree/node/directory.rb
|
98
103
|
- lib/dev_suite/directory_tree/node/file.rb
|
104
|
+
- lib/dev_suite/directory_tree/node/node.rb
|
99
105
|
- lib/dev_suite/directory_tree/node/permission_denied.rb
|
100
106
|
- lib/dev_suite/directory_tree/renderer.rb
|
101
107
|
- lib/dev_suite/directory_tree/renderer/base.rb
|
108
|
+
- lib/dev_suite/directory_tree/renderer/renderer.rb
|
102
109
|
- lib/dev_suite/directory_tree/renderer/simple.rb
|
103
110
|
- lib/dev_suite/directory_tree/visualizer.rb
|
104
111
|
- lib/dev_suite/directory_tree/visualizer/base.rb
|
105
112
|
- lib/dev_suite/directory_tree/visualizer/tree.rb
|
113
|
+
- lib/dev_suite/directory_tree/visualizer/visualizer.rb
|
106
114
|
- lib/dev_suite/performance.rb
|
107
115
|
- lib/dev_suite/performance/analyzer.rb
|
108
116
|
- lib/dev_suite/performance/config.rb
|
109
117
|
- lib/dev_suite/performance/config/config.rb
|
110
118
|
- lib/dev_suite/performance/config/configuration.rb
|
111
119
|
- lib/dev_suite/performance/data.rb
|
120
|
+
- lib/dev_suite/performance/data/data.rb
|
112
121
|
- lib/dev_suite/performance/data/memory_usage.rb
|
113
122
|
- lib/dev_suite/performance/profiler.rb
|
114
123
|
- lib/dev_suite/performance/profiler/base.rb
|
115
124
|
- lib/dev_suite/performance/profiler/execution_time.rb
|
116
125
|
- lib/dev_suite/performance/profiler/memory.rb
|
126
|
+
- lib/dev_suite/performance/profiler/profiler.rb
|
117
127
|
- lib/dev_suite/performance/profiler_manager.rb
|
118
128
|
- lib/dev_suite/performance/reporter.rb
|
119
129
|
- lib/dev_suite/performance/reporter/base.rb
|
120
130
|
- lib/dev_suite/performance/reporter/helpers.rb
|
121
131
|
- lib/dev_suite/performance/reporter/helpers/stat_mappings.rb
|
122
132
|
- lib/dev_suite/performance/reporter/helpers/table_builder.rb
|
133
|
+
- lib/dev_suite/performance/reporter/reporter.rb
|
123
134
|
- lib/dev_suite/performance/reporter/simple.rb
|
124
135
|
- lib/dev_suite/request_logger.rb
|
125
136
|
- lib/dev_suite/request_logger/adapter.rb
|
126
137
|
- lib/dev_suite/request_logger/adapter/adapter.rb
|
127
138
|
- lib/dev_suite/request_logger/adapter/base.rb
|
139
|
+
- lib/dev_suite/request_logger/adapter/faraday.rb
|
140
|
+
- lib/dev_suite/request_logger/adapter/middleware/faraday.rb
|
128
141
|
- lib/dev_suite/request_logger/adapter/net_http.rb
|
129
142
|
- lib/dev_suite/request_logger/config.rb
|
130
143
|
- lib/dev_suite/request_logger/config/config.rb
|
131
144
|
- lib/dev_suite/request_logger/config/configuration.rb
|
145
|
+
- lib/dev_suite/request_logger/extractor.rb
|
146
|
+
- lib/dev_suite/request_logger/extractor/base.rb
|
147
|
+
- lib/dev_suite/request_logger/extractor/extractor.rb
|
148
|
+
- lib/dev_suite/request_logger/extractor/faraday.rb
|
149
|
+
- lib/dev_suite/request_logger/extractor/net_http.rb
|
132
150
|
- lib/dev_suite/request_logger/logger.rb
|
151
|
+
- lib/dev_suite/request_logger/request.rb
|
133
152
|
- lib/dev_suite/request_logger/request_logger.rb
|
153
|
+
- lib/dev_suite/request_logger/response.rb
|
134
154
|
- lib/dev_suite/utils.rb
|
135
155
|
- lib/dev_suite/utils/color.rb
|
136
156
|
- lib/dev_suite/utils/color/color.rb
|
@@ -141,31 +161,41 @@ files:
|
|
141
161
|
- lib/dev_suite/utils/color/palette.rb
|
142
162
|
- lib/dev_suite/utils/color/palette/base.rb
|
143
163
|
- lib/dev_suite/utils/color/palette/default.rb
|
164
|
+
- lib/dev_suite/utils/color/palette/palette.rb
|
144
165
|
- lib/dev_suite/utils/color/strategy.rb
|
145
166
|
- lib/dev_suite/utils/color/strategy/base.rb
|
146
167
|
- lib/dev_suite/utils/color/strategy/basic.rb
|
147
168
|
- lib/dev_suite/utils/color/strategy/rgb.rb
|
169
|
+
- lib/dev_suite/utils/color/strategy/strategy.rb
|
148
170
|
- lib/dev_suite/utils/color/strategy/theme.rb
|
149
171
|
- lib/dev_suite/utils/construct.rb
|
172
|
+
- lib/dev_suite/utils/construct/component.rb
|
173
|
+
- lib/dev_suite/utils/construct/component/base.rb
|
174
|
+
- lib/dev_suite/utils/construct/component/component.rb
|
175
|
+
- lib/dev_suite/utils/construct/component/initializer.rb
|
176
|
+
- lib/dev_suite/utils/construct/component/manager.rb
|
150
177
|
- lib/dev_suite/utils/construct/config.rb
|
151
178
|
- lib/dev_suite/utils/construct/config/attribute.rb
|
179
|
+
- lib/dev_suite/utils/construct/config/attribute/attr_definition.rb
|
180
|
+
- lib/dev_suite/utils/construct/config/attribute/attr_initialization.rb
|
181
|
+
- lib/dev_suite/utils/construct/config/attribute/attr_resolving.rb
|
152
182
|
- lib/dev_suite/utils/construct/config/attribute/attribute.rb
|
153
|
-
- lib/dev_suite/utils/construct/config/attribute/manager.rb
|
154
|
-
- lib/dev_suite/utils/construct/config/attribute/resolver.rb
|
155
183
|
- lib/dev_suite/utils/construct/config/attribute/validator.rb
|
156
184
|
- lib/dev_suite/utils/construct/config/base.rb
|
157
185
|
- lib/dev_suite/utils/construct/config/config.rb
|
158
|
-
- lib/dev_suite/utils/construct/config/
|
186
|
+
- lib/dev_suite/utils/construct/config/dependency_handler.rb
|
159
187
|
- lib/dev_suite/utils/construct/config/hook.rb
|
160
188
|
- lib/dev_suite/utils/construct/config/hook/hook.rb
|
189
|
+
- lib/dev_suite/utils/construct/config/hook/hook_registry.rb
|
190
|
+
- lib/dev_suite/utils/construct/config/hook/hook_runner.rb
|
161
191
|
- lib/dev_suite/utils/construct/config/hook/manager.rb
|
162
|
-
- lib/dev_suite/utils/construct/config/initializer.rb
|
163
192
|
- lib/dev_suite/utils/construct/config/manager.rb
|
164
193
|
- lib/dev_suite/utils/construct/config/settings.rb
|
165
194
|
- lib/dev_suite/utils/construct/config/settings/base.rb
|
166
195
|
- lib/dev_suite/utils/construct/config/settings/manager.rb
|
167
196
|
- lib/dev_suite/utils/construct/config/settings/settings.rb
|
168
197
|
- lib/dev_suite/utils/construct/construct.rb
|
198
|
+
- lib/dev_suite/utils/dependency_loader.rb
|
169
199
|
- lib/dev_suite/utils/emoji.rb
|
170
200
|
- lib/dev_suite/utils/error_handler.rb
|
171
201
|
- lib/dev_suite/utils/file_loader.rb
|
@@ -176,6 +206,7 @@ files:
|
|
176
206
|
- lib/dev_suite/utils/file_loader/loader.rb
|
177
207
|
- lib/dev_suite/utils/file_loader/loader/base.rb
|
178
208
|
- lib/dev_suite/utils/file_loader/loader/json.rb
|
209
|
+
- lib/dev_suite/utils/file_loader/loader/loader.rb
|
179
210
|
- lib/dev_suite/utils/file_loader/loader/text.rb
|
180
211
|
- lib/dev_suite/utils/file_loader/loader/yaml.rb
|
181
212
|
- lib/dev_suite/utils/file_loader/loader_manager.rb
|
@@ -192,9 +223,11 @@ files:
|
|
192
223
|
- lib/dev_suite/utils/table/config/configuration.rb
|
193
224
|
- lib/dev_suite/utils/table/formatter.rb
|
194
225
|
- lib/dev_suite/utils/table/formatter/column_width_calculator.rb
|
226
|
+
- lib/dev_suite/utils/table/formatter/formatter.rb
|
195
227
|
- lib/dev_suite/utils/table/formatter/text_aligner.rb
|
196
228
|
- lib/dev_suite/utils/table/renderer.rb
|
197
229
|
- lib/dev_suite/utils/table/renderer/base.rb
|
230
|
+
- lib/dev_suite/utils/table/renderer/renderer.rb
|
198
231
|
- lib/dev_suite/utils/table/renderer/simple.rb
|
199
232
|
- lib/dev_suite/utils/table/row.rb
|
200
233
|
- lib/dev_suite/utils/table/table.rb
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DevSuite
|
4
|
-
module Utils
|
5
|
-
module Construct
|
6
|
-
module Config
|
7
|
-
module Attribute
|
8
|
-
module Manager
|
9
|
-
include Validator
|
10
|
-
include Resolver
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def included(base)
|
14
|
-
base.extend(ClassMethods)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module ClassMethods
|
19
|
-
def config_attr(attr, default_value: nil, type: nil, resolver: nil)
|
20
|
-
config_attrs[attr] = { default_value: default_value, type: type, resolver: resolver }
|
21
|
-
define_config_attr_methods(attr)
|
22
|
-
end
|
23
|
-
|
24
|
-
def config_attrs
|
25
|
-
@config_attrs ||= {}
|
26
|
-
end
|
27
|
-
|
28
|
-
def config_attr_present?(attr)
|
29
|
-
config_attrs.key?(attr)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def define_config_attr_methods(attr)
|
35
|
-
define_method(attr) { instance_variable_get("@#{attr}") }
|
36
|
-
define_method("#{attr}=") do |value|
|
37
|
-
validate_and_set_config_attr(attr: attr, value: value)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def initialize_config_attrs
|
45
|
-
self.class.config_attrs.each do |attr, details|
|
46
|
-
send("#{attr}=", details[:default_value]) unless instance_variable_defined?("@#{attr}")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def validate_and_set_config_attr(attr:, value:)
|
51
|
-
attr_details = self.class.config_attrs[attr]
|
52
|
-
type, resolver = attr_details.values_at(:type, :resolver)
|
53
|
-
|
54
|
-
validate_config_attr_type!(attr: attr, value: value, type: type) if type
|
55
|
-
resolved_value = resolver ? resolve_config_attr(value: value, resolver: resolver) : value
|
56
|
-
instance_variable_set("@#{attr}", resolved_value)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DevSuite
|
4
|
-
module Utils
|
5
|
-
module Construct
|
6
|
-
module Config
|
7
|
-
module Attribute
|
8
|
-
module Resolver
|
9
|
-
extend self
|
10
|
-
|
11
|
-
# Resolves the value of an attribute based on its resolver.
|
12
|
-
# If no resolver is provided, the value is returned as is.
|
13
|
-
#
|
14
|
-
# @param value [Object] The value to resolve.
|
15
|
-
# @param resolver [Proc] The resolver to use for the attribute.
|
16
|
-
def resolve_config_attr(value:, resolver:)
|
17
|
-
case resolver
|
18
|
-
when Proc
|
19
|
-
resolver.call(value)
|
20
|
-
when Symbol
|
21
|
-
send(resolver, value)
|
22
|
-
else
|
23
|
-
value
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DevSuite
|
4
|
-
module Utils
|
5
|
-
module Construct
|
6
|
-
module Config
|
7
|
-
module Initializer
|
8
|
-
class << self
|
9
|
-
def define_config_constants(base)
|
10
|
-
base.const_set(:BaseConfiguration, Configuration)
|
11
|
-
|
12
|
-
unless base.const_defined?(:Configuration)
|
13
|
-
base.const_set(:Configuration, Class.new(base::BaseConfiguration))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|