dev_suite 0.2.4 → 0.2.5

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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +53 -0
  5. data/dev_suite.gemspec +0 -4
  6. data/lib/dev_suite/cli/commands/base.rb +0 -2
  7. data/lib/dev_suite/cli/commands/tree.rb +3 -3
  8. data/lib/dev_suite/cli/commands/version.rb +1 -1
  9. data/lib/dev_suite/cli/main.rb +1 -1
  10. data/lib/dev_suite/dev_suite.rb +12 -0
  11. data/lib/dev_suite/directory_tree/config/config.rb +11 -0
  12. data/lib/dev_suite/directory_tree/config/configuration.rb +21 -0
  13. data/lib/dev_suite/directory_tree/config.rb +2 -36
  14. data/lib/dev_suite/directory_tree/directory_tree.rb +0 -1
  15. data/lib/dev_suite/directory_tree/renderer/base.rb +0 -6
  16. data/lib/dev_suite/performance/analyzer.rb +1 -1
  17. data/lib/dev_suite/performance/config/config.rb +11 -0
  18. data/lib/dev_suite/performance/config/configuration.rb +30 -0
  19. data/lib/dev_suite/performance/config.rb +2 -30
  20. data/lib/dev_suite/performance/{reportor → reporter}/base.rb +1 -1
  21. data/lib/dev_suite/performance/{reportor → reporter}/helpers/stat_mappings.rb +1 -1
  22. data/lib/dev_suite/performance/{reportor → reporter}/helpers/table_builder.rb +1 -1
  23. data/lib/dev_suite/performance/{reportor → reporter}/helpers.rb +1 -1
  24. data/lib/dev_suite/performance/{reportor → reporter}/simple.rb +1 -1
  25. data/lib/dev_suite/performance/reporter.rb +22 -0
  26. data/lib/dev_suite/performance.rb +1 -1
  27. data/lib/dev_suite/request_logger/adapter/adapter.rb +27 -0
  28. data/lib/dev_suite/request_logger/adapter/base.rb +17 -0
  29. data/lib/dev_suite/request_logger/adapter/net_http.rb +42 -0
  30. data/lib/dev_suite/request_logger/adapter.rb +9 -0
  31. data/lib/dev_suite/request_logger/config/config.rb +11 -0
  32. data/lib/dev_suite/request_logger/config/configuration.rb +24 -0
  33. data/lib/dev_suite/request_logger/config.rb +9 -0
  34. data/lib/dev_suite/request_logger/logger.rb +93 -0
  35. data/lib/dev_suite/request_logger/request_logger.rb +29 -0
  36. data/lib/dev_suite/request_logger.rb +7 -0
  37. data/lib/dev_suite/utils/color/color.rb +12 -0
  38. data/lib/dev_suite/utils/color/config/config.rb +13 -0
  39. data/lib/dev_suite/utils/color/config/configuration.rb +31 -0
  40. data/lib/dev_suite/utils/color/config.rb +2 -31
  41. data/lib/dev_suite/utils/color/strategy/theme.rb +6 -7
  42. data/lib/dev_suite/utils/color/strategy.rb +2 -4
  43. data/lib/dev_suite/utils/color.rb +1 -4
  44. data/lib/dev_suite/utils/construct/config/attribute/attribute.rb +15 -0
  45. data/lib/dev_suite/utils/construct/config/attribute/manager.rb +63 -0
  46. data/lib/dev_suite/utils/construct/config/attribute/resolver.rb +31 -0
  47. data/lib/dev_suite/utils/construct/config/attribute/validator.rb +55 -0
  48. data/lib/dev_suite/utils/construct/config/attribute.rb +13 -0
  49. data/lib/dev_suite/utils/construct/config/base.rb +20 -0
  50. data/lib/dev_suite/utils/construct/config/config.rb +24 -0
  51. data/lib/dev_suite/utils/construct/config/configuration.rb +13 -0
  52. data/lib/dev_suite/utils/construct/config/hook/hook.rb +13 -0
  53. data/lib/dev_suite/utils/construct/config/hook/manager.rb +36 -0
  54. data/lib/dev_suite/utils/construct/config/hook.rb +13 -0
  55. data/lib/dev_suite/utils/construct/config/initializer.rb +21 -0
  56. data/lib/dev_suite/utils/construct/config/manager.rb +33 -0
  57. data/lib/dev_suite/utils/construct/config/settings/base.rb +59 -0
  58. data/lib/dev_suite/utils/construct/config/settings/manager.rb +38 -0
  59. data/lib/dev_suite/utils/construct/config/settings/settings.rb +14 -0
  60. data/lib/dev_suite/utils/construct/config/settings.rb +13 -0
  61. data/lib/dev_suite/utils/construct/config.rb +11 -0
  62. data/lib/dev_suite/utils/construct/construct.rb +9 -0
  63. data/lib/dev_suite/utils/construct.rb +16 -0
  64. data/lib/dev_suite/utils/emoji.rb +71 -0
  65. data/lib/dev_suite/utils/error_handler.rb +24 -0
  66. data/lib/dev_suite/utils/file_loader/config/config.rb +13 -0
  67. data/lib/dev_suite/utils/file_loader/config/configuration.rb +33 -0
  68. data/lib/dev_suite/utils/file_loader/config.rb +11 -0
  69. data/lib/dev_suite/utils/file_loader/file_loader.rb +23 -0
  70. data/lib/dev_suite/utils/file_loader/loader/base.rb +21 -0
  71. data/lib/dev_suite/utils/file_loader/loader/json.rb +21 -0
  72. data/lib/dev_suite/utils/file_loader/loader/text.rb +21 -0
  73. data/lib/dev_suite/utils/file_loader/loader/yaml.rb +38 -0
  74. data/lib/dev_suite/utils/file_loader/loader.rb +41 -0
  75. data/lib/dev_suite/utils/file_loader/loader_manager.rb +34 -0
  76. data/lib/dev_suite/utils/file_loader/loader_registry.rb +36 -0
  77. data/lib/dev_suite/utils/file_loader.rb +9 -0
  78. data/lib/dev_suite/utils/logger.rb +58 -0
  79. data/lib/dev_suite/utils/path_matcher/matcher.rb +31 -0
  80. data/lib/dev_suite/utils/path_matcher/path_matcher.rb +17 -0
  81. data/lib/dev_suite/utils/path_matcher/pattern.rb +35 -0
  82. data/lib/dev_suite/utils/path_matcher.rb +9 -0
  83. data/lib/dev_suite/utils/table/config/config.rb +13 -0
  84. data/lib/dev_suite/utils/table/config/configuration.rb +32 -0
  85. data/lib/dev_suite/utils/table/config.rb +2 -23
  86. data/lib/dev_suite/utils/table/renderer/base.rb +0 -6
  87. data/lib/dev_suite/utils/table/renderer/simple.rb +9 -5
  88. data/lib/dev_suite/utils/table/renderer.rb +2 -2
  89. data/lib/dev_suite/utils/table/table.rb +6 -0
  90. data/lib/dev_suite/utils/table.rb +0 -6
  91. data/lib/dev_suite/utils/utils.rb +14 -0
  92. data/lib/dev_suite/utils.rb +1 -3
  93. data/lib/dev_suite/version.rb +1 -1
  94. data/lib/dev_suite.rb +1 -10
  95. metadata +68 -44
  96. data/lib/dev_suite/directory_tree/settings.rb +0 -18
  97. data/lib/dev_suite/emoji.rb +0 -33
  98. data/lib/dev_suite/error_handler.rb +0 -22
  99. data/lib/dev_suite/logger.rb +0 -56
  100. data/lib/dev_suite/performance/reportor.rb +0 -22
  101. data/lib/dev_suite/utils/config_tools/configuration.rb +0 -134
  102. data/lib/dev_suite/utils/config_tools/settings.rb +0 -67
  103. data/lib/dev_suite/utils/config_tools.rb +0 -10
  104. data/lib/dev_suite/utils/table/settings.rb +0 -34
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module RequestLogger
5
+ module Logger
6
+ class << self
7
+ def log_request(adapter, request)
8
+ log_entry(format_request_line(adapter, request), :start)
9
+ log_headers(request) if settings.get(:log_headers)
10
+ log_cookies(request) if settings.get(:log_cookies)
11
+ log_body(request.body, "Request") if settings.get(:log_body)
12
+ end
13
+
14
+ def log_response(adapter, response)
15
+ status_emoji = determine_status_emoji(response)
16
+ log_level = determine_log_level(response)
17
+
18
+ log_entry(format_response_line(adapter, response), status_emoji, log_level)
19
+ log_headers(response) if settings.get(:log_headers)
20
+ log_body(response.body, "Response") if settings.get(:log_body)
21
+ end
22
+
23
+ private
24
+
25
+ def config
26
+ Config.configuration
27
+ end
28
+
29
+ def settings
30
+ config.settings
31
+ end
32
+
33
+ def log_entry(message, emoji, level = settings.get(:log_level))
34
+ Utils::Logger.log(message, level: level, emoji: emoji)
35
+ end
36
+
37
+ def determine_status_emoji(response)
38
+ response_success?(response) ? :success : :error
39
+ end
40
+
41
+ def determine_log_level(response)
42
+ response_success?(response) ? settings.get(:log_level) : :error
43
+ end
44
+
45
+ def response_success?(response)
46
+ response.code.to_i.between?(200, 299)
47
+ end
48
+
49
+ def extract_headers(request)
50
+ request.each_header.to_h
51
+ end
52
+
53
+ def extract_cookies(request)
54
+ if request.respond_to?(:to_hash) && request.to_hash["cookie"]
55
+ request.to_hash["cookie"]
56
+ elsif request.respond_to?(:headers) && request.headers["Cookie"]
57
+ [request.headers["Cookie"]]
58
+ else
59
+ []
60
+ end
61
+ end
62
+
63
+ def format_request_line(adapter, request)
64
+ "#{adapter.class} Request: #{request.method} #{request.uri}"
65
+ end
66
+
67
+ def format_response_line(adapter, response)
68
+ "#{adapter.class} Response: #{response.code} #{response.message}"
69
+ end
70
+
71
+ def log_headers(request)
72
+ headers = extract_headers(request)
73
+ log_entry("Headers: #{headers}", :document) unless headers.empty?
74
+ end
75
+
76
+ def log_cookies(request)
77
+ cookies = extract_cookies(request)
78
+ if cookies.any?
79
+ log_entry("Cookies: #{cookies.join("; ")}", :cookie)
80
+ else
81
+ log_entry("Cookies: None", :cookie)
82
+ end
83
+ end
84
+
85
+ def log_body(body, type)
86
+ return unless body && !body.empty?
87
+
88
+ log_entry("#{type} Body: #{body}", :code)
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module RequestLogger
5
+ require_relative "config"
6
+ require_relative "adapter"
7
+ require_relative "logger"
8
+
9
+ class << self
10
+ def with_logging(&block)
11
+ enable_adapters
12
+ block.call
13
+ ensure
14
+ # Ensure that adapters are disabled even if an exception is raised
15
+ disable_adapters
16
+ end
17
+
18
+ private
19
+
20
+ def enable_adapters
21
+ Config.configuration.adapters.each(&:enable)
22
+ end
23
+
24
+ def disable_adapters
25
+ Config.configuration.adapters.each(&:disable)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module RequestLogger
5
+ require_relative "request_logger/request_logger"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Color
6
+ require_relative "colorizer"
7
+ require_relative "palette"
8
+ require_relative "strategy"
9
+ require_relative "config"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Color
6
+ module Config
7
+ include Construct::Config
8
+
9
+ require_relative "configuration"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Color
6
+ module Config
7
+ class Configuration < BaseConfiguration
8
+ config_attr :strategy,
9
+ default_value: :theme,
10
+ type: :symbol,
11
+ resolver: :resolve_strategy
12
+
13
+ config_attr :palette,
14
+ default_value: :default,
15
+ type: :symbol,
16
+ resolver: :resolve_palette
17
+
18
+ private
19
+
20
+ def resolve_strategy(value)
21
+ Strategy.create(value)
22
+ end
23
+
24
+ def resolve_palette(value)
25
+ Palette.create(value)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,37 +3,8 @@
3
3
  module DevSuite
