dev_suite 0.2.4 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -5
  3. data/.vscode/extensions.json +8 -0
  4. data/.vscode/launch.json +39 -0
  5. data/.vscode/settings.json +28 -0
  6. data/Gemfile +6 -1
  7. data/Gemfile.lock +28 -2
  8. data/README.md +69 -8
  9. data/bin/rspec +27 -0
  10. data/dev_suite.gemspec +0 -4
  11. data/lib/dev_suite/cli/commands/base.rb +0 -2
  12. data/lib/dev_suite/cli/commands/tree.rb +3 -3
  13. data/lib/dev_suite/cli/commands/version.rb +1 -1
  14. data/lib/dev_suite/cli/main.rb +1 -1
  15. data/lib/dev_suite/dev_suite.rb +12 -0
  16. data/lib/dev_suite/directory_tree/builder/base.rb +1 -1
  17. data/lib/dev_suite/directory_tree/builder/builder.rb +13 -0
  18. data/lib/dev_suite/directory_tree/builder.rb +1 -12
  19. data/lib/dev_suite/directory_tree/config/config.rb +11 -0
  20. data/lib/dev_suite/directory_tree/config/configuration.rb +34 -0
  21. data/lib/dev_suite/directory_tree/config.rb +2 -36
  22. data/lib/dev_suite/directory_tree/directory_tree.rb +0 -3
  23. data/lib/dev_suite/directory_tree/node/node.rb +12 -0
  24. data/lib/dev_suite/directory_tree/node.rb +1 -4
  25. data/lib/dev_suite/directory_tree/renderer/base.rb +1 -7
  26. data/lib/dev_suite/directory_tree/renderer/renderer.rb +14 -0
  27. data/lib/dev_suite/directory_tree/renderer.rb +1 -13
  28. data/lib/dev_suite/directory_tree/visualizer/base.rb +1 -1
  29. data/lib/dev_suite/directory_tree/visualizer/visualizer.rb +16 -0
  30. data/lib/dev_suite/directory_tree/visualizer.rb +1 -15
  31. data/lib/dev_suite/performance/analyzer.rb +1 -1
  32. data/lib/dev_suite/performance/config/config.rb +11 -0
  33. data/lib/dev_suite/performance/config/configuration.rb +30 -0
  34. data/lib/dev_suite/performance/config.rb +2 -30
  35. data/lib/dev_suite/performance/data/data.rb +9 -0
  36. data/lib/dev_suite/performance/data.rb +1 -1
  37. data/lib/dev_suite/performance/profiler/base.rb +1 -1
  38. data/lib/dev_suite/performance/profiler/profiler.rb +16 -0
  39. data/lib/dev_suite/performance/profiler.rb +1 -20
  40. data/lib/dev_suite/performance/profiler_manager.rb +1 -0
  41. data/lib/dev_suite/performance/{reportor → reporter}/base.rb +2 -2
  42. data/lib/dev_suite/performance/{reportor → reporter}/helpers/stat_mappings.rb +1 -1
  43. data/lib/dev_suite/performance/{reportor → reporter}/helpers/table_builder.rb +1 -1
  44. data/lib/dev_suite/performance/{reportor → reporter}/helpers.rb +1 -1
  45. data/lib/dev_suite/performance/reporter/reporter.rb +15 -0
  46. data/lib/dev_suite/performance/{reportor → reporter}/simple.rb +1 -1
  47. data/lib/dev_suite/performance/reporter.rb +9 -0
  48. data/lib/dev_suite/performance.rb +1 -1
  49. data/lib/dev_suite/request_logger/adapter/adapter.rb +31 -0
  50. data/lib/dev_suite/request_logger/adapter/base.rb +17 -0
  51. data/lib/dev_suite/request_logger/adapter/faraday.rb +37 -0
  52. data/lib/dev_suite/request_logger/adapter/middleware/faraday.rb +22 -0
  53. data/lib/dev_suite/request_logger/adapter/net_http.rb +43 -0
  54. data/lib/dev_suite/request_logger/adapter.rb +9 -0
  55. data/lib/dev_suite/request_logger/config/config.rb +11 -0
  56. data/lib/dev_suite/request_logger/config/configuration.rb +24 -0
  57. data/lib/dev_suite/request_logger/config.rb +9 -0
  58. data/lib/dev_suite/request_logger/extractor/base.rb +17 -0
  59. data/lib/dev_suite/request_logger/extractor/extractor.rb +22 -0
  60. data/lib/dev_suite/request_logger/extractor/faraday.rb +37 -0
  61. data/lib/dev_suite/request_logger/extractor/net_http.rb +36 -0
  62. data/lib/dev_suite/request_logger/extractor.rb +9 -0
  63. data/lib/dev_suite/request_logger/logger.rb +87 -0
  64. data/lib/dev_suite/request_logger/request.rb +19 -0
  65. data/lib/dev_suite/request_logger/request_logger.rb +32 -0
  66. data/lib/dev_suite/request_logger/response.rb +28 -0
  67. data/lib/dev_suite/request_logger.rb +7 -0
  68. data/lib/dev_suite/utils/color/color.rb +12 -0
  69. data/lib/dev_suite/utils/color/config/config.rb +13 -0
  70. data/lib/dev_suite/utils/color/config/configuration.rb +31 -0
  71. data/lib/dev_suite/utils/color/config.rb +2 -31
  72. data/lib/dev_suite/utils/color/palette/base.rb +1 -14
  73. data/lib/dev_suite/utils/color/palette/palette.rb +16 -0
  74. data/lib/dev_suite/utils/color/palette.rb +1 -13
  75. data/lib/dev_suite/utils/color/strategy/base.rb +1 -1
  76. data/lib/dev_suite/utils/color/strategy/strategy.rb +20 -0
  77. data/lib/dev_suite/utils/color/strategy/theme.rb +6 -7
  78. data/lib/dev_suite/utils/color/strategy.rb +1 -21
  79. data/lib/dev_suite/utils/color.rb +1 -4
  80. data/lib/dev_suite/utils/construct/component/base.rb +30 -0
  81. data/lib/dev_suite/utils/construct/component/component.rb +12 -0
  82. data/lib/dev_suite/utils/construct/component/initializer.rb +28 -0
  83. data/lib/dev_suite/utils/construct/component/manager.rb +57 -0
  84. data/lib/dev_suite/utils/construct/component.rb +11 -0
  85. data/lib/dev_suite/utils/construct/config/attribute/attr_definition.rb +76 -0
  86. data/lib/dev_suite/utils/construct/config/attribute/attr_initialization.rb +22 -0
  87. data/lib/dev_suite/utils/construct/config/attribute/attr_resolving.rb +80 -0
  88. data/lib/dev_suite/utils/construct/config/attribute/attribute.rb +24 -0
  89. data/lib/dev_suite/utils/construct/config/attribute/validator.rb +55 -0
  90. data/lib/dev_suite/utils/construct/config/attribute.rb +13 -0
  91. data/lib/dev_suite/utils/construct/config/base.rb +25 -0
  92. data/lib/dev_suite/utils/construct/config/config.rb +16 -0
  93. data/lib/dev_suite/utils/construct/config/dependency_handler.rb +56 -0
  94. data/lib/dev_suite/utils/construct/config/hook/hook.rb +22 -0
  95. data/lib/dev_suite/utils/construct/config/hook/hook_registry.rb +24 -0
  96. data/lib/dev_suite/utils/construct/config/hook/hook_runner.rb +20 -0
  97. data/lib/dev_suite/utils/construct/config/hook/manager.rb +36 -0
  98. data/lib/dev_suite/utils/construct/config/hook.rb +13 -0
  99. data/lib/dev_suite/utils/construct/config/manager.rb +41 -0
  100. data/lib/dev_suite/utils/construct/config/settings/base.rb +59 -0
  101. data/lib/dev_suite/utils/construct/config/settings/manager.rb +38 -0
  102. data/lib/dev_suite/utils/construct/config/settings/settings.rb +14 -0
  103. data/lib/dev_suite/utils/construct/config/settings.rb +13 -0
  104. data/lib/dev_suite/utils/construct/config.rb +11 -0
  105. data/lib/dev_suite/utils/construct/construct.rb +10 -0
  106. data/lib/dev_suite/utils/construct.rb +16 -0
  107. data/lib/dev_suite/utils/dependency_loader.rb +71 -0
  108. data/lib/dev_suite/utils/emoji.rb +71 -0
  109. data/lib/dev_suite/utils/error_handler.rb +24 -0
  110. data/lib/dev_suite/utils/file_loader/config/config.rb +13 -0
  111. data/lib/dev_suite/utils/file_loader/config/configuration.rb +33 -0
  112. data/lib/dev_suite/utils/file_loader/config.rb +11 -0
  113. data/lib/dev_suite/utils/file_loader/file_loader.rb +23 -0
  114. data/lib/dev_suite/utils/file_loader/loader/base.rb +21 -0
  115. data/lib/dev_suite/utils/file_loader/loader/json.rb +21 -0
  116. data/lib/dev_suite/utils/file_loader/loader/loader.rb +41 -0
  117. data/lib/dev_suite/utils/file_loader/loader/text.rb +21 -0
  118. data/lib/dev_suite/utils/file_loader/loader/yaml.rb +38 -0
  119. data/lib/dev_suite/utils/file_loader/loader.rb +13 -0
  120. data/lib/dev_suite/utils/file_loader/loader_manager.rb +34 -0
  121. data/lib/dev_suite/utils/file_loader/loader_registry.rb +36 -0
  122. data/lib/dev_suite/utils/file_loader.rb +9 -0
  123. data/lib/dev_suite/utils/logger.rb +58 -0
  124. data/lib/dev_suite/utils/path_matcher/matcher.rb +31 -0
  125. data/lib/dev_suite/utils/path_matcher/path_matcher.rb +17 -0
  126. data/lib/dev_suite/utils/path_matcher/pattern.rb +35 -0
  127. data/lib/dev_suite/utils/path_matcher.rb +9 -0
  128. data/lib/dev_suite/utils/table/config/config.rb +13 -0
  129. data/lib/dev_suite/utils/table/config/configuration.rb +32 -0
  130. data/lib/dev_suite/utils/table/config.rb +2 -23
  131. data/lib/dev_suite/utils/table/formatter/formatter.rb +12 -0
  132. data/lib/dev_suite/utils/table/formatter.rb +1 -2
  133. data/lib/dev_suite/utils/table/renderer/base.rb +1 -7
  134. data/lib/dev_suite/utils/table/renderer/renderer.rb +16 -0
  135. data/lib/dev_suite/utils/table/renderer/simple.rb +9 -5
  136. data/lib/dev_suite/utils/table/renderer.rb +1 -13
  137. data/lib/dev_suite/utils/table/table.rb +6 -0
  138. data/lib/dev_suite/utils/table.rb +0 -6
  139. data/lib/dev_suite/utils/utils.rb +15 -0
  140. data/lib/dev_suite/utils.rb +1 -3
  141. data/lib/dev_suite/version.rb +3 -1
  142. data/lib/dev_suite.rb +1 -10
  143. metadata +101 -44
  144. data/lib/dev_suite/directory_tree/settings.rb +0 -18
  145. data/lib/dev_suite/emoji.rb +0 -33
  146. data/lib/dev_suite/error_handler.rb +0 -22
  147. data/lib/dev_suite/logger.rb +0 -56
  148. data/lib/dev_suite/performance/reportor.rb +0 -22
  149. data/lib/dev_suite/utils/config_tools/configuration.rb +0 -134
  150. data/lib/dev_suite/utils/config_tools/settings.rb +0 -67
  151. data/lib/dev_suite/utils/config_tools.rb +0 -10
  152. 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