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
@@ -1,134 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DevSuite
4
- module Utils
5
- module ConfigTools
6
- module Configuration
7
- # Module for global configuration
8
- class << self
9
- def included(base)
10
- base.extend(ClassMethods)
11
- base.include(InstanceMethods)
12
- end
13
- end
14
-
15
- module ClassMethods
16
- # Provides global access to a single instance of the configuration class
17
- # @return [Object] The singleton configuration instance
18
- def configuration
19
- @configuration ||= new
20
- end
21
-
22
- # Allows block-based configuration
23
- # Example usage:
24
- # ConfigClass.configure do |config|
25
- # config.attr_name = value
26
- # end
27
- def configure
28
- yield(configuration)
29
- rescue StandardError => e
30
- ErrorHandler.handle_error(e)
31
- end
32
-
33
- # Defines a configuration attribute with an optional default value
34
- # This method automatically creates getter and setter methods for the attribute
35
- #
36
- # @param attr_name [Symbol] The name of the attribute
37
- # @param default_value [Object] The default value for the attribute
38
- def config_attr(attr_name, default_value: nil)
39
- config_attrs[attr_name] = default_value
40
-
41
- # Getter method for the attribute
42
- define_method(attr_name) do
43
- instance_variable_get("@#{attr_name}")
44
- end
45
-
46
- # Setter method for the attribute with validation and resolution
47
- define_method("#{attr_name}=") do |value|
48
- validate_attr!(attr_name, value)
49
- instance_variable_set("@#{attr_name}", resolve_attr(attr_name, value))
50
- end
51
- end
52
-
53
- # Stores configuration attributes and their default values
54
- # @return [Hash] A hash of attribute names and their default values
55
- def config_attrs
56
- @config_attrs ||= {}
57
- end
58
- end
59
-
60
- # Module for instance-level methods
61
- module InstanceMethods
62
- private
63
-
64
- # Initializes configuration attributes with provided or default values
65
- # This method is called automatically during object initialization
66
- #
67
- # @param options [Hash] A hash of attribute names and their values
68
- def initialize(**options)
69
- initialize_attributes(options)
70
- end
71
-
72
- # Sets up each attribute with either the provided value or the default value
73
- #
74
- # @param options [Hash] A hash of attribute names and their values
75
- def initialize_attributes(options)
76
- self.class.config_attrs.each do |attr_name, default_value|
77
- value = options.fetch(attr_name, default_value)
78
- send("#{attr_name}=", value)
79
- end
80
- end
81
-
82
- # Validates an attribute's value based on its type
83
- # Override this method in the including class to add custom validation logic
84
- #
85
- # @param attr [Symbol] The name of the attribute
86
- # @param value [Object] The value to validate
87
- def validate_attr!(attr, value)
88
- raise ArgumentError, "Unknown attribute: #{attr}" unless self.class.config_attrs.key?(attr)
89
- raise ArgumentError, "Invalid #{attr} value: #{value}" if value.nil?
90
-
91
- # Override in including class to add custom validation logic
92
- end
93
-
94
- # Validates that an attribute's value is a Hash
95
- #
96
- # @param attr [Symbol] The name of the attribute
97
- # @param value [Object] The value to validate
98
- def validate_hash!(attr, value)
99
- raise ArgumentError, "Invalid #{attr} value: expected a Hash" unless value.is_a?(Hash)
100
- end
101
-
102
- # Validates that an attribute's value is a Symbol
103
- #
104
- # @param attr [Symbol] The name of the attribute
105
- # @param value [Object] The value to validate
106
- def validate_symbol!(attr, value)
107
- raise ArgumentError, "Invalid #{attr} value: expected a Symbol" unless value.is_a?(Symbol)
108
- end
109
-
110
- # Validates that an attribute's value is an Array
111
- #
112
- # @param attr [Symbol] The name of the attribute
113
- # @param value [Object] The value to validate
114
- def validate_array!(attr, value)
115
- raise ArgumentError, "Invalid #{attr} value: expected an Array" unless value.is_a?(Array)
116
- end
117
-
118
- # Resolves the value of an attribute, especially if it requires
119
- # converting a symbol to an object. Override in the including class.
120
- #
121
- # @param _attr [Symbol] The name of the attribute
122
- # @param value [Object] The value to resolve
123
- # @return [Object] The resolved value
124
- def resolve_attr(attr, value)
125
- raise ArgumentError, "Unknown attribute: #{attr}" unless self.class.config_attrs.key?(attr)
126
-
127
- # Override in including class to resolve symbols to objects
128
- value
129
- end
130
- end
131
- end
132
- end
133
- end
134
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DevSuite
4
- module Utils
5
- module ConfigTools
6
- # Module for managing instance settings
7
- module Settings
8
- class << self
9
- def included(base)
10
- base.include(InstanceMethods)
11
- end
12
- end
13
-
14
- module InstanceMethods
15
- def initialize(settings = {})
16
- @settings = merge_settings(default_settings, settings)
17
- end
18
-
19
- def set(*keys, value)
20
- key_path = normalize_keys(keys)
21
- last_key = key_path.pop
22
- target = key_path.each_with_object(@settings) do |key, nested|
23
- nested[key] ||= {}
24
- end
25
- target[last_key] = value
26
- end
27
-
28
- def get(*keys)
29
- key_path = normalize_keys(keys)
30
- key_path.reduce(@settings) do |nested, key|
31
- nested.is_a?(Hash) ? nested[key] : nil
32
- end
33
- end
34
-
35
- def reset!
36
- @settings = default_settings
37
- end
38
-
39
- def default_settings
40
- raise NotImplementedError, "#{self.class} must implement the #default_settings method"
41
- end
42
-
43
- private
44
-
45
- def normalize_keys(keys)
46
- key_path = keys.flatten
47
- if key_path.size == 1 && key_path.first.is_a?(String)
48
- key_path.first.to_s.split(".").map(&:to_sym)
49
- else
50
- key_path.map(&:to_sym)
51
- end
52
- end
53
-
54
- def merge_settings(defaults, overrides)
55
- defaults.merge(overrides) do |_key, oldval, newval|
56
- if oldval.is_a?(Hash) && newval.is_a?(Hash)
57
- merge_settings(oldval, newval)
58
- else
59
- newval
60
- end
61
- end
62
- end
63
- end
64
- end
65
- end
66
- end
67
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DevSuite
4
- module Utils
5
- module ConfigTools
6
- require_relative "config_tools/configuration"
7
- require_relative "config_tools/settings"
8
- end
9
- end
10
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DevSuite
4
- module Utils
5
- module Table
6
- class Settings
7
- include ConfigTools::Settings
8
-
9
- def default_settings
10
- {
11
- colors: {
12
- title: :cyan,
13
- column: :yellow,
14
- row: :default,
15
- border: :blue,
16
- },
17
- alignments: {
18
- column: :left,
19
- row: :left,
20
- },
21
- }
22
- end
23
-
24
- def color_for(key)
25
- get(:colors, key)
26
- end
27
-
28
- def alignment_for(key)
29
- get(:alignments, key)
30
- end
31
- end
32
- end
33
- end
34
- end