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,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Settings
8
+ class Base
9
+ def initialize(settings = {})
10
+ @default_settings = settings
11
+ @settings = merge_settings(@default_settings, settings)
12
+ end
13
+
14
+ def set(*keys, value)
15
+ key_path = normalize_keys(keys)
16
+ last_key = key_path.pop
17
+ target = key_path.each_with_object(@settings) do |key, nested|
18
+ nested[key] ||= {}
19
+ end
20
+ target[last_key] = value
21
+ end
22
+
23
+ def get(*keys)
24
+ key_path = normalize_keys(keys)
25
+ key_path.reduce(@settings) do |nested, key|
26
+ nested.is_a?(Hash) ? nested[key] : nil
27
+ end
28
+ end
29
+
30
+ def reset!
31
+ @settings = @default_settings
32
+ end
33
+
34
+ private
35
+
36
+ def normalize_keys(keys)
37
+ key_path = keys.flatten
38
+ if key_path.size == 1 && key_path.first.is_a?(String)
39
+ key_path.first.to_s.split(".").map(&:to_sym)
40
+ else
41
+ key_path.map(&:to_sym)
42
+ end
43
+ end
44
+
45
+ def merge_settings(defaults, overrides)
46
+ defaults.merge(overrides) do |_key, oldval, newval|
47
+ if oldval.is_a?(Hash) && newval.is_a?(Hash)
48
+ merge_settings(oldval, newval)
49
+ else
50
+ newval
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Settings
8
+ module Manager
9
+ class << self
10
+ def included(base)
11
+ base.extend(ClassMethods)
12
+ end
13
+ end
14
+
15
+ module ClassMethods
16
+ # Ensure that default configuration attributes are applied to subclasses.
17
+ def inherited(subclass)
18
+ subclass.set_default_settings
19
+ super
20
+ end
21
+
22
+ # Define default settings for the class.
23
+ def set_default_settings(settings = {})
24
+ config_attr(:settings, default_value: settings, type: :hash, resolver: :resolve_settings)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def resolve_settings(value)
31
+ Base.new(value)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ module Settings
8
+ require_relative "base"
9
+ require_relative "manager"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ 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 Settings
8
+ require_relative "settings/settings"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ module Config
7
+ require_relative "config/config"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ require_relative "config"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Construct
6
+ # The Construct module serves as a namespace for reusable constructs that
7
+ # provide foundational utilities, such as configuration management, which
8
+ # can be included in other modules throughout the DevSuite framework.
9
+ #
10
+ # This module centralizes shared functionality to promote code reuse,
11
+ # maintainability, and consistency across different modules.
12
+
13
+ require_relative "construct/construct"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Emoji
6
+ # Status-related emojis
7
+ STATUS = {
8
+ start: "🚀",
9
+ success: "✅",
10
+ error: "🚨❌",
11
+ retry: "💥",
12
+ warning: "⚠️", # For warnings
13
+ caution: "🟡", # For caution or proceed with care
14
+ }.freeze
15
+
16
+ # Action-related emojis
17
+ ACTIONS = {
18
+ update: "🔄", # For updates or changes
19
+ fix: "🔧", # For fixes or repairs
20
+ bug: "🐞", # For bugs or issues
21
+ code: "💻", # For code or technical content
22
+ }.freeze
23
+
24
+ # Notification-related emojis
25
+ NOTIFICATIONS = {
26
+ info: "ℹ️",
27
+ important: "❗",
28
+ note: "📝", # For notes or annotations
29
+ tip: "💡", # For tips or helpful hints
30
+ }.freeze
31
+
32
+ # Resource-related emojis
33
+ RESOURCES = {
34
+ document: "📄", # For representing documents or files
35
+ network: "🌐", # For network-related logs
36
+ database: "💾", # For database-related logs
37
+ cache: "🗄️", # For cache-related logs
38
+ file: "📁", # For file-related logs
39
+ cookie: "🍪", # For cookie-related logs
40
+ header: "📑", # For header-related logs
41
+ request: "📤", # For request-related logs
42
+ response: "📥", # For response-related logs
43
+ }.freeze
44
+
45
+ DEFAULT_EMOJI = "❓"
46
+
47
+ EMOJIS = STATUS.merge(ACTIONS).merge(NOTIFICATIONS).merge(RESOURCES).freeze
48
+
49
+ class << self
50
+ # Returns the emoji corresponding to the given key.
51
+ # @param key [Symbol] the key to look up the emoji
52
+ # @param default [String] the default emoji if the key is not found
53
+ # @return [String] the corresponding emoji or the default emoji
54
+ def get(key, default: DEFAULT_EMOJI)
55
+ EMOJIS[key] || default
56
+ end
57
+
58
+ # Returns all emojis categorized by their purpose.
59
+ # @return [Hash] a hash containing all emojis organized by categories.
60
+ def all
61
+ {
62
+ status: STATUS,
63
+ actions: ACTIONS,
64
+ notifications: NOTIFICATIONS,
65
+ resources: RESOURCES,
66
+ }
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module ErrorHandler
6
+ extend self # This makes all instance methods behave like class methods
7
+
8
+ def handle_error(error)
9
+ Utils::Logger.log(
10
+ "Oops! An error occurred: #{error.message}",
11
+ level: :error,
12
+ emoji: :error,
13
+ )
14
+ Utils::Logger.log(
15
+ "For more information, please refer to the README: " \
16
+ "https://github.com/patrick204nqh/dev_suite",
17
+ level: :error,
18
+ emoji: :document,
19
+ )
20
+ # exit(1)
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 FileLoader
6
+ module Config
7
+ include Construct::Config
8
+
9
+ require_relative "configuration"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ module Config
7
+ class Configuration < BaseConfiguration
8
+ config_attr :loaders, default_value: [:text, :json, :yaml], type: :array
9
+
10
+ register_hook :after_initialize do
11
+ setup_registry
12
+ end
13
+
14
+ # Expose the registry as a read-only attribute
15
+ attr_reader :registry
16
+
17
+ # Setup the registry based on the current loaders
18
+ def setup_registry
19
+ @registry = LoaderRegistry.new
20
+ update_registry(loaders)
21
+ end
22
+
23
+ # Update the registry with the provided loaders
24
+ def update_registry(loaders)
25
+ @registry ||= LoaderRegistry.new
26
+ @registry.clear # Clear the existing registry
27
+ Loader.registry_loaders(@registry, loaders)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ module Config
7
+ require_relative "config/config"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ require "pathname"
7
+ require "json"
8
+ require "yaml"
9
+
10
+ require_relative "loader"
11
+ require_relative "loader_registry"
12
+ require_relative "loader_manager"
13
+ require_relative "config"
14
+
15
+ class << self
16
+ def load(path)
17
+ loader = LoaderManager.new
18
+ loader.load(path)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ module Loader
7
+ class Base
8
+ class << self
9
+ def extensions
10
+ raise NotImplementedError, "You must implement the extensions method"
11
+ end
12
+ end
13
+
14
+ def load(_path)
15
+ raise NotImplementedError, "You must implement the load method"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ module Loader
7
+ class Json < Base
8
+ class << self
9
+ def extensions
10
+ ["json"]
11
+ end
12
+ end
13
+
14
+ def load(path)
15
+ ::JSON.parse(::File.read(path))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ module Loader
7
+ class Text < Base
8
+ class << self
9
+ def extensions
10
+ ["txt"]
11
+ end
12
+ end
13
+
14
+ def load(path)
15
+ ::File.read(path)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ module Loader
7
+ class Yaml < Base
8
+ class << self
9
+ def extensions
10
+ ["yml", "yaml"]
11
+ end
12
+ end
13
+
14
+ def load(path, safe: true)
15
+ validate_file_existence!(path)
16
+ parse_yaml_file(path, safe)
17
+ rescue ::Psych::SyntaxError => e
18
+ handle_yaml_parsing_error(path, e)
19
+ end
20
+
21
+ private
22
+
23
+ def validate_file_existence!(path)
24
+ raise "File not found: #{path}" unless ::File.exist?(path)
25
+ end
26
+
27
+ def parse_yaml_file(path, safe)
28
+ safe ? ::YAML.safe_load_file(path) : ::YAML.load_file(path)
29
+ end
30
+
31
+ def handle_yaml_parsing_error(path, error)
32
+ raise "YAML parsing error in file #{path}: #{error.message}"
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -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 "loader/base"
8
+ require_relative "loader/text"
9
+ require_relative "loader/json"
10
+ require_relative "loader/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
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ class LoaderManager
7
+ def load(path)
8
+ loader = find_loader_for(path)
9
+ loader.load(path)
10
+ end
11
+
12
+ private
13
+
14
+ def find_loader_for(path)
15
+ extension = extract_extension(path)
16
+ loader = registry.find_loader(extension)
17
+ raise LoaderNotFoundError, "No loader registered for #{extension}" unless loader
18
+
19
+ loader
20
+ end
21
+
22
+ def extract_extension(path)
23
+ ::File.extname(path).delete_prefix(".")
24
+ end
25
+
26
+ def registry
27
+ Config.configuration.registry
28
+ end
29
+ end
30
+
31
+ class LoaderNotFoundError < StandardError; end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ class LoaderRegistry
7
+ def initialize
8
+ @registry = {}
9
+ end
10
+
11
+ def register(loader_class)
12
+ loader = loader_class.new
13
+ loader_class.extensions.each do |ext|
14
+ @registry[ext] = loader
15
+ end
16
+ end
17
+
18
+ def clear
19
+ @registry.clear
20
+ end
21
+
22
+ def find_loader(extension)
23
+ @registry[extension]
24
+ end
25
+
26
+ def registered_extensions
27
+ @registry.keys
28
+ end
29
+
30
+ def registered_loaders
31
+ @registry.values.uniq
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module FileLoader
6
+ require_relative "file_loader/file_loader"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module Logger
6
+ LOG_DETAILS = {
7
+ info: { prefix: "[INFO]", color: :green },
8
+ warn: { prefix: "[WARNING]", color: :yellow },
9
+ error: { prefix: "[ERROR]", color: :red },
10
+ debug: { prefix: "[DEBUG]", color: :blue },
11
+ }.freeze
12
+
13
+ class << self
14
+ # Logs a message with an optional emoji and specified log level.
15
+ #
16
+ # @param message [String] The message to log.
17
+ # @param level [Symbol] The log level (:info, :warn, :error, :debug).
18
+ # @param emoji [String, Symbol] Optional emoji to prepend to the message.
19
+ def log(message, level: :info, emoji: nil)
20
+ emoji_icon = resolve_emoji(emoji)
21
+ formatted_message = format_message("#{emoji_icon} #{message}", level)
22
+ output_log(formatted_message)
23
+ end
24
+
25
+ private
26
+
27
+ # Resolves the emoji, either from a symbol or directly as a string.
28
+ #
29
+ # @param emoji [String, Symbol, nil] The emoji or its symbol key.
30
+ # @return [String] The resolved emoji or an empty string if none is provided.
31
+ def resolve_emoji(emoji)
32
+ return "" unless emoji
33
+
34
+ emoji.is_a?(Symbol) ? Emoji.get(emoji) : emoji
35
+ end
36
+
37
+ # Formats the log message with the appropriate prefix and color.
38
+ #
39
+ # @param message [String] The message to format.
40
+ # @param level [Symbol] The log level (:info, :warn, :error, :debug).
41
+ # @return [String] The formatted log message.
42
+ def format_message(message, level)
43
+ details = LOG_DETAILS[level]
44
+ raise ArgumentError, "Invalid log level: #{level}" unless details
45
+
46
+ Utils::Color.colorize("#{details[:prefix]} #{message}", color: details[:color])
47
+ end
48
+
49
+ # Outputs the formatted log message to the console.
50
+ #
51
+ # @param formatted_message [String] The message to output.
52
+ def output_log(formatted_message)
53
+ puts formatted_message if formatted_message
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module PathMatcher
6
+ class Matcher
7
+ def initialize(includes: [], excludes: [])
8
+ @include_patterns = includes.map { |pattern| Pattern.new(pattern) }
9
+ @exclude_patterns = excludes.map { |pattern| Pattern.new(pattern) }
10
+ end
11
+
12
+ def match?(path)
13
+ return false if excluded?(path)
14
+ return true if included?(path)
15
+
16
+ false
17
+ end
18
+
19
+ private
20
+
21
+ def included?(path)
22
+ @include_patterns.empty? || @include_patterns.any? { |pattern| pattern.match?(path) }
23
+ end
24
+
25
+ def excluded?(path)
26
+ @exclude_patterns.any? { |pattern| pattern.match?(path) }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Utils
5
+ module PathMatcher
6
+ require_relative "pattern"
7
+ require_relative "matcher"
8
+
9
+ class << self
10
+ def match?(path, includes: [], excludes: [])
11
+ matcher = Matcher.new(includes: includes, excludes: excludes)
12
+ matcher.match?(path)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end