dev_suite 0.2.5 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) 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 +4 -1
  7. data/Gemfile.lock +28 -2
  8. data/README.md +39 -31
  9. data/bin/rspec +27 -0
  10. data/lib/dev_suite/directory_tree/builder/base.rb +1 -1
  11. data/lib/dev_suite/directory_tree/builder/builder.rb +13 -0
  12. data/lib/dev_suite/directory_tree/builder.rb +1 -12
  13. data/lib/dev_suite/directory_tree/config/config.rb +1 -1
  14. data/lib/dev_suite/directory_tree/config/configuration.rb +18 -5
  15. data/lib/dev_suite/directory_tree/directory_tree.rb +0 -2
  16. data/lib/dev_suite/directory_tree/node/node.rb +12 -0
  17. data/lib/dev_suite/directory_tree/node.rb +1 -4
  18. data/lib/dev_suite/directory_tree/renderer/base.rb +1 -1
  19. data/lib/dev_suite/directory_tree/renderer/renderer.rb +14 -0
  20. data/lib/dev_suite/directory_tree/renderer.rb +1 -13
  21. data/lib/dev_suite/directory_tree/visualizer/base.rb +1 -1
  22. data/lib/dev_suite/directory_tree/visualizer/visualizer.rb +16 -0
  23. data/lib/dev_suite/directory_tree/visualizer.rb +1 -15
  24. data/lib/dev_suite/performance/config/config.rb +1 -1
  25. data/lib/dev_suite/performance/config/configuration.rb +3 -3
  26. data/lib/dev_suite/performance/data/data.rb +9 -0
  27. data/lib/dev_suite/performance/data.rb +1 -1
  28. data/lib/dev_suite/performance/profiler/base.rb +1 -1
  29. data/lib/dev_suite/performance/profiler/profiler.rb +16 -0
  30. data/lib/dev_suite/performance/profiler.rb +1 -20
  31. data/lib/dev_suite/performance/profiler_manager.rb +1 -0
  32. data/lib/dev_suite/performance/reporter/base.rb +1 -1
  33. data/lib/dev_suite/performance/reporter/reporter.rb +15 -0
  34. data/lib/dev_suite/performance/reporter.rb +1 -14
  35. data/lib/dev_suite/request_logger/adapter/adapter.rb +16 -12
  36. data/lib/dev_suite/request_logger/adapter/base.rb +1 -1
  37. data/lib/dev_suite/request_logger/adapter/faraday.rb +37 -0
  38. data/lib/dev_suite/request_logger/adapter/middleware/faraday.rb +22 -0
  39. data/lib/dev_suite/request_logger/adapter/net_http.rb +1 -0
  40. data/lib/dev_suite/request_logger/adapter.rb +1 -1
  41. data/lib/dev_suite/request_logger/config/config.rb +1 -1
  42. data/lib/dev_suite/request_logger/config/configuration.rb +2 -2
  43. data/lib/dev_suite/request_logger/extractor/base.rb +17 -0
  44. data/lib/dev_suite/request_logger/extractor/extractor.rb +22 -0
  45. data/lib/dev_suite/request_logger/extractor/faraday.rb +37 -0
  46. data/lib/dev_suite/request_logger/extractor/net_http.rb +36 -0
  47. data/lib/dev_suite/request_logger/extractor.rb +9 -0
  48. data/lib/dev_suite/request_logger/logger.rb +22 -28
  49. data/lib/dev_suite/request_logger/request.rb +19 -0
  50. data/lib/dev_suite/request_logger/request_logger.rb +3 -0
  51. data/lib/dev_suite/request_logger/response.rb +28 -0
  52. data/lib/dev_suite/utils/color/config/config.rb +1 -1
  53. data/lib/dev_suite/utils/color/config/configuration.rb +3 -3
  54. data/lib/dev_suite/utils/color/palette/base.rb +1 -14
  55. data/lib/dev_suite/utils/color/palette/palette.rb +16 -0
  56. data/lib/dev_suite/utils/color/palette.rb +1 -13
  57. data/lib/dev_suite/utils/color/strategy/base.rb +1 -1
  58. data/lib/dev_suite/utils/color/strategy/strategy.rb +20 -0
  59. data/lib/dev_suite/utils/color/strategy.rb +1 -19
  60. data/lib/dev_suite/utils/construct/component/base.rb +30 -0
  61. data/lib/dev_suite/utils/construct/component/component.rb +12 -0
  62. data/lib/dev_suite/utils/construct/component/initializer.rb +28 -0
  63. data/lib/dev_suite/utils/construct/component/manager.rb +57 -0
  64. data/lib/dev_suite/utils/construct/{config/configuration.rb → component.rb} +2 -4
  65. data/lib/dev_suite/utils/construct/config/attribute/attr_definition.rb +76 -0
  66. data/lib/dev_suite/utils/construct/config/attribute/attr_initialization.rb +22 -0
  67. data/lib/dev_suite/utils/construct/config/attribute/attr_resolving.rb +80 -0
  68. data/lib/dev_suite/utils/construct/config/attribute/attribute.rb +12 -3
  69. data/lib/dev_suite/utils/construct/config/base.rb +7 -2
  70. data/lib/dev_suite/utils/construct/config/config.rb +2 -10
  71. data/lib/dev_suite/utils/construct/config/dependency_handler.rb +56 -0
  72. data/lib/dev_suite/utils/construct/config/hook/hook.rb +10 -1
  73. data/lib/dev_suite/utils/construct/config/hook/hook_registry.rb +24 -0
  74. data/lib/dev_suite/utils/construct/config/hook/hook_runner.rb +20 -0
  75. data/lib/dev_suite/utils/construct/config/manager.rb +25 -17
  76. data/lib/dev_suite/utils/construct/construct.rb +1 -0
  77. data/lib/dev_suite/utils/dependency_loader.rb +71 -0
  78. data/lib/dev_suite/utils/file_loader/config/config.rb +1 -1
  79. data/lib/dev_suite/utils/file_loader/config/configuration.rb +1 -1
  80. data/lib/dev_suite/utils/file_loader/loader/base.rb +1 -1
  81. data/lib/dev_suite/utils/file_loader/loader/loader.rb +41 -0
  82. data/lib/dev_suite/utils/file_loader/loader.rb +2 -30
  83. data/lib/dev_suite/utils/table/config/config.rb +1 -1
  84. data/lib/dev_suite/utils/table/config/configuration.rb +2 -2
  85. data/lib/dev_suite/utils/table/formatter/formatter.rb +12 -0
  86. data/lib/dev_suite/utils/table/formatter.rb +1 -2
  87. data/lib/dev_suite/utils/table/renderer/base.rb +1 -1
  88. data/lib/dev_suite/utils/table/renderer/renderer.rb +16 -0
  89. data/lib/dev_suite/utils/table/renderer.rb +1 -13
  90. data/lib/dev_suite/utils/utils.rb +1 -0
  91. data/lib/dev_suite/version.rb +3 -1
  92. metadata +39 -6
  93. data/lib/dev_suite/utils/construct/config/attribute/manager.rb +0 -63
  94. data/lib/dev_suite/utils/construct/config/attribute/resolver.rb +0 -31
  95. data/lib/dev_suite/utils/construct/config/initializer.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d90d0f33e4d0651dbc5ed388a62c7c0b3a665cb27db805631d8771245b21129e