4
4
  module Utils
5
5
  module Color
6
- class Config
7
- attr_accessor :strategy, :palette
8
-
9
- def initialize(strategy: :theme, palette: :default)
10
- @palette = Palette.create(palette)
11
- @strategy = Strategy.create(strategy, palette: @palette)
12
- freeze # Make the instance of this class immutable as well
13
- end
14
-
15
- class << self
16
- #
17
- # Provide global access to a single instance of Config
18
- #
19
- def configuration
20
- @configuration ||= new
21
- end
22
-
23
- # Allow block-based configuration
24
- def configure
25
- yield(configuration)
26
- rescue StandardError => e
27
- handle_configuration_error(e)
28
- raise
29
- end
30
-
31
- private
32
-
33
- def handle_configuration_error(error)
34
- puts "Configuration error: #{error.message}"
35
- end
36
- end
6
+ module Config
7
+ require_relative "config/config"
37
8
  end
38
9
  end
39
10
  end
@@ -5,17 +5,12 @@ module DevSuite
5
5
  module Color
6
6
  module Strategy
7
7
  class Theme < Base
8
- def initialize(palette)
9
- super()
10
- @palette = palette
11
- end
12
-
13
8
  def colorize(text, color: :default)
14
- unless @palette.colors.key?(color)
9
+ unless palette.colors.key?(color)
15
10
  raise ArgumentError, "Invalid color key"
