trace_viz 0.0.1 → 1.0.0

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 (157) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +34 -0
  3. data/README.md +134 -39
  4. data/Steepfile +34 -0
  5. data/examples/eu_central_bank.rb +69 -0
  6. data/examples/example.cast +189 -0
  7. data/examples/example.rb +94 -23
  8. data/lib/trace_viz/adapters/base_adapter.rb +23 -2
  9. data/lib/trace_viz/adapters/trace_point_adapter.rb +10 -11
  10. data/lib/trace_viz/collectors/base_collector.rb +90 -0
  11. data/lib/trace_viz/collectors/filters/base_class_filter.rb +29 -0
  12. data/lib/trace_viz/collectors/filters/base_exclude_filter.rb +16 -0
  13. data/lib/trace_viz/collectors/filters/base_filter.rb +17 -0
  14. data/lib/trace_viz/collectors/filters/base_include_filter.rb +16 -0
  15. data/lib/trace_viz/collectors/filters/exclude_classes_filter.rb +15 -0
  16. data/lib/trace_viz/collectors/filters/exclude_default_classes_filter.rb +34 -0
  17. data/lib/trace_viz/collectors/filters/exclude_gems_filter.rb +30 -0
  18. data/lib/trace_viz/collectors/filters/exclude_internal_call_filter.rb +31 -0
  19. data/lib/trace_viz/collectors/filters/exclude_rails_framework_filter.rb +38 -0
  20. data/lib/trace_viz/collectors/filters/include_classes_filter.rb +15 -0
  21. data/lib/trace_viz/collectors/filters/include_gems_filter.rb +54 -0
  22. data/lib/trace_viz/collectors/filters/registry.rb +59 -0
  23. data/lib/trace_viz/collectors/hierarchy_linker.rb +30 -0
  24. data/lib/trace_viz/collectors/matchers/base_matcher.rb +13 -0
  25. data/lib/trace_viz/collectors/matchers/trace_point_action_matcher.rb +38 -0
  26. data/lib/trace_viz/collectors/matchers/within_depth_matcher.rb +26 -0
  27. data/lib/trace_viz/collectors/steps/assign_depth_for_call_step.rb +30 -0
  28. data/lib/trace_viz/collectors/steps/assign_depth_for_return_step.rb +39 -0
  29. data/lib/trace_viz/collectors/steps/base_step.rb +27 -0
  30. data/lib/trace_viz/collectors/steps/build_hierarchy_step.rb +32 -0
  31. data/lib/trace_viz/collectors/steps/hidden_step.rb +25 -0
  32. data/lib/trace_viz/collectors/steps/linking_step.rb +36 -0
  33. data/lib/trace_viz/collectors/steps/validation_step.rb +33 -0
  34. data/lib/trace_viz/collectors/steps.rb +10 -0
  35. data/lib/trace_viz/collectors/trace_pipeline.rb +26 -0
  36. data/lib/trace_viz/collectors/trace_pipeline_builder.rb +29 -0
  37. data/lib/trace_viz/collectors/trace_point_collector.rb +41 -0
  38. data/lib/trace_viz/collectors/trace_stats.rb +21 -0
  39. data/lib/trace_viz/config/copier.rb +38 -0
  40. data/lib/trace_viz/config/validator.rb +75 -0
  41. data/lib/trace_viz/configuration.rb +36 -30
  42. data/lib/trace_viz/context/config_context.rb +1 -1
  43. data/lib/trace_viz/context/manager.rb +17 -21
  44. data/lib/trace_viz/context/map.rb +29 -0
  45. data/lib/trace_viz/context/registry.rb +37 -0
  46. data/lib/trace_viz/context/tracking/active_calls.rb +37 -0
  47. data/lib/trace_viz/context/tracking_context.rb +11 -2
  48. data/lib/trace_viz/context.rb +2 -2
  49. data/lib/trace_viz/core/tracer.rb +3 -0
  50. data/lib/trace_viz/defaults/actions.rb +84 -0
  51. data/lib/trace_viz/defaults/colors.rb +61 -0
  52. data/lib/trace_viz/defaults/config.rb +89 -0
  53. data/lib/trace_viz/defaults/themes.rb +66 -0
  54. data/lib/trace_viz/defaults.rb +20 -0
  55. data/lib/trace_viz/exporters/base_exporter.rb +81 -0
  56. data/lib/trace_viz/exporters/export_manager.rb +33 -0
  57. data/lib/trace_viz/exporters/registry.rb +25 -0
  58. data/lib/trace_viz/exporters/text_exporter.rb +37 -0
  59. data/lib/trace_viz/formatters/base_formatter.rb +15 -0
  60. data/lib/trace_viz/formatters/export/base_formatter.rb +12 -0
  61. data/lib/trace_viz/formatters/export/formatter_factory.rb +27 -0
  62. data/lib/trace_viz/formatters/export/method_call_formatter.rb +21 -0
  63. data/lib/trace_viz/formatters/export/method_return_formatter.rb +22 -0
  64. data/lib/trace_viz/formatters/export/summary_group_formatter.rb +35 -0
  65. data/lib/trace_viz/formatters/helpers/depth_helper.rb +15 -0
  66. data/lib/trace_viz/formatters/helpers/indent_helper.rb +15 -0
  67. data/lib/trace_viz/formatters/helpers/log/color_helper.rb +23 -0
  68. data/lib/trace_viz/formatters/helpers/log/depth_helper.rb +22 -0
  69. data/lib/trace_viz/formatters/helpers/log/method_name_helper.rb +29 -0
  70. data/lib/trace_viz/formatters/helpers/log/params_helper.rb +51 -0
  71. data/lib/trace_viz/formatters/helpers/log/result_helper.rb +27 -0
  72. data/lib/trace_viz/formatters/helpers/log/summary/params_helper.rb +53 -0
  73. data/lib/trace_viz/formatters/helpers/method_details_helper.rb +15 -0
  74. data/lib/trace_viz/formatters/helpers/params_helper.rb +43 -0
  75. data/lib/trace_viz/formatters/helpers/result_helper.rb +21 -0
  76. data/lib/trace_viz/formatters/helpers/source_helper.rb +22 -0
  77. data/lib/trace_viz/formatters/helpers/summary/params_helper.rb +41 -0
  78. data/lib/trace_viz/formatters/helpers/summary/source_helper.rb +24 -0
  79. data/lib/trace_viz/formatters/helpers/time_helper.rb +15 -0
  80. data/lib/trace_viz/formatters/helpers.rb +10 -0
  81. data/lib/trace_viz/formatters/log/base_formatter.rb +13 -0
  82. data/lib/trace_viz/formatters/log/formatter_factory.rb +27 -0
  83. data/lib/trace_viz/formatters/log/method_call_formatter.rb +34 -0
  84. data/lib/trace_viz/formatters/log/method_return_formatter.rb +24 -0
  85. data/lib/trace_viz/formatters/log/summary_group_formatter.rb +40 -0
  86. data/lib/trace_viz/formatters/log/verbose_formatter.rb +14 -0
  87. data/lib/trace_viz/formatters/trace_data_formatter.rb +24 -0
  88. data/lib/trace_viz/helpers/config_helper.rb +13 -0
  89. data/lib/trace_viz/helpers/trace_point/param_helper.rb +98 -0
  90. data/lib/trace_viz/helpers/tracking_helper.rb +26 -0
  91. data/lib/trace_viz/helpers.rb +9 -0
  92. data/lib/trace_viz/logger.rb +28 -49
  93. data/lib/trace_viz/loggers/base_logger.rb +29 -0
  94. data/lib/trace_viz/loggers/log_level_resolver.rb +18 -0
  95. data/lib/trace_viz/loggers/logging_manager.rb +46 -0
  96. data/lib/trace_viz/loggers/post_collection_logger.rb +39 -0
  97. data/lib/trace_viz/loggers/trace_logger.rb +37 -0
  98. data/lib/trace_viz/loggers/trace_stats_logger.rb +47 -0
  99. data/lib/trace_viz/renderers/base_renderer.rb +24 -0
  100. data/lib/trace_viz/renderers/render_context.rb +18 -0
  101. data/lib/trace_viz/renderers/renderer_factory.rb +41 -0
  102. data/lib/trace_viz/renderers/summary/node_processor.rb +82 -0
  103. data/lib/trace_viz/renderers/summary_renderer.rb +22 -0
  104. data/lib/trace_viz/renderers/verbose_renderer.rb +29 -0
  105. data/lib/trace_viz/shared/renderer_helper.rb +46 -0
  106. data/lib/trace_viz/shared.rb +8 -0
  107. data/lib/trace_viz/trace_data/base.rb +49 -0
  108. data/lib/trace_viz/trace_data/node.rb +33 -0
  109. data/lib/trace_viz/trace_data/root_node.rb +20 -0
  110. data/lib/trace_viz/trace_data/summary_node.rb +49 -0
  111. data/lib/trace_viz/trace_data/trace_point/base.rb +59 -0
  112. data/lib/trace_viz/trace_data/trace_point/method_call.rb +47 -0
  113. data/lib/trace_viz/trace_data/trace_point/method_return.rb +45 -0
  114. data/lib/trace_viz/trace_data/trace_point_builder.rb +23 -0
  115. data/lib/trace_viz/traits/depth_trackable.rb +13 -0
  116. data/lib/trace_viz/traits/identifiable.rb +25 -0
  117. data/lib/trace_viz/traits/time_trackable.rb +13 -0
  118. data/lib/trace_viz/traits.rb +10 -0
  119. data/lib/trace_viz/utils/colorize.rb +12 -23
  120. data/lib/trace_viz/utils/format_utils/key_value_formatter.rb +37 -0
  121. data/lib/trace_viz/utils/format_utils/value_truncator.rb +74 -0
  122. data/lib/trace_viz/utils/format_utils.rb +24 -0
  123. data/lib/trace_viz/utils/id_generator.rb +35 -0
  124. data/lib/trace_viz/version.rb +1 -1
  125. data/sig/adapters/base_adapter.rbs +11 -0
  126. data/sig/adapters/trace_point_adapter.rbs +13 -0
  127. data/sig/collectors/filters/registry.rbs +13 -0
  128. data/sig/collectors/trace_point_collector.rbs +17 -0
  129. data/sig/config/copier.rbs +15 -0
  130. data/sig/config/validator.rbs +18 -0
  131. data/sig/configuration.rbs +22 -0
  132. data/sig/context/base_context.rbs +9 -0
  133. data/sig/context/config_context.rbs +13 -0
  134. data/sig/context/manager.rbs +10 -0
  135. data/sig/context/map.rbs +13 -0
  136. data/sig/context.rbs +5 -0
  137. data/sig/core/tracer.rbs +7 -0
  138. data/sig/core.rbs +4 -0
  139. data/sig/defaults.rbs +17 -0
  140. data/sig/errors.rbs +13 -0
  141. data/sig/logger.rbs +33 -0
  142. data/sig/trace_viz.rbs +1 -2
  143. data/sig/utils/colorize.rbs +8 -0
  144. data/sig/utils/format_utils/key_value_formatter.rbs +16 -0
  145. data/sig/utils/format_utils/value_truncator.rbs +19 -0
  146. data/sig/utils/format_utils.rbs +8 -0
  147. data/sig/version.rbs +3 -0
  148. metadata +140 -16
  149. data/lib/trace_viz/adapters/trace_point/depth_manager.rb +0 -34
  150. data/lib/trace_viz/adapters/trace_point/event_handler.rb +0 -36
  151. data/lib/trace_viz/adapters/trace_point/trace_data.rb +0 -89
  152. data/lib/trace_viz/adapters/trace_point/trace_formatter.rb +0 -95
  153. data/lib/trace_viz/adapters/trace_point/trace_logger.rb +0 -44
  154. data/lib/trace_viz/context/manager/context_map.rb +0 -31
  155. data/lib/trace_viz/context/manager/context_operations.rb +0 -60
  156. data/lib/trace_viz/context/manager/context_registry.rb +0 -20
  157. data/lib/trace_viz/context/manager/context_validation.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dad6986e31d5fab4d42a7e6820086bd39ad16d3dd7461b483425d06122533d56