4
- data.tar.gz: e87b028766648877eea33d3c2910d3879510a50d4425fd9b19bf96212cb141a7
3
+ metadata.gz: 1a7188e92386a13da83abc637b7446d68c485eff8e6e2198a53f88360ac13f02
4
+ data.tar.gz: f76c576284ba7b90bc671a389cd6e43065079f04ae19567b0e633a147e2b2276
5
5
  SHA512:
6
- metadata.gz: c7a4fdb6138b2c9e75bafa923f095479827d58c229fdc60f2ae8c2b5e2a6a04f8e39c6ed27cf26ab3c53a62f606c5931c851698c1b577f6bdb1bad45289b344e
7
- data.tar.gz: 1d10bd660e02d4100ee58fb7607626cfaf2ef714811a9407d25ae12f9fe71ae3ed9fd36d8b21de8bdba6b288223ed9a8b58ae22deb6e3ac297d24692e90ca86e
6
+ metadata.gz: b565a159f2aee25115301ae629dcd2e44e844005586c2505e92cd18f75f9845a856c16f8db1c5a309eb249f645ba1e90b6c36ca4e0958f6106f39d0d86f7434a
7
+ data.tar.gz: 7a34933bf806f8e3fb09351b200698da8d6f5568fefc3054f7ba0591c939dc264b9962c77cd56b6f01e5304b2bb60e5301885f33f34b05bebd54858046cb1e73
data/.rubocop.yml CHANGED
@@ -5,13 +5,12 @@ AllCops:
5
5
  NewCops: enable
