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.
- 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 +6 -1
- data/Gemfile.lock +28 -2
- data/README.md +69 -8
- data/bin/rspec +27 -0
- data/dev_suite.gemspec +0 -4
- data/lib/dev_suite/cli/commands/base.rb +0 -2
- data/lib/dev_suite/cli/commands/tree.rb +3 -3
- data/lib/dev_suite/cli/commands/version.rb +1 -1
- data/lib/dev_suite/cli/main.rb +1 -1
- data/lib/dev_suite/dev_suite.rb +12 -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 +11 -0
- data/lib/dev_suite/directory_tree/config/configuration.rb +34 -0
- data/lib/dev_suite/directory_tree/config.rb +2 -36
- data/lib/dev_suite/directory_tree/directory_tree.rb +0 -3
- 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 -7
- 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/analyzer.rb +1 -1
- data/lib/dev_suite/performance/config/config.rb +11 -0
- data/lib/dev_suite/performance/config/configuration.rb +30 -0
- data/lib/dev_suite/performance/config.rb +2 -30
- 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/{reportor → reporter}/base.rb +2 -2
- data/lib/dev_suite/performance/{reportor → reporter}/helpers/stat_mappings.rb +1 -1
- data/lib/dev_suite/performance/{reportor → reporter}/helpers/table_builder.rb +1 -1
- data/lib/dev_suite/performance/{reportor → reporter}/helpers.rb +1 -1
- data/lib/dev_suite/performance/reporter/reporter.rb +15 -0
- data/lib/dev_suite/performance/{reportor → reporter}/simple.rb +1 -1
- data/lib/dev_suite/performance/reporter.rb +9 -0
- data/lib/dev_suite/performance.rb +1 -1
- data/lib/dev_suite/request_logger/adapter/adapter.rb +31 -0
- data/lib/dev_suite/request_logger/adapter/base.rb +17 -0
- 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 +43 -0
- data/lib/dev_suite/request_logger/adapter.rb +9 -0
- data/lib/dev_suite/request_logger/config/config.rb +11 -0
- data/lib/dev_suite/request_logger/config/configuration.rb +24 -0
- data/lib/dev_suite/request_logger/config.rb +9 -0
- 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 +87 -0
- data/lib/dev_suite/request_logger/request.rb +19 -0
- data/lib/dev_suite/request_logger/request_logger.rb +32 -0
- data/lib/dev_suite/request_logger/response.rb +28 -0
- data/lib/dev_suite/request_logger.rb +7 -0
- data/lib/dev_suite/utils/color/color.rb +12 -0
- data/lib/dev_suite/utils/color/config/config.rb +13 -0
- data/lib/dev_suite/utils/color/config/configuration.rb +31 -0
- data/lib/dev_suite/utils/color/config.rb +2 -31
- 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/theme.rb +6 -7
- data/lib/dev_suite/utils/color/strategy.rb +1 -21
- data/lib/dev_suite/utils/color.rb +1 -4
- 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/component.rb +11 -0
- 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 +24 -0
- data/lib/dev_suite/utils/construct/config/attribute/validator.rb +55 -0
- data/lib/dev_suite/utils/construct/config/attribute.rb +13 -0
- data/lib/dev_suite/utils/construct/config/base.rb +25 -0
- data/lib/dev_suite/utils/construct/config/config.rb +16 -0
- data/lib/dev_suite/utils/construct/config/dependency_handler.rb +56 -0
- data/lib/dev_suite/utils/construct/config/hook/hook.rb +22 -0
- 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/hook/manager.rb +36 -0
- data/lib/dev_suite/utils/construct/config/hook.rb +13 -0
- data/lib/dev_suite/utils/construct/config/manager.rb +41 -0
- data/lib/dev_suite/utils/construct/config/settings/base.rb +59 -0
- data/lib/dev_suite/utils/construct/config/settings/manager.rb +38 -0
- data/lib/dev_suite/utils/construct/config/settings/settings.rb +14 -0
- data/lib/dev_suite/utils/construct/config/settings.rb +13 -0
- data/lib/dev_suite/utils/construct/config.rb +11 -0
- data/lib/dev_suite/utils/construct/construct.rb +10 -0
- data/lib/dev_suite/utils/construct.rb +16 -0
- data/lib/dev_suite/utils/dependency_loader.rb +71 -0
- data/lib/dev_suite/utils/emoji.rb +71 -0
- data/lib/dev_suite/utils/error_handler.rb +24 -0
- data/lib/dev_suite/utils/file_loader/config/config.rb +13 -0
- data/lib/dev_suite/utils/file_loader/config/configuration.rb +33 -0
- data/lib/dev_suite/utils/file_loader/config.rb +11 -0
- data/lib/dev_suite/utils/file_loader/file_loader.rb +23 -0
- data/lib/dev_suite/utils/file_loader/loader/base.rb +21 -0
- data/lib/dev_suite/utils/file_loader/loader/json.rb +21 -0
- data/lib/dev_suite/utils/file_loader/loader/loader.rb +41 -0
- data/lib/dev_suite/utils/file_loader/loader/text.rb +21 -0
- data/lib/dev_suite/utils/file_loader/loader/yaml.rb +38 -0
- data/lib/dev_suite/utils/file_loader/loader.rb +13 -0
- data/lib/dev_suite/utils/file_loader/loader_manager.rb +34 -0
- data/lib/dev_suite/utils/file_loader/loader_registry.rb +36 -0
- data/lib/dev_suite/utils/file_loader.rb +9 -0
- data/lib/dev_suite/utils/logger.rb +58 -0
- data/lib/dev_suite/utils/path_matcher/matcher.rb +31 -0
- data/lib/dev_suite/utils/path_matcher/path_matcher.rb +17 -0
- data/lib/dev_suite/utils/path_matcher/pattern.rb +35 -0
- data/lib/dev_suite/utils/path_matcher.rb +9 -0
- data/lib/dev_suite/utils/table/config/config.rb +13 -0
- data/lib/dev_suite/utils/table/config/configuration.rb +32 -0
- data/lib/dev_suite/utils/table/config.rb +2 -23
- 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 -7
- data/lib/dev_suite/utils/table/renderer/renderer.rb +16 -0
- data/lib/dev_suite/utils/table/renderer/simple.rb +9 -5
- data/lib/dev_suite/utils/table/renderer.rb +1 -13
- data/lib/dev_suite/utils/table/table.rb +6 -0
- data/lib/dev_suite/utils/table.rb +0 -6
- data/lib/dev_suite/utils/utils.rb +15 -0
- data/lib/dev_suite/utils.rb +1 -3
- data/lib/dev_suite/version.rb +3 -1
- data/lib/dev_suite.rb +1 -10
- metadata +101 -44
- data/lib/dev_suite/directory_tree/settings.rb +0 -18
- data/lib/dev_suite/emoji.rb +0 -33
- data/lib/dev_suite/error_handler.rb +0 -22
- data/lib/dev_suite/logger.rb +0 -56
- data/lib/dev_suite/performance/reportor.rb +0 -22
- data/lib/dev_suite/utils/config_tools/configuration.rb +0 -134
- data/lib/dev_suite/utils/config_tools/settings.rb +0 -67
- data/lib/dev_suite/utils/config_tools.rb +0 -10
- 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,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
|