4
- data.tar.gz: ca9411d76b1134ad5e676264771e7046a6e52fbe250040f61c5b3294071d2578
3
+ metadata.gz: 8fffeaf37d8c9d9854f95159dba5ab2c8d9657a4ad63828e04164a79911ba4a3
4
+ data.tar.gz: 8c868e5bd2e954611c280fcb23a68cbf059f8314a98f7aaba2d3da909197e203
5
5
  SHA512:
6
- metadata.gz: c66ab56494adc950558f5e9f21f8630178a262443440d70799ee43284ad03b0615e1031df8f24d495b9970b054c841c057d1858e629e5216c05c35a7485071b6
7
- data.tar.gz: c30a273a89fa59c417e3974056916f135083ad50320dbb18c063b3db0c365231bb09118611770e1a158435997733101e9a917026245936ece186c73a7e9fcf71
6
+ metadata.gz: 25fa2eb78c78ad670bc3dd5e2819880154e4119c7260ab4127d35d7f75bcf56a23e237a0eb4cbbd893e2d3f6547a57496b432a214a2145770bdb252385d7dd94
7
+ data.tar.gz: f267c37003eaa0a4a4427e6faedac0e83827e3e5c6433bc22aee68a32b5b14a07abc51cf6d71bbfaf9aff3bfb0448cd381d1e168bb34e345d95c138478623635
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,34 @@
1
+ # Contributing to TraceViz
2
+
3
+ Thank you for your interest in improving TraceViz! 🎉
4
+
5
+ ## Development Setup
6
+
7
+ 1. Fork and clone the repository.
8
+ 2. Run `bundle install` to install dependencies.
9
+ 3. Make your changes.
10
+ 4. Run `bin/rspec` to ensure all tests pass.
11
+ 5. Submit a Pull Request with a clear description.
12
+
13
+ ## Coding Standards
14
+
15
+ - Follow the [Ruby Style Guide](https://github.com/rubocop/ruby-style-guide).
16
+ - Write clear and descriptive commit messages.
17
+
18
+ ## Tests
19
+
20
+ - All new functionality must be covered by tests.
21
+ - Run `bin/rspec` before pushing changes.
22
+ - Ensure 100% passing tests on CI.
23
+
24
+ ## Documentation
25
+
26
+ - Update `README.md` if your changes affect usage.
27
+ - Consider adding examples or improving existing ones.
28
+
29
+ ## Code of Conduct
30
+
31
+ - Please be respectful and supportive of others.
32
+ - Refer to [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) for details.
33
+
34
+ Thank you for making TraceViz better! 🚀
data/README.md CHANGED
@@ -2,11 +2,20 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/trace_viz.svg)](https://rubygems.org/gems/trace_viz)
4
4
  [![Downloads](https://img.shields.io/gem/dt/trace_viz)](https://rubygems.org/gems/trace_viz)
5
- [![Build Status](https://github.com/patrick204nqh/trace_viz/actions/workflows/main.yml/badge.svg)](https://github.com/patrick204nqh/trace_viz/actions)
5
+ [![Build Status](https://github.com/patrick204nqh/trace_viz/actions/workflows/ci.yml/badge.svg)](https://github.com/patrick204nqh/trace_viz/actions)
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/e97579abe66f3477e71d/maintainability)](https://codeclimate.com/github/patrick204nqh/trace_viz/maintainability)
7
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/e97579abe66f3477e71d/test_coverage)](https://codeclimate.com/github/patrick204nqh/trace_viz/test_coverage)
7
8
  ![License](https://img.shields.io/github/license/patrick204nqh/trace_viz)
8
9
 
9
- TraceViz is a Ruby library designed to trace and visualize events executed in a block of code. It is useful for logging, debugging, and generating diagrams to understand code execution and flow. The gem allows you to customize how much detail you want to see, such as method calls, parameters, return values, and execution times.
10
+ TraceViz is a Ruby library designed to trace and visualize events executed in a block of code. It is useful for logging, debugging, and generating diagrams to understand code execution and flow.
11
+
12
+ > **Note:** The diagram generation feature is currently under development.
13
+
14
+ The gem allows you to customize how much detail you want to see, such as method calls, parameters, return values, and execution times.
15
+
16
+ ## Demo
17
+
18
+ [![asciicast](https://asciinema.org/a/lKXPPgx0muZuQbtvMu8GyHaOV.svg)](https://asciinema.org/a/lKXPPgx0muZuQbtvMu8GyHaOV)
10
19
 
11
20
  ## Installation
12
21
 
@@ -32,24 +41,55 @@ gem install trace_viz
32
41
 
33
42
  Wrap your code inside the TraceViz.trace block to start tracing its execution. The tracing behavior can be customized using various options:
34
43
 
44
+ <details>
45
+ <summary>Configuration Example</summary>
46
+
35
47
  ```ruby
36
48
  TraceViz.trace(
37
- tab_size: 2,
38
- show_indent: true,
39
- show_depth: true,
40
- max_display_depth: 4, # Recommended to keep this value between 3 and 5
41
- show_method_name: true,
42
- show_source_location: false,
43
- show_params: true,
44
- show_return_value: true,
45
- show_execution_time: true,
46
- show_trace_events: [:call, :return]
49
+ general: {
50
+ tab_size: 4,
51
+ show_indent: true,
52
+ show_depth: true,
53
+ max_display_depth: 3,
54
+ show_method_name: true,
55
+ },
56
+ source_location: {
57
+ show: false,
58
+ truncate_length: 100,
59
+ },
60
+ params: {
61
+ show: true,
62
+ mode: :name_and_value,
63
+ truncate_values: 50,
64
+ },
65
+ result: {
66
+ show: true,
67
+ truncate_length: 50,
68
+ },
69
+ execution: {
70
+ show_time: true,
71
+ show_trace_events: [:call, :return],
72
+ },
73
+ filters: [
74
+ :exclude_internal_call,
75
+ :exclude_default_classes,
76
+ ...
77
+ ],
78
+ export: {
79
+ enabled: true,
80
+ path: "tmp",
81
+ format: :txt,
82
+ overwrite: false,
83
+ }
47
84
  ) do
48
85
  # Your code here
49
86
  end
50
87
  ```
51
88
 
52
- **Example**
89
+ </details>
90
+
91
+ <details>
92
+ <summary>Example Code</summary>
53
93
 
54
94
  ```ruby
55
95
  class Example
@@ -77,27 +117,56 @@ class Example
77
117
  end
78
118
 
79
119
  TraceViz.trace(
120
+ general: {
80
121
  tab_size: 4,
81
122
  show_indent: true,
82
123
  show_depth: true,
83
124
  max_display_depth: 3,
84
125
  show_method_name: true,
85
- show_source_location: false,
86
- show_params: true,
87
- show_return_value: true,
88
- show_execution_time: true,
89
- show_trace_events: [:call, :return]
126
+ },
127
+ source_location: {
128
+ show: false,
129
+ truncate_length: 100,
130
+ },
131
+ params: {
132
+ show: true,
133
+ mode: :name_and_value,
134
+ truncate_values: 50,
135
+ },
136
+ result: {
137
+ show: true,
138
+ truncate_length: 50,
139
+ },
140
+ execution: {
141
+ show_time: true,
142
+ show_trace_events: [:call, :return],
143
+ },
144
+ filters: [
145
+ :exclude_internal_call,
146
+ include_classes: [Example]
147
+ ],
148
+ export: {
149
+ enabled: true,
150
+ path: "tmp",
151
+ format: :txt,
152
+ overwrite: false,
153
+ }
90
154
  ) do
91
155
  example = Example.new
92
156
  example.perform_task(5, 7)
93
157
  end
94
158
  ```
95
159
 
160
+ </details>
161
+
96
162
  **Output**
97
163
 
164
+ <details open>
165
+ <summary>Sample Output</summary>
166
+
98
167
  ```bash
99
- 🚀 [START] #depth:0 Example#perform_task (5, 7, nil)
100
- 🚀 [START] #depth:1 Example#add_numbers (5, 7, nil)
168
+ 🚀 [START] #depth:0 Example#perform_task (5, 7)
169
+ 🚀 [START] #depth:1 Example#add_numbers (5, 7)
101
170
  🚀 [START] #depth:2 Example#multiply_by_factor (12, 2)
102
171
  🏁 [FINISH] #depth:2 Example#multiply_by_factor #=> 24
103
172
  🏁 [FINISH] #depth:1 Example#add_numbers #=> 24
@@ -107,22 +176,52 @@ Final result: 24
107
176
  🏁 [FINISH] #depth:0 Example#perform_task #=> 24
108
177
  ```
109
178
 
179
+ </details>
180
+
110
181
  ### Configuration Options
111
182
 
112
- | Option | Type | Description |
113
- | ---------------------- | ---------------- | -------------------------------------------------------------------------------- |
114
- | `tab_size` | Integer | Defines the number of spaces used for indentation when `show_indent` is enabled. |
115
- | `show_indent` | Boolean | Whether to visually indent nested calls. |
116
- | `show_depth` | Boolean | Displays the depth level of the method call. |
117
- | `max_display_depth` | Integer | Limits the display to a maximum depth of calls. |
118
- | `show_method_name` | Boolean | Shows the name of the method being called. |
119
- | `show_source_location` | Boolean | Logs the source file name and line number where the method is defined. |
120
- | `show_params` | Boolean | Logs the parameters passed to the method. |
121
- | `show_return_value` | Boolean | Logs the return value of the method. |
122
- | `show_execution_time` | Boolean | Logs the execution time for methods. |
123
- | `show_trace_events` | Array of Symbols | Specifies the events to trace. Valid values include: |
124
- | | | - `:call` - Log method calls. |
125
- | | | - `:return` - Log method returns. |
183
+ TraceViz provides extensive configuration options to customize tracing behavior.
184
+
185
+ | Group | Option | Type | Default Value | Description |
186
+ | ----------------- | -------------------------- | ---------------- | --------------------------- | -------------------------------------------------------------------------- |
187
+ | `general` | `tab_size` | Integer | 2 | Number of spaces for indentation. |
188
+ | | `mode` | Symbol | `:summary` | Display mode (`:summary` or `:verbose`). |
189
+ | | `group_keys` | Array of Symbols | `[:event, :klass, :action]` | Keys to group similar outputs. |
190
+ | | `show_indent` | Boolean | true | Enables visual indentation for nested calls. |
191
+ | | `show_depth` | Boolean | true | Displays the depth level of the method call. |
192
+ | | `max_display_depth` | Integer | 3 | Maximum depth of calls to display. |
193
+ | | `show_method_name` | Boolean | true | Logs the name of the method being executed. |
194
+ | `source_location` | `show` | Boolean | false | Logs the source file and line number for methods. |
195
+ | | `truncate_length` | Integer | 100 | Maximum length of displayed source location information. |
196
+ | `params` | `show` | Boolean | true | Logs method parameters. |
197
+ | | `mode` | Symbol | `:name_and_value` | Parameter display mode (`:name`, `:value`, or `:name_and_value`). |
198
+ | | `truncate_values` | Integer | 50 | Maximum length of parameter values to display. |
199
+ | `result` | `show` | Boolean | true | Logs method return values. |
200
+ | | `truncate_length` | Integer | 50 | Maximum length of return value logs. |
201
+ | `execution` | `show_time` | Boolean | true | Logs execution time for methods. |
202
+ | | `show_trace_events` | Array of Symbols | `[:call, :return]` | Specifies the trace events to log (e.g., `:call`, `:return`). |
203
+ | `filters` | `:exclude_internal_call` | Symbol | N/A | Exclude internal Ruby calls. |
204
+ | | `:exclude_default_classes` | Symbol | N/A | Skip logging standard library classes. |
205
+ | | `:exclude_rails_framework` | Symbol | N/A | Ignore Rails framework classes and methods. |
206
+ | | `include_classes` | Hash | N/A | Specify classes to include in tracing. |
207
+ | | - `classes` | Array | [] | List of class names to include (e.g., `["ClassName"]`). |
208
+ | | `exclude_classes` | Hash | N/A | Specify classes to exclude from tracing. |
209
+ | | - `classes` | Array | [] | List of class names to exclude (e.g., `["ClassName"]`). |
210
+ | | `include_gems` | Hash | N/A | Include specific gems or runtime application gems. |
211
+ | | - `app_running` | Boolean | true | Include the code of the application. |
212
+ | | - `app_path` | String | `Dir.pwd` | Path to the application (e.g., `Dir.pwd`). |
213
+ | | - `gems` | Array | [] | List of gems to include (e.g., `["gem1", "gem2"]`). |
214
+ | | `exclude_gems` | Hash | N/A | Exclude specified gems. |
215
+ | | - `gems` | Array | [] | List of gems to exclude (e.g., `["excluded_gem"]`). |
216
+ | `export` | `enabled` | Boolean | true | Enables or disables exporting of trace logs. |
217
+ | | `path` | String | `"tmp"` | Directory for exported trace logs. |
218
+ | | `format` | Symbol | `:txt` | Format for trace logs (`:txt`). `.json` and `.yaml` are under development. |
219
+ | | `overwrite` | Boolean | false | Prevents overwriting of existing exported files. |
220
+
221
+ ### Notes
222
+
223
+ - **Default Skipped Classes**: The following standard library classes are excluded by default when `:exclude_default_classes` is enabled:
224
+ - `Object`, `String`, `Array`, `Hash`, `Numeric`, `Integer`, `Float`, `Symbol`, `Kernel`, `Module`, `Class`, `Range`, `Regexp`, `Set`, `Gem`.
126
225
 
127
226
  ## Development
128
227
 
@@ -152,7 +251,7 @@ bundle install
152
251
  bin/rspec
153
252
  ```
154
253
 
155
- You can use `irb` or `pry` to test the gem locally. Make your changes, add tests, and ensure all tests pass before submitting a pull request.
254
+ You can use `debug` or `pry` to test the gem locally. Make your changes, add tests, and ensure all tests pass before submitting a pull request.
156
255
 
157
256
  ## Contributing
158
257
 
@@ -161,7 +260,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/patric
161
260
  ## License
162
261
 
163
262
  TraceViz is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
164
-
165
- ## Acknowledgements
166
-
167
- Special thanks to the Ruby community for their continued support and inspiration!
data/Steepfile ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ D = Steep::Diagnostic
4
+
5
+ target :lib do
6
+ signature "sig"
7
+ # ignore_signature "sig/test"
8
+
9
+ check "lib" # Directory name
10
+ # check "path/to/source.rb" # File name
11
+ # check "app/models/**/*.rb" # Glob
12
+ # ignore "lib/templates/*.rb"
13
+
14
+ # library "pathname" # Standard libraries
15
+ # library "strong_json" # Gems
16
+
17
+ # configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
18
+ # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
19
+ # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
20
+ # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
21
+ # configure_code_diagnostics do |hash| # You can setup everything yourself
22
+ # hash[D::Ruby::NoMethod] = :information
23
+ # end
24
+ end
25
+
26
+ target :test do
27
+ unreferenced! # Skip type checking the `lib` code when types in `test` target is changed
28
+ # signature "sig/test" # Put RBS files for tests under `sig/test`
29
+ check "test" # Type check Ruby scripts under `test`
30
+
31
+ configure_code_diagnostics(D::Ruby.lenient) # Weak type checking for test code
32
+
33
+ # library "pathname" # Standard libraries
34
+ end
@@ -0,0 +1,69 @@
1
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
2
+ require 'eu_central_bank'
3
+ require 'i18n'
4
+ require 'trace_viz'
5
+
6
+ # Fix the locale issue
7
+ I18n.config.available_locales = [:en]
8
+ I18n.locale = :en
9
+
10
+ TraceViz.trace(
11
+ general: {
12
+ tab_size: 1,
13
+ mode: :summary,
14
+ show_indent: true,
15
+ show_depth: true,
16
+ max_display_depth: 5,
17
+ show_method_name: true,
18
+ },
19
+ params: {
20
+ show: true,
21
+ mode: :name_only,
22
+ # truncate_length: 10
23
+ },
24
+ result: {
25
+ show: true,
26
+ truncate_length: 15,
27
+ },
28
+ source_location: {
29
+ show: true,
30
+ truncate_length: 50,
31
+ },
32
+ execution: {
33
+ show_time: true,
34
+ show_trace_events: [:call, :return],
35
+ },
36
+ log: {
37
+ runtime: false,
38
+ post_collection: true,
39
+ stats: true
40
+ },
41
+ filters: [
42
+ :exclude_internal_call,
43
+ :exclude_default_classes,
44
+ # include_classes: {
45
+ # classes: [EuCentralBank],
46
+ # },
47
+ # exclude_classes: {
48
+ # classes: ['Gem']
49
+ # },
50
+ exclude_gems: {
51
+ gems: ['nokogiri', 'money', 'i18n']
52
+ }
53
+ ],
54
+ export: {
55
+ enabled: true,
56
+ format: :txt,
57
+ overwrite: true,
58
+ }
59
+ ) do
60
+ # Create a new instance of the EuCentralBank
61
+ bank = EuCentralBank.new
62
+
63
+ # Trace the update of exchange rates
64
+ bank.update_rates
65
+
66
+ # Trace conversion of currency
67
+ result = bank.exchange(50, 'USD', 'EUR')
68
+ puts "Converted amount: #{result}"
69
+ end