6
6
  TargetRubyVersion: 2.7
7
7
  Exclude:
8
+ - '.git/**/*'
8
9
  - 'bin/**/*'
9
- - 'db/schema.rb'
10
10
  - 'node_modules/**/*'
11
- - 'vendor/**/*'
12
- - 'spec/**/*'
13
- - 'test/**/*'
14
- - 'lib/dev_suite/version.rb'
11
+ - 'coverage/**/*'
12
+ - 'tmp/**/*'
13
+ - 'log/**/*'
15
14
 
16
15
  Metrics/LineLength:
17
16
  Max: 120
@@ -0,0 +1,8 @@
1
+ {
2
+ "recommendations": [
3
+ "Shopify.ruby-lsp",
4
+ "misogi.ruby-rubocop",
5
+ "KoichiSasada.vscode-rdbg",
6
+ "streetsidesoftware.code-spell-checker",
7
+ ]
8
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug all tests",
6
+ "type": "rdbg",
7
+ "request": "launch",
8
+ "useBundler": true,
9
+ "script": "${workspaceFolder}/bin/rspec",
10
+ "args": [
11
+ "--color",
12
+ "--require",
13
+ "rspec",
14
+ "--format",
15
+ "progress",
16
+ "${workspaceFolder}/spec"
17
+ ],
18
+ "useTerminal": false,
19
+ "env": { "DEBUG": "true" }
20
+ },
21
+ {
22
+ "name": "Debug current line",
23
+ "type": "rdbg",
24
+ "request": "launch",
25
+ "useBundler": true,
26
+ "script": "${workspaceFolder}/bin/rspec",
27
+ "args": [
28
+ "--color",
29
+ "--require",
30
+ "rspec",
31
+ "--format",
32
+ "progress",
33
+ "${file}:${lineNumber}"
34
+ ],
35
+ "useTerminal": false,
36
+ "env": { "DEBUG": "true" }
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "[ruby]": {
3
+ "editor.defaultFormatter": "Shopify.ruby-lsp", // Use the Ruby LSP as the default formatter
4
+ "editor.formatOnSave": true, // Format files automatically when saving
5
+ "editor.tabSize": 2, // Use 2 spaces for indentation
6
+ "editor.insertSpaces": true, // Use spaces and not tabs for indentation
7
+ "editor.semanticHighlighting.enabled": true, // Enable semantic highlighting
8
+ "editor.formatOnType": true // Enable formatting while typing
9
+ },
10
+ "rubyLsp.enabledFeatures": {
11
+ "codeActions": true,
12
+ "diagnostics": true,
13
+ "documentHighlights": true,
14
+ "documentLink": true,
15
+ "documentSymbols": true,
16
+ "foldingRanges": true,
17
+ "formatting": true,
18
+ "hover": true,
19
+ "inlayHint": true,
20
+ "onTypeFormatting": true,
21
+ "selectionRanges": true,
22
+ "semanticHighlighting": true,
23
+ "completion": true,
24
+ "codeLens": true
25
+ },
26
+ "rubyLsp.formatter": "rubocop", // Use RuboCop for formatting within Ruby LSP
27
+ "ruby.rubocop.configFilePath": ".rubocop.yml" // Use the .rubocop.yml file in the root of the project
28
+ }
data/Gemfile CHANGED
@@ -5,15 +5,18 @@ source "https://rubygems.org"
5
5
  # Use the gemspec method to include dependencies specified in the gemspec file