16
11
  end
17
12
 
18
- color_code = @palette.colors[color]
13
+ color_code = palette.colors[color]
19
14
 
20
15
  unless valid_color_code?(color_code)
21
16
  raise ArgumentError, "Invalid color code"
@@ -26,6 +21,10 @@ module DevSuite
26
21
 
27
22
  private
28
23
 
24
+ def palette
25
+ Config.configuration.palette
26
+ end
27
+
29
28
  def valid_color_code?(color_code)
30
29
  color_code.is_a?(Integer) && color_code.between?(0, 255)
31
30
  end
@@ -10,16 +10,14 @@ module DevSuite
10
10
  require_relative "strategy/theme"
11
11
 
12
12
  class << self
13
- def create(type, palette: nil)
13
+ def create(type)
14
14
  case type
15
15
  when :basic
16
16
  Basic.new
17
17
  when :rgb
18
18
  Rgb.new
19
19
  when :theme
20
- raise ArgumentError, "Palette is required for theme strategy" unless palette
21
-
22
- Theme.new(palette)
20
+ Theme.new
23
21
  else
24
22
  raise ArgumentError, "Unknown strategy type: #{type}"
25
23
  end
@@ -3,10 +3,7 @@
3
3
  module DevSuite
4
4
  module Utils
5
5
  module Color
