class-metrix 0.1.2
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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +88 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +417 -0
- data/RELEASE_GUIDE.md +158 -0
- data/Rakefile +12 -0
- data/examples/README.md +155 -0
- data/examples/advanced/error_handling.rb +199 -0
- data/examples/advanced/hash_expansion.rb +180 -0
- data/examples/basic/01_simple_constants.rb +56 -0
- data/examples/basic/02_simple_methods.rb +99 -0
- data/examples/basic/03_multi_type_extraction.rb +116 -0
- data/examples/components/configurable_reports.rb +201 -0
- data/examples/csv_output_demo.rb +237 -0
- data/examples/real_world/microservices_audit.rb +312 -0
- data/lib/class_metrix/extractor.rb +121 -0
- data/lib/class_metrix/extractors/constants_extractor.rb +87 -0
- data/lib/class_metrix/extractors/methods_extractor.rb +87 -0
- data/lib/class_metrix/extractors/multi_type_extractor.rb +66 -0
- data/lib/class_metrix/formatters/base/base_component.rb +62 -0
- data/lib/class_metrix/formatters/base/base_formatter.rb +93 -0
- data/lib/class_metrix/formatters/components/footer_component.rb +67 -0
- data/lib/class_metrix/formatters/components/generic_header_component.rb +87 -0
- data/lib/class_metrix/formatters/components/header_component.rb +92 -0
- data/lib/class_metrix/formatters/components/missing_behaviors_component.rb +140 -0
- data/lib/class_metrix/formatters/components/table_component.rb +268 -0
- data/lib/class_metrix/formatters/csv_formatter.rb +98 -0
- data/lib/class_metrix/formatters/markdown_formatter.rb +184 -0
- data/lib/class_metrix/formatters/shared/csv_table_builder.rb +21 -0
- data/lib/class_metrix/formatters/shared/markdown_table_builder.rb +97 -0
- data/lib/class_metrix/formatters/shared/table_builder.rb +267 -0
- data/lib/class_metrix/formatters/shared/value_processor.rb +78 -0
- data/lib/class_metrix/processors/value_processor.rb +40 -0
- data/lib/class_metrix/utils/class_resolver.rb +20 -0
- data/lib/class_metrix/version.rb +5 -0
- data/lib/class_metrix.rb +12 -0
- data/sig/class/metrix.rbs +6 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f907803028cff5b1f0e8fcc21bd9e9b68d4dc496ba450dda0364337f5548c06a
|
4
|
+
data.tar.gz: 1d02ce1725a8542e9a5e60a528c248838ff072743c4556c17878b68a7a5ae931
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7d44e8e2359f858fc349179539cb5d7d7cf831abb6da76f77eaec75e882efd4f3d9cb371f6070c34ab4048d9fb319ddf7621fadafc5a0cc0d00089c8f8881f2
|
7
|
+
data.tar.gz: 349ccda98eec305973604160b6238c47b3c764f5f1935ca7d06bf63fcf4a8832b8d026e7810dff3504ac38eddf029f7ac45fdfe9b3fdfaa0f19bde7adbab449c
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.3
|
3
|
+
SuggestExtensions: false
|
4
|
+
NewCops: enable
|
5
|
+
Exclude:
|
6
|
+
- 'bin/*'
|
7
|
+
- 'examples/**/*'
|
8
|
+
- 'vendor/**/*'
|
9
|
+
- 'node_modules/**/*'
|
10
|
+
- '.ruby-lsp/**/*'
|
11
|
+
|
12
|
+
# String literal styles
|
13
|
+
Style/StringLiterals:
|
14
|
+
EnforcedStyle: double_quotes
|
15
|
+
|
16
|
+
Style/StringLiteralsInInterpolation:
|
17
|
+
EnforcedStyle: double_quotes
|
18
|
+
|
19
|
+
# Documentation requirements
|
20
|
+
Style/Documentation:
|
21
|
+
Enabled: false # Many classes don't need top-level documentation
|
22
|
+
|
23
|
+
# Method and class length limits
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 25 # Increased to accommodate current codebase
|
26
|
+
|
27
|
+
Metrics/ClassLength:
|
28
|
+
Max: 250 # Increased to accommodate complex formatter classes
|
29
|
+
|
30
|
+
Metrics/BlockLength:
|
31
|
+
Max: 30 # Slightly increased from default
|
32
|
+
Exclude:
|
33
|
+
- 'spec/**/*' # Allow long blocks in tests
|
34
|
+
- 'class-metrix.gemspec' # Allow long blocks in gemspec
|
35
|
+
|
36
|
+
# Complexity limits
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Max: 35 # Increased to accommodate current codebase
|
39
|
+
|
40
|
+
Metrics/CyclomaticComplexity:
|
41
|
+
Max: 15 # Increased to accommodate current codebase
|
42
|
+
|
43
|
+
Metrics/PerceivedComplexity:
|
44
|
+
Max: 15 # Increased to accommodate current codebase
|
45
|
+
|
46
|
+
# Line length
|
47
|
+
Layout/LineLength:
|
48
|
+
Max: 140 # Increased from default 120
|
49
|
+
|
50
|
+
# Naming conventions
|
51
|
+
Naming/AccessorMethodName:
|
52
|
+
Enabled: false # Allow get_ prefixed methods
|
53
|
+
|
54
|
+
Naming/PredicateName:
|
55
|
+
Enabled: false # Allow has_ prefixed methods
|
56
|
+
|
57
|
+
# Optional boolean parameters
|
58
|
+
Style/OptionalBooleanParameter:
|
59
|
+
Enabled: false # Allow boolean default parameters
|
60
|
+
|
61
|
+
# Gemspec warning
|
62
|
+
Gemspec/RequiredRubyVersion:
|
63
|
+
Enabled: false # Allow different ruby versions in gemspec vs rubocop
|
64
|
+
|
65
|
+
# Script permissions (for examples)
|
66
|
+
Lint/ScriptPermission:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
# Allow constants in blocks (common in specs)
|
70
|
+
Lint/ConstantDefinitionInBlock:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
# String concatenation
|
74
|
+
Style/StringConcatenation:
|
75
|
+
Enabled: false # Allow string concatenation in some cases
|
76
|
+
|
77
|
+
# Additional cops to disable based on project needs
|
78
|
+
Gemspec/DevelopmentDependencies:
|
79
|
+
Enabled: false # Allow development dependencies in gemspec
|
80
|
+
|
81
|
+
Lint/DuplicateBranch:
|
82
|
+
Enabled: false # Allow duplicate rescue branches for different error types
|
83
|
+
|
84
|
+
Style/ComparableClamp:
|
85
|
+
Enabled: false # Allow traditional min/max patterns for clarity
|
86
|
+
|
87
|
+
Lint/NonAtomicFileOperation:
|
88
|
+
Enabled: false # Allow traditional file existence checks in specs
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.3.7
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [0.1.0] - 2025-06-07
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- GitHub Actions CI/CD workflow for automated releases
|
12
|
+
- Multi-version Ruby testing (3.1, 3.2, 3.3)
|
13
|
+
- Automated gem publishing to RubyGems
|
14
|
+
- Version consistency checking
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Improved CI workflow with better test coverage
|
18
|
+
|
19
|
+
## [0.1.0] - 2024-01-XX
|
20
|
+
|
21
|
+
### Added
|
22
|
+
- Initial release of ClassMetrix
|
23
|
+
- Constants extraction from Ruby classes
|
24
|
+
- Class methods extraction and comparison
|
25
|
+
- Multi-type extraction support
|
26
|
+
- Hash expansion functionality
|
27
|
+
- Error handling for missing methods/constants
|
28
|
+
- Markdown report generation
|
29
|
+
- CSV export with hash flattening
|
30
|
+
- Filtering capabilities
|
31
|
+
- Comprehensive test suite
|
32
|
+
- RuboCop integration
|
33
|
+
|
34
|
+
### Features
|
35
|
+
- ๐ Multi-Type Extraction: Constants, class methods, and more
|
36
|
+
- ๐ Hash Expansion: Expand hash values into readable sub-rows
|
37
|
+
- ๐ก๏ธ Error Handling: Graceful handling of missing methods and constants
|
38
|
+
- ๐ Rich Markdown Reports: Professional reports with configurable components
|
39
|
+
- ๐ CSV Export: Data analysis-friendly CSV output with hash flattening
|
40
|
+
- โ๏ธ Highly Configurable: Customize every aspect of the output
|
41
|
+
- ๐ Simple API: Chainable, intuitive interface
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Huy Nguyen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,417 @@
|
|
1
|
+
# ClassMetrix
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/class-metrix)
|
4
|
+
[](https://github.com/patrick204nqh/class-metrix/actions/workflows/main.yml)
|
5
|
+
|
6
|
+
**ClassMetrix** is a Ruby gem that extracts and compares class behaviors (constants, class methods, and more) across multiple classes, generating clean markdown reports for analysis, documentation, and compliance auditing.
|
7
|
+
|
8
|
+
## โจ Features
|
9
|
+
|
10
|
+
- **๐ Multi-Type Extraction**: Constants, class methods, and more
|
11
|
+
- **๐ Hash Expansion**: Expand hash values into readable sub-rows
|
12
|
+
- **๐ก๏ธ Error Handling**: Graceful handling of missing methods and constants
|
13
|
+
- **๐ Rich Markdown Reports**: Professional reports with configurable components
|
14
|
+
- **๐ CSV Export**: Data analysis-friendly CSV output with hash flattening
|
15
|
+
- **โ๏ธ Highly Configurable**: Customize every aspect of the output
|
16
|
+
- **๐ Simple API**: Chainable, intuitive interface
|
17
|
+
|
18
|
+
## ๐ Quick Start
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
# Basic usage
|
22
|
+
ClassMetrix.extract(:constants)
|
23
|
+
.from([User, Admin, Guest])
|
24
|
+
.to_markdown
|
25
|
+
|
26
|
+
# Advanced usage with configuration
|
27
|
+
ClassMetrix.extract(:constants, :class_methods)
|
28
|
+
.from([DatabaseConfig, RedisConfig, S3Config])
|
29
|
+
.filter(/config$/)
|
30
|
+
.expand_hashes
|
31
|
+
.handle_errors
|
32
|
+
.to_markdown("audit_report.md",
|
33
|
+
title: "Service Configuration Audit",
|
34
|
+
footer_style: :detailed,
|
35
|
+
show_missing_summary: true
|
36
|
+
)
|
37
|
+
|
38
|
+
# CSV output with hash flattening
|
39
|
+
ClassMetrix.extract(:constants)
|
40
|
+
.from([DatabaseConfig, RedisConfig])
|
41
|
+
.expand_hashes
|
42
|
+
.to_csv("config_analysis.csv",
|
43
|
+
title: "Configuration Analysis",
|
44
|
+
flatten_hashes: true
|
45
|
+
)
|
46
|
+
```
|
47
|
+
|
48
|
+
## ๐ฆ Installation
|
49
|
+
|
50
|
+
Add to your Gemfile:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
gem 'class-metrix'
|
54
|
+
```
|
55
|
+
|
56
|
+
Or install directly:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
gem install class-metrix
|
60
|
+
```
|
61
|
+
|
62
|
+
## ๐ Usage Guide
|
63
|
+
|
64
|
+
### Basic Extraction
|
65
|
+
|
66
|
+
#### Constants
|
67
|
+
```ruby
|
68
|
+
# Extract constants from multiple classes
|
69
|
+
ClassMetrix.extract(:constants)
|
70
|
+
.from([User, Admin, Guest])
|
71
|
+
.to_markdown
|
72
|
+
|
73
|
+
# Output:
|
74
|
+
# | Constant | User | Admin | Guest |
|
75
|
+
# |------------|----------|----------|----------|
|
76
|
+
# | ROLE_NAME | 'user' | 'admin' | 'guest' |
|
77
|
+
# | PERMISSION | 'read' | 'write' | 'read' |
|
78
|
+
```
|
79
|
+
|
80
|
+
#### Class Methods
|
81
|
+
```ruby
|
82
|
+
# Extract class method results
|
83
|
+
ClassMetrix.extract(:class_methods)
|
84
|
+
.from([DatabaseConfig, RedisConfig])
|
85
|
+
.filter(/config$/)
|
86
|
+
.to_markdown
|
87
|
+
|
88
|
+
# Output:
|
89
|
+
# | Method | DatabaseConfig | RedisConfig |
|
90
|
+
# |---------------|--------------------------|--------------------------|
|
91
|
+
# | db_config | {:host=>"localhost"} | ๐ซ Not defined |
|
92
|
+
# | cache_config | ๐ซ Not defined | {:host=>"redis.local"} |
|
93
|
+
```
|
94
|
+
|
95
|
+
#### Multi-Type Extraction
|
96
|
+
```ruby
|
97
|
+
# Combine multiple extraction types in one table
|
98
|
+
ClassMetrix.extract(:constants, :class_methods)
|
99
|
+
.from([User, Admin])
|
100
|
+
.to_markdown
|
101
|
+
|
102
|
+
# Output:
|
103
|
+
# | Type | Behavior | User | Admin |
|
104
|
+
# |--------------|-------------|----------|----------|
|
105
|
+
# | Constant | ROLE_NAME | 'user' | 'admin' |
|
106
|
+
# | Class Method | permissions | ['read'] | ['read', 'write'] |
|
107
|
+
```
|
108
|
+
|
109
|
+
### Advanced Features
|
110
|
+
|
111
|
+
#### Hash Expansion
|
112
|
+
```ruby
|
113
|
+
# Expand hash values into readable sub-rows
|
114
|
+
ClassMetrix.extract(:constants)
|
115
|
+
.from([DatabaseConfig, RedisConfig])
|
116
|
+
.expand_hashes
|
117
|
+
.to_markdown
|
118
|
+
|
119
|
+
# Output:
|
120
|
+
# | Constant | DatabaseConfig | RedisConfig |
|
121
|
+
# |-------------|--------------------------|--------------------------|
|
122
|
+
# | DB_CONFIG | {:host=>"localhost"} | {:host=>"redis.local"} |
|
123
|
+
# | .host | localhost | redis.local |
|
124
|
+
# | .port | 5432 | โ (missing key) |
|
125
|
+
# | .timeout | โ (missing key) | 30 |
|
126
|
+
```
|
127
|
+
|
128
|
+
#### Error Handling
|
129
|
+
```ruby
|
130
|
+
# Handle missing methods and constants gracefully
|
131
|
+
ClassMetrix.extract(:class_methods)
|
132
|
+
.from([ServiceA, ServiceB])
|
133
|
+
.handle_errors
|
134
|
+
.to_markdown
|
135
|
+
|
136
|
+
# Error indicators:
|
137
|
+
# ๐ซ Not defined - Constant/method doesn't exist
|
138
|
+
# ๐ซ No method - Method doesn't exist
|
139
|
+
# โ ๏ธ Error: msg - Runtime error with context
|
140
|
+
# โ - nil or false values
|
141
|
+
# โ
- true values
|
142
|
+
# โ - Missing hash key
|
143
|
+
```
|
144
|
+
|
145
|
+
#### Filtering
|
146
|
+
```ruby
|
147
|
+
# Filter behaviors by pattern
|
148
|
+
ClassMetrix.extract(:constants)
|
149
|
+
.from([User, Admin, Guest])
|
150
|
+
.filter(/^ROLE_/, /^PERMISSION_/)
|
151
|
+
.to_markdown
|
152
|
+
|
153
|
+
# Multiple filters (OR logic)
|
154
|
+
ClassMetrix.extract(:class_methods)
|
155
|
+
.from([ConfigA, ConfigB])
|
156
|
+
.filter(/config$/, /setup$/)
|
157
|
+
.to_markdown
|
158
|
+
```
|
159
|
+
|
160
|
+
#### CSV Output
|
161
|
+
```ruby
|
162
|
+
# Basic CSV output
|
163
|
+
ClassMetrix.extract(:constants)
|
164
|
+
.from([DatabaseConfig, RedisConfig])
|
165
|
+
.to_csv("config.csv")
|
166
|
+
|
167
|
+
# CSV with hash flattening (separate columns for each hash key)
|
168
|
+
ClassMetrix.extract(:constants)
|
169
|
+
.from([DatabaseConfig, RedisConfig])
|
170
|
+
.expand_hashes
|
171
|
+
.to_csv("config_flat.csv", flatten_hashes: true)
|
172
|
+
|
173
|
+
# CSV with hash expansion (sub-rows for hash keys)
|
174
|
+
ClassMetrix.extract(:constants)
|
175
|
+
.from([DatabaseConfig, RedisConfig])
|
176
|
+
.expand_hashes
|
177
|
+
.to_csv("config_expanded.csv", flatten_hashes: false)
|
178
|
+
|
179
|
+
# Custom CSV options
|
180
|
+
ClassMetrix.extract(:class_methods)
|
181
|
+
.from([ServiceA, ServiceB])
|
182
|
+
.to_csv(
|
183
|
+
separator: ";", # Use semicolon separator
|
184
|
+
null_value: "N/A", # Custom null value
|
185
|
+
show_metadata: false # No comment headers
|
186
|
+
)
|
187
|
+
```
|
188
|
+
|
189
|
+
## โ๏ธ Configuration Options
|
190
|
+
|
191
|
+
ClassMetrix offers extensive configuration options for customizing report generation:
|
192
|
+
|
193
|
+
### Markdown Report Options
|
194
|
+
```ruby
|
195
|
+
ClassMetrix.extract(:constants)
|
196
|
+
.from([User, Admin])
|
197
|
+
.to_markdown(
|
198
|
+
# File and title
|
199
|
+
"report.md",
|
200
|
+
title: "Custom Report Title",
|
201
|
+
|
202
|
+
# Content sections
|
203
|
+
show_metadata: true, # Show title and report info
|
204
|
+
show_classes: true, # Show "Classes Analyzed" section
|
205
|
+
show_extraction_info: true, # Show "Extraction Types" section
|
206
|
+
show_missing_summary: false, # Show missing behaviors summary
|
207
|
+
|
208
|
+
# Footer configuration
|
209
|
+
show_footer: true, # Show footer
|
210
|
+
footer_style: :detailed, # :default, :minimal, :detailed
|
211
|
+
show_timestamp: true, # Include generation timestamp
|
212
|
+
custom_footer: "Custom note", # Custom footer message
|
213
|
+
|
214
|
+
# Table formatting
|
215
|
+
table_style: :standard, # :standard, :compact, :wide
|
216
|
+
min_column_width: 3, # Minimum column width
|
217
|
+
max_column_width: 50, # Maximum column width (for :compact style)
|
218
|
+
|
219
|
+
# Missing behaviors analysis
|
220
|
+
summary_style: :grouped # :grouped, :flat, :detailed
|
221
|
+
)
|
222
|
+
```
|
223
|
+
|
224
|
+
### CSV Output Options
|
225
|
+
```ruby
|
226
|
+
ClassMetrix.extract(:constants)
|
227
|
+
.from([User, Admin])
|
228
|
+
.to_csv(
|
229
|
+
# File and title
|
230
|
+
"report.csv",
|
231
|
+
title: "Custom CSV Report",
|
232
|
+
|
233
|
+
# Content options
|
234
|
+
show_metadata: true, # Show comment headers
|
235
|
+
comment_char: "#", # Comment character for metadata
|
236
|
+
|
237
|
+
# CSV formatting
|
238
|
+
separator: ",", # Column separator (comma, semicolon, tab)
|
239
|
+
quote_char: '"', # Quote character
|
240
|
+
null_value: "", # Value for nil/missing data
|
241
|
+
|
242
|
+
# Hash handling
|
243
|
+
flatten_hashes: true, # Flatten hashes into separate columns
|
244
|
+
# false = expand into sub-rows
|
245
|
+
)
|
246
|
+
```
|
247
|
+
|
248
|
+
### Footer Styles
|
249
|
+
|
250
|
+
#### Default Footer
|
251
|
+
```markdown
|
252
|
+
---
|
253
|
+
*Report generated by ClassMetrix gem*
|
254
|
+
```
|
255
|
+
|
256
|
+
#### Minimal Footer
|
257
|
+
```markdown
|
258
|
+
---
|
259
|
+
*Generated by ClassMetrix*
|
260
|
+
```
|
261
|
+
|
262
|
+
#### Detailed Footer
|
263
|
+
```markdown
|
264
|
+
---
|
265
|
+
## Report Information
|
266
|
+
|
267
|
+
- **Generated by**: [ClassMetrix gem](https://github.com/your-username/class-metrix)
|
268
|
+
- **Generated at**: 2024-01-15 14:30:25 UTC
|
269
|
+
- **Ruby version**: 3.2.0
|
270
|
+
```
|
271
|
+
|
272
|
+
### Missing Behaviors Styles
|
273
|
+
|
274
|
+
#### Grouped (Default)
|
275
|
+
```markdown
|
276
|
+
## Missing Behaviors Summary
|
277
|
+
|
278
|
+
### DatabaseConfig
|
279
|
+
- `redis_config` - ๐ซ Not defined
|
280
|
+
- `cache_timeout` - ๐ซ No method
|
281
|
+
|
282
|
+
### RedisConfig
|
283
|
+
- `db_config` - ๐ซ Not defined
|
284
|
+
```
|
285
|
+
|
286
|
+
#### Flat
|
287
|
+
```markdown
|
288
|
+
## Missing Behaviors
|
289
|
+
|
290
|
+
- **DatabaseConfig**: `redis_config` - ๐ซ Not defined
|
291
|
+
- **DatabaseConfig**: `cache_timeout` - ๐ซ No method
|
292
|
+
- **RedisConfig**: `db_config` - ๐ซ Not defined
|
293
|
+
```
|
294
|
+
|
295
|
+
#### Detailed
|
296
|
+
```markdown
|
297
|
+
## Missing Behaviors Analysis
|
298
|
+
|
299
|
+
**Summary**: 3 missing behaviors across 2 classes
|
300
|
+
|
301
|
+
### ๐ซ Not (2 items)
|
302
|
+
- **DatabaseConfig**: `redis_config` - ๐ซ Not defined
|
303
|
+
- **RedisConfig**: `db_config` - ๐ซ Not defined
|
304
|
+
|
305
|
+
### ๐ซ No (1 items)
|
306
|
+
- **DatabaseConfig**: `cache_timeout` - ๐ซ No method
|
307
|
+
```
|
308
|
+
|
309
|
+
## ๐ฏ Real-World Examples
|
310
|
+
|
311
|
+
### Microservices Configuration Audit
|
312
|
+
```ruby
|
313
|
+
# Audit configuration consistency across services
|
314
|
+
services = [DatabaseService, RedisService, S3Service, AuthService]
|
315
|
+
|
316
|
+
ClassMetrix.extract(:constants, :class_methods)
|
317
|
+
.from(services)
|
318
|
+
.filter(/CONFIG/, /timeout/, /pool/)
|
319
|
+
.expand_hashes
|
320
|
+
.handle_errors
|
321
|
+
.to_markdown("microservices_audit.md",
|
322
|
+
title: "Microservices Configuration Audit",
|
323
|
+
show_missing_summary: true,
|
324
|
+
summary_style: :detailed,
|
325
|
+
footer_style: :detailed
|
326
|
+
)
|
327
|
+
```
|
328
|
+
|
329
|
+
### Policy Classes Comparison
|
330
|
+
```ruby
|
331
|
+
# Compare authorization policies
|
332
|
+
policies = [UserPolicy, AdminPolicy, ModeratorPolicy]
|
333
|
+
|
334
|
+
ClassMetrix.extract(:constants)
|
335
|
+
.from(policies)
|
336
|
+
.filter(/^PERMISSION_/, /^ROLE_/)
|
337
|
+
.to_markdown("policy_comparison.md",
|
338
|
+
title: "Authorization Policy Analysis",
|
339
|
+
show_timestamp: true
|
340
|
+
)
|
341
|
+
```
|
342
|
+
|
343
|
+
### API Version Compatibility
|
344
|
+
```ruby
|
345
|
+
# Check API compatibility across versions
|
346
|
+
apis = [V1::UsersAPI, V2::UsersAPI, V3::UsersAPI]
|
347
|
+
|
348
|
+
ClassMetrix.extract(:class_methods)
|
349
|
+
.from(apis)
|
350
|
+
.filter(/^endpoint_/, /^validate_/)
|
351
|
+
.handle_errors
|
352
|
+
.to_markdown("api_compatibility.md",
|
353
|
+
title: "API Version Compatibility Report",
|
354
|
+
show_missing_summary: true,
|
355
|
+
summary_style: :flat
|
356
|
+
)
|
357
|
+
```
|
358
|
+
|
359
|
+
## ๐๏ธ Architecture
|
360
|
+
|
361
|
+
ClassMetrix uses a modular component architecture for maximum flexibility:
|
362
|
+
|
363
|
+
```
|
364
|
+
MarkdownFormatter
|
365
|
+
โโโ HeaderComponent # Title, classes, extraction info
|
366
|
+
โโโ TableComponent # Table formatting and hash expansion
|
367
|
+
โโโ MissingBehaviorsComponent # Missing behavior analysis
|
368
|
+
โโโ FooterComponent # Footer with various styles
|
369
|
+
```
|
370
|
+
|
371
|
+
Each component is independently configurable and can be customized for specific needs.
|
372
|
+
|
373
|
+
## ๐งช Development
|
374
|
+
|
375
|
+
```bash
|
376
|
+
# Clone the repository
|
377
|
+
git clone https://github.com/your-username/class-metrix.git
|
378
|
+
cd class-metrix
|
379
|
+
|
380
|
+
# Install dependencies
|
381
|
+
bundle install
|
382
|
+
|
383
|
+
# Run tests
|
384
|
+
bundle exec rspec
|
385
|
+
|
386
|
+
# Run examples
|
387
|
+
ruby examples/basic/01_simple_constants.rb
|
388
|
+
ruby examples/advanced/hash_expansion.rb
|
389
|
+
```
|
390
|
+
|
391
|
+
## ๐ Requirements
|
392
|
+
|
393
|
+
- Ruby 2.7+
|
394
|
+
- No runtime dependencies (pure Ruby implementation)
|
395
|
+
|
396
|
+
## ๐ค Contributing
|
397
|
+
|
398
|
+
1. Fork the repository
|
399
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
400
|
+
3. Commit your changes (`git commit -am 'Add amazing feature'`)
|
401
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
402
|
+
5. Open a Pull Request
|
403
|
+
|
404
|
+
## ๐ License
|
405
|
+
|
406
|
+
This gem is available as open source under the terms of the [MIT License](LICENSE).
|
407
|
+
|
408
|
+
## ๐ Links
|
409
|
+
|
410
|
+
- [Documentation](https://github.com/your-username/class-metrix/wiki)
|
411
|
+
- [Examples](examples/)
|
412
|
+
- [Build Guide](BUILD_GUIDE.md)
|
413
|
+
- [Changelog](CHANGELOG.md)
|
414
|
+
|
415
|
+
---
|
416
|
+
|
417
|
+
**Built with โค๏ธ for Ruby developers who love clean, maintainable code.**
|