6
6
  gemspec
7
7
 
8
+ # Additional runtime dependencies
9
+ gem "faraday", "~> 1.4"
10
+
8
11
  # Additional development tools not required as part of the gem's runtime
9
12
  group :development, :test do
10
13
  gem "rspec", "~> 3.9"
11
14
  gem "simplecov", "~> 0.21"
12
15
  gem "rake", "~> 13.0"
13
- gem "pry", "~> 0.14"
14
16
  end
15
17
 
16
18
  group :development do
19
+ gem "pry", "~> 0.14"
17
20
  gem "rubocop", "~> 1.65", require: false
18
21
  gem "rubocop-shopify", "~> 2.15", require: false
19
22
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dev_suite (0.2.5)
4
+ dev_suite (0.2.7)
5
5
  benchmark (~> 0.1)
6
6
  get_process_mem (~> 1.0)
7
7
  thor (~> 1.1)
@@ -15,6 +15,29 @@ GEM
15
15
  coderay (1.1.3)
16
16
  diff-lcs (1.5.1)
17
17
  docile (1.4.1)
18
+ faraday (1.10.3)
19
+ faraday-em_http (~> 1.0)
20
+ faraday-em_synchrony (~> 1.0)
21
+ faraday-excon (~> 1.1)
22
+ faraday-httpclient (~> 1.0)
23
+ faraday-multipart (~> 1.0)
24
+ faraday-net_http (~> 1.0)
25
+ faraday-net_http_persistent (~> 1.0)
26
+ faraday-patron (~> 1.0)
27
+ faraday-rack (~> 1.0)
28
+ faraday-retry (~> 1.0)
29
+ ruby2_keywords (>= 0.0.4)
30
+ faraday-em_http (1.0.0)
31
+ faraday-em_synchrony (1.0.0)
32
+ faraday-excon (1.1.0)
33
+ faraday-httpclient (1.0.1)
34
+ faraday-multipart (1.0.4)
35
+ multipart-post (~> 2)
36
+ faraday-net_http (1.0.2)
37
+ faraday-net_http_persistent (1.2.0)
38
+ faraday-patron (1.0.0)
39
+ faraday-rack (1.0.0)
40
+ faraday-retry (1.0.3)
18
41
  ffi (1.17.0)
19
42
  ffi (1.17.0-aarch64-linux-gnu)
20
43
  ffi (1.17.0-aarch64-linux-musl)
@@ -32,6 +55,7 @@ GEM
32
55
  json (2.7.2)
33
56
  language_server-protocol (3.17.0.3)
34
57
  method_source (1.1.0)
58
+ multipart-post (2.4.1)
35
59
  parallel (1.25.1)
36
60
  parser (3.3.4.1)
37
61
  ast (~> 2.4.1)
@@ -43,7 +67,7 @@ GEM
43
67
  rainbow (3.1.1)
44
68
  rake (13.2.1)
45
69
  regexp_parser (2.9.2)
46
- rexml (3.3.4)
70
+ rexml (3.3.6)
47
71
  strscan
48
72
  rspec (3.13.0)
49
73
  rspec-core (~> 3.13.0)
@@ -74,6 +98,7 @@ GEM
74
98
  rubocop-shopify (2.15.1)