6
- require_relative "color/colorizer"
7
- require_relative "color/palette"
8
- require_relative "color/strategy"
9
- require_relative "color/config"
6
+ require_relative "color/color"
10
7
  end
11
8
  end
12
9
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Attribute
8
+ require_relative "validator"
9
+ require_relative "resolver"
10
+ require_relative "manager"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,63 @@
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
@@ -0,0 +1,31 @@
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
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Attribute
8
+ module Validator
9
+ extend self
10
+
11
+ # Validates an attribute's value based on its type.
12
+ #
13
+ # @param attr [Symbol] The name of the attribute.
14
+ # @param value [Object] The value to validate.
15
+ # @param type [Symbol] The expected type of the attribute.
16
+ def validate_config_attr_type!(attr:, value:, type:)
17
+ case type
18
+ when :symbol
19
+ validate_symbol!(value)
20
+ when :hash
21
+ validate_hash!(value)
22
+ when :array
23
+ validate_array!(value)
24
+ when :class
25
+ validate_instance_of!(value, Object)
26
+ else
27
+ raise ArgumentError, "Unknown type #{type} for attribute #{attr}"
28
+ end
29
+ end
30
+
31
+ # Utility method to validate a Symbol.
32
+ def validate_symbol!(value)
33
+ raise ArgumentError, "Expected a Symbol, got #{value.class}" unless value.is_a?(Symbol)
34
+ end
35
+
36
+ # Utility method to validate a Hash.
37
+ def validate_hash!(value)
38
+ raise ArgumentError, "Expected a Hash, got #{value.class}" unless value.is_a?(Hash)
39
+ end
40
+
41
+ # Utility method to validate an Array.
42
+ def validate_array!(value)
43
+ raise ArgumentError, "Expected an Array, got #{value.class}" unless value.is_a?(Array)
44
+ end
45
+
46
+ # Utility method to validate a class instance.
47
+ def validate_instance_of!(value, klass)
48
+ raise ArgumentError, "Expected an instance of #{klass}, got #{value.class}" unless value.is_a?(klass)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Attribute
8
+ require_relative "attribute/attribute"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ class Base
8
+ include Attribute::Manager
9
+ include Hook::Manager
10
+
11
+ def initialize
12
+ run_hooks(:before_initialize)
13
+ initialize_config_attrs
14
+ run_hooks(:after_initialize)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ require_relative "attribute"
8
+ require_relative "hook"
9
+ require_relative "base"
10
+ require_relative "settings"
11
+ require_relative "configuration"
12
+ require_relative "manager"
13
+ require_relative "initializer"
14
+
15
+ class << self
16
+ def included(base)
17
+ base.extend(Manager)
18
+ Initializer.define_config_constants(base)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ class Configuration < Base
8
+ include Settings::Manager
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Hook
8
+ require_relative "manager"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Hook
8
+ module Manager
9
+ class << self
10
+ def included(base)
11
+ base.extend(ClassMethods)
12
+ end
13
+ end
14
+
15
+ module ClassMethods
16
+ def register_hook(stage, &block)
17
+ hooks[stage] ||= []
18
+ hooks[stage] << block
19
+ end
20
+
21
+ def hooks
22
+ @hooks ||= {}
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def run_hooks(stage)
29
+ self.class.hooks[stage]&.each { |hook| instance_eval(&hook) }
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Hook
8
+ require_relative "hook/hook"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
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
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Manager
8
+ # Provides access to a single instance of the configuration class
9
+ # It dynamically uses the Configuration class in the including module's namespace
10
+ def configuration
11
+ @configuration ||= self::Configuration.new
12
+ end
13
+
14
+ # Allows block-based configuration
15
+ # Example usage:
16
+ # ConfigClass.configure do |config|
17
+ # config.attr_name = value
18
+ # end
19
+ def configure
20
+ yield(configuration)
21
+ rescue StandardError => e
22
+ ErrorHandler.handle_error(e)
23
+ end
24
+
25
+ # Resets the configuration by reinitializing it with default values
26
+ def reset!
27
+ @configuration = self::Configuration.new # Reinitialize the configuration instance
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end