75
99
  rubocop (~> 1.51)
76
100
  ruby-progressbar (1.13.0)
101
+ ruby2_keywords (0.0.5)
77
102
  simplecov (0.22.0)
78
103
  docile (~> 1.1)
79
104
  simplecov-html (~> 0.11)
@@ -99,6 +124,7 @@ PLATFORMS
99
124
 
100
125
  DEPENDENCIES
101
126
  dev_suite!
127
+ faraday (~> 1.4)
102
128
  pry (~> 0.14)
103
129
  rake (~> 13.0)
104
130
  rspec (~> 3.9)
data/README.md CHANGED
@@ -57,15 +57,13 @@ DevSuite also provides a command-line interface for various utilities. Below are
57
57
  ## Features Overview
58
58
 
59
59
  ### Performance Analysis
60
+ Analyze the performance of Ruby code blocks, capturing metrics like execution time and memory usage.
61
+
60
62
  <details>
61
63
  <summary>Show more</summary>
62
64
 
63
- **Purpose**: Quickly analyze the performance of Ruby code blocks, capturing metrics like execution time and memory usage.
64
-
65
65
  **How to Use**:
66
66
  ```ruby
67
- require 'dev_suite'
68
-
69
67
  DevSuite::Performance.analyze(description: "Example Analysis") do
70
68
  sum = 0
71
69
  1_000_000.times { |i| sum += i }
@@ -88,15 +86,13 @@ DevSuite also provides a command-line interface for various utilities. Below are
88
86
  </details>
89
87
 
90
88
  ### Directory Tree Visualization
89
+ Visualize the file structure of directories and subdirectories to better understand project organization.
90
+
91
91
  <details>
92
92
  <summary>Show more</summary>
93
93
 
94
- **Purpose**: Visualize the file structure of directories and subdirectories to better understand project organization.
95
-
96
94
  **How to Use**:
97
95
  ```ruby
98
- require 'dev_suite'
99
-
100
96
  # Define the directory path
101
97
  base_path = "/path/to/your/directory"
102
98
 
@@ -154,15 +150,13 @@ DevSuite also provides a command-line interface for various utilities. Below are
154
150
  </details>
155
151
 
156
152
  ### Request Logging
153
+ Log detailed HTTP requests and responses across different adapters like Net::HTTP and Faraday for debugging and monitoring
154
+
157
155
  <details>
158
156
  <summary>Show more</summary>
159
157
 
160
- **Purpose**: The `RequestLogger` feature enables detailed logging of HTTP requests and responses across different adapters (e.g., `Net::HTTP`, `Faraday`). This can be useful for debugging, monitoring, and auditing API interactions.
161
-
162
158
  **How to Use**:
163
159
  ```ruby
164
- require 'dev_suite'
165
-
166
160
  DevSuite::RequestLogger.with_logging do
167
161
  # Make an HTTP request using Net::HTTP
168
162
  uri = URI('https://jsonplaceholder.typicode.com/posts')
@@ -173,36 +167,50 @@ DevSuite also provides a command-line interface for various utilities. Below are
173
167
  **Configuration Guide**:
174
168
  Customize the request logging behavior by setting configuration options:
175
169
  ```ruby
176
- DevSuite::RequestLogger.configure do |config|
170
+ DevSuite::RequestLogger::Config.configure do |config|
177
171
  config.adapters = [:net_http]
178
- ...
172
+ config.settings.set(:log_level, :debug)
173
+ config.settings.set(:log_headers, true)
174
+ config.settings.set(:log_cookies, true)
175
+ config.settings.set(:log_body, true)
179
176
  end
180
177
  ```
181
178
 
182
179
  **Configuration Options**:
183
180
 
184
- Below is a table describing the available configuration settings:
181
+ Below is a table describing the general configuration options available:
185
182
 
186
- | Setting | Description | Example Values |
187
- |----------------|----------------------------------------------------|------------------------------------|
188
- | `:adapters` | List of adapters for which logging is enabled. | `[:net_http, :faraday]` |
189
- <!-- | `:log_level` | Set the logging level (e.g., info, debug). | `:info`, `:debug`, `:warn`, `:error` |
190
- | `:log_response` | Enable or disable response logging. | `true`, `false` |
191
- | `:log_emoji` | Customize emojis for request and response logs. | `{ request: :globe, response: :envelope }` | -->
183
+ | Setting | Description | Default Value | Example Values |
184
+ |----------------|-------------------------------------------------------|---------------|------------------------------------|
185
+ | `:adapters` | List of adapters for which logging is enabled. | `[:net_http]` | `[:net_http, :faraday]` |
192
186
 
193
- **Adapters Supported**:
194
-
195
- The `RequestLogger` currently supports the following adapters:
196
-
197
- | Adapter | Description | Example Usage |
198
- |--------------|--------------------------------------------|---------------------------------------------------|
199
- | `Net::HTTP` | Logs requests made with the Net::HTTP class.| `DevSuite::RequestLogger::Adapter::NetHttp.new(config)` |
200
- <!-- | `Faraday` | Logs requests made with the Faraday gem. | `DevSuite::RequestLogger::Adapter::Faraday.new(config)` | -->
187
+ **Settings Options**:
188
+
189
+ The `settings` key allows you to customize various logging behaviors. Below is a table describing these settings:
190
+
191
+ | Setting | Description | Default Value | Example Values |
192
+ |----------------|-------------------------------------------------------|---------------|------------------------------------|
193
+ | `:log_level` | Set the logging level. | `:debug` | `:info`, `:debug`, `:warn`, `:error` |
194
+ | `:log_headers` | Enable or disable logging of HTTP headers. | `true` | `true`, `false` |
195
+ | `:log_cookies` | Enable or disable logging of cookies. | `true` | `true`, `false` |
196
+ | `:log_body` | Enable or disable logging of HTTP bodies. | `true` | `true`, `false` |
201
197
 
202
198
  **Sample Output**:
203
199
  ```bash
204
- [INFO] 🌐 Net::HTTP Request: GET http://example.com
205
- [DEBUG] 📄 Net::HTTP Response: 200 OK
200
+ [DEBUG] 🚀 Net::HTTP Request: GET https://jsonplaceholder.typicode.com/posts
201
+ [DEBUG] 📄 Headers: {"accept-encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "accept"=>"*/*", "user-agent"=>"Ruby", "host"=>"jsonplaceholder.typicode.com"}
202
+ [DEBUG] 🍪 Cookies: None
203
+ [DEBUG] ✅ Net::HTTP Response: 200 OK
204
+ [DEBUG] 📄 Headers: {"date"=>"Wed, 21 Aug 2024 10:33:59 GMT", "content-type"=>"application/json; charset=utf-8", "transfer-encoding"=>"chunked", "connection"=>"keep-alive", "report-to"=>"{\"group\":\"heroku-nel\",\"max_age\":3600,\"endpoints\":[{\"url\":\"https://nel.heroku.com/reports?ts=1723379558&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=LYnyHXQQqBH310%2FAbzjH0MN%2BaFoA6Ntqh94a3%2F5J54E%3D\"}]}", "reporting-endpoints"=>"heroku-nel=https://nel.heroku.com/reports?ts=1723379558&sid=e11707d5-02a7-43ef-b45e-2cf4d2036f7d&s=LYnyHXQQqBH310%2FAbzjH0MN%2BaFoA6Ntqh94a3%2F5J54E%3D", "nel"=>"{\"report_to\":\"heroku-nel\",\"max_age\":3600,\"success_fraction\":0.005,\"failure_fraction\":0.05,\"response_headers\":[\"Via\"]}", "x-powered-by"=>"Express", "x-ratelimit-limit"=>"1000", "x-ratelimit-remaining"=>"999", "x-ratelimit-reset"=>"1723379596", "vary"=>"Origin, Accept-Encoding", "access-control-allow-credentials"=>"true", "cache-control"=>"max-age=43200", "pragma"=>"no-cache", "expires"=>"-1", "x-content-type-options"=>"nosniff", "etag"=>"W/\"6b80-Ybsq/K6GwwqrYkAsFxqDXGC7DoM\"", "via"=>"1.1 vegur", "cf-cache-status"=>"HIT", "age"=>"4620", "server"=>"cloudflare", "cf-ray"=>"8b69f7d4ad941fa4-HKG", "alt-svc"=>"h3=\":443\"; ma=86400"}
205
+ [DEBUG] 💻 Response Body: [
206
+ {
207
+ "userId": 1,
208
+ "id": 1,
209
+ "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
210
+ "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
211
+ },
212
+ ...
213
+ ]
206
214
  ```
207
215
  </details>
208
216
 
data/bin/rspec ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("rspec-core", "rspec")
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Builder
6
- class Base
6
+ class Base < Utils::Construct::Component::Base
7
7
  #
8
8
  # Recursive method to build the tree
9
9
  #
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module DirectoryTree
5
+ module Builder
6
+ include Utils::Construct::Component::Manager
7
+
8
+ require_relative "base"
9
+
10
+ register_component(Base)
11
+ end
12
+ end
13
+ end
@@ -3,18 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Builder
6
- require_relative "builder/base"
7
-
8
- class << self
9
- def create(type)
10
- case type
11
- when :base
12
- Base.new
13
- else
14
- raise ArgumentError, "Unknown renderer type: #{type}"
15
- end
16
- end
17
- end
6
+ require_relative "builder/builder"
18
7
  end
19
8
  end
20
9
  end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Config
6
- include Utils::Construct::Config
6
+ include Utils::Construct::Config::Manager
7
7
 
8
8
  require_relative "configuration"
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Config
6
- class Configuration < BaseConfiguration
6
+ class Configuration < Utils::Construct::Config::Base
7
7
  set_default_settings(
8
8
  skip_hidden: false,
9
9
  skip_types: [],
@@ -11,10 +11,23 @@ module DevSuite
11
11
  max_size: 100 * 1024 * 1024, # 100 MB
12
12
  )
13
13
 
14
- # Define configuration attributes
15
- config_attr :builder, default_value: :base, type: :symbol, resolver: ->(value) { Builder.create(value) }
16
- config_attr :renderer, default_value: :simple, type: :symbol, resolver: ->(value) { Renderer.create(value) }
17
- config_attr :visualizer, default_value: :tree, type: :symbol, resolver: ->(value) { Visualizer.create(value) }
14
+ config_attr :builder, default_value: :base, type: :symbol, resolver: :resolve_builder
15
+ config_attr :renderer, default_value: :simple, type: :symbol, resolver: :resolve_renderer
16
+ config_attr :visualizer, default_value: :tree, type: :symbol, resolver: :resolve_visualizer
17
+
18
+ private
19
+
20
+ def resolve_builder(value)
21
+ Builder.build_component(value)
22
+ end
23
+
24
+ def resolve_renderer(value)
25
+ Renderer.build_component(value)
26
+ end
27
+
28
+ def resolve_visualizer(value)
29
+ Visualizer.build_component(value)
30
+ end
18
31
  end
19
32
  end
20
33
  end
@@ -2,8 +2,6 @@
2
2
 
3
3
  module DevSuite
4
4
  module DirectoryTree
5
- require "pathname"
6
-
7
5
  require_relative "node"
8
6
  require_relative "config"
9
7
  require_relative "renderer"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module DirectoryTree
5
+ module Node
6
+ require_relative "base"
7
+ require_relative "file"
8
+ require_relative "directory"
9
+ require_relative "permission_denied"
10
+ end
11
+ end
12
+ end
@@ -3,10 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Node
6
- require_relative "node/base"
7
- require_relative "node/file"
8
- require_relative "node/directory"
9
- require_relative "node/permission_denied"
6
+ require_relative "node/node"
10
7
  end
11
8
  end
12
9
  end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Renderer
6
- class Base
6
+ class Base < Utils::Construct::Component::Base
7
7
  def render
8
8
  raise NotImplementedError
9
9
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module DirectoryTree
5
+ module Renderer
6
+ include Utils::Construct::Component::Manager
7
+
8
+ require_relative "base"
9
+ require_relative "simple"
10
+
11
+ register_component(Simple)
12
+ end
13
+ end
14
+ end
@@ -3,19 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Renderer
6
- require_relative "renderer/base"
7
- require_relative "renderer/simple"
8
-
9
- class << self
10
- def create(type)
11
- case type
12
- when :simple
13
- Simple.new
14
- else
15
- raise ArgumentError, "Unknown renderer type: #{type}"
16
- end
17
- end
18
- end
6
+ require_relative "renderer/renderer"
19
7
  end
20
8
  end
21
9
  end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Visualizer
6
- class Base
6
+ class Base < Utils::Construct::Component::Base
7
7
  def visualize(path)
8
8
  raise NotImplementedError, "You must implement #{self.class}##{__method}"
9
9
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module DirectoryTree
5
+ module Visualizer
6
+ include Utils::Construct::Component::Manager
7
+
8
+ require "pathname"
9
+
10
+ require_relative "base"
11
+ require_relative "tree"
12
+
13
+ register_component(Tree)
14
+ end
15
+ end
16
+ end
@@ -3,21 +3,7 @@
3
3
  module DevSuite
4
4
  module DirectoryTree
5
5
  module Visualizer
6
- require "pathname"
7
-
8
- require_relative "visualizer/base"
9
- require_relative "visualizer/tree"
10
-
11
- class << self
12
- def create(type)
13
- case type
14
- when :tree
15
- Tree.new
16
- else
17
- raise ArgumentError, "Unknown renderer type: #{type}"
18
- end
19
- end
20
- end
6
+ require_relative "visualizer/visualizer"
21
7
  end
22
8
  end
23
9
  end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module Performance
5
5
  module Config
6
- include Utils::Construct::Config
6
+ include Utils::Construct::Config::Manager
7
7
 
8
8
  require_relative "configuration"
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module Performance
5
5
  module Config
6
- class Configuration < BaseConfiguration
6
+ class Configuration < Utils::Construct::Config::Base
7
7
  # Define configuration attributes
8
8
  config_attr :profilers,
9
9
  default_value: [:execution_time, :memory],
@@ -18,11 +18,11 @@ module DevSuite
18
18
  private
19
19
 
20
20
  def resolve_profilers(value)
21
- Profiler.create_multiple(value)
21
+ Profiler.build_components(value)
22
22
  end
23
23
 
24
24
  def resolve_reporter(value)
25
- Reporter.create(value)
25
+ Reporter.build_component(value)
26
26
  end
27
27
  end
28
28
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Performance
5
+ module Data
6
+ require_relative "memory_usage"
7
+ end
8
+ end
9
+ end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module Performance
5
5
  module Data
6
- require_relative "data/memory_usage"
6
+ require_relative "data/data"
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module DevSuite
4
4
  module Performance
5
5
  module Profiler
6
- class Base
6
+ class Base < Utils::Construct::Component::Base
7
7
  def run(&block)
8
8
  raise NotImplementedError, "Subclasses must implement the run method"
9
9
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevSuite
4
+ module Performance
5
+ module Profiler
6
+ include Utils::Construct::Component::Manager
7
+
8
+ require_relative "base"
9
+ require_relative "execution_time"
10
+ require_relative "memory"
11
+
12
+ register_component(ExecutionTime)
13
+ register_component(Memory)
14
+ end
15
+ end
16
+ end