class-metrix 0.1.2 → 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.
- checksums.yaml +4 -4
- data/.editorconfig +48 -0
- data/.vscode/README.md +72 -0
- data/.vscode/extensions.json +28 -0
- data/.vscode/launch.json +32 -0
- data/.vscode/settings.json +88 -0
- data/.vscode/tasks.json +99 -0
- data/CHANGELOG.md +71 -4
- data/README.md +41 -7
- data/docs/ARCHITECTURE.md +501 -0
- data/examples/README.md +161 -114
- data/examples/basic_usage.rb +88 -0
- data/examples/debug_levels_demo.rb +65 -0
- data/examples/debug_mode_demo.rb +75 -0
- data/examples/inheritance_and_modules.rb +155 -0
- data/lib/class_metrix/extractor.rb +106 -11
- data/lib/class_metrix/extractors/constants_extractor.rb +155 -21
- data/lib/class_metrix/extractors/methods_extractor.rb +186 -21
- data/lib/class_metrix/extractors/multi_type_extractor.rb +6 -5
- data/lib/class_metrix/formatters/components/footer_component.rb +1 -1
- data/lib/class_metrix/formatters/components/table_component/column_width_calculator.rb +56 -0
- data/lib/class_metrix/formatters/components/table_component/row_processor.rb +138 -0
- data/lib/class_metrix/formatters/components/table_component/table_data_extractor.rb +54 -0
- data/lib/class_metrix/formatters/components/table_component/table_renderer.rb +55 -0
- data/lib/class_metrix/formatters/components/table_component.rb +30 -244
- data/lib/class_metrix/formatters/shared/markdown_table_builder.rb +10 -5
- data/lib/class_metrix/formatters/shared/table_builder.rb +84 -21
- data/lib/class_metrix/formatters/shared/value_processor.rb +72 -16
- data/lib/class_metrix/utils/debug_logger.rb +159 -0
- data/lib/class_metrix/version.rb +1 -1
- metadata +17 -9
- data/examples/advanced/error_handling.rb +0 -199
- data/examples/advanced/hash_expansion.rb +0 -180
- data/examples/basic/01_simple_constants.rb +0 -56
- data/examples/basic/02_simple_methods.rb +0 -99
- data/examples/basic/03_multi_type_extraction.rb +0 -116
- data/examples/components/configurable_reports.rb +0 -201
- data/examples/csv_output_demo.rb +0 -237
- data/examples/real_world/microservices_audit.rb +0 -312
@@ -1,312 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative "../../lib/class_metrix"
|
5
|
-
|
6
|
-
puts "=== Real-World Example: Microservices Configuration Audit ==="
|
7
|
-
puts
|
8
|
-
|
9
|
-
# Realistic microservice configuration classes
|
10
|
-
class UserService
|
11
|
-
# Service metadata
|
12
|
-
SERVICE_NAME = "user-service"
|
13
|
-
VERSION = "2.1.0"
|
14
|
-
PORT = 8001
|
15
|
-
ENVIRONMENT = "production"
|
16
|
-
|
17
|
-
# Feature flags
|
18
|
-
ENABLE_CACHING = true
|
19
|
-
ENABLE_METRICS = true
|
20
|
-
ENABLE_TRACING = false
|
21
|
-
RATE_LIMITING_ENABLED = true
|
22
|
-
|
23
|
-
# Configuration methods
|
24
|
-
def self.database_config
|
25
|
-
{
|
26
|
-
host: "user-db.internal",
|
27
|
-
port: 5432,
|
28
|
-
database: "users_production",
|
29
|
-
pool_size: 20,
|
30
|
-
timeout: 30,
|
31
|
-
ssl: true,
|
32
|
-
backup_enabled: true
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.redis_config
|
37
|
-
{
|
38
|
-
host: "user-redis.internal",
|
39
|
-
port: 6379,
|
40
|
-
database: 0,
|
41
|
-
timeout: 5,
|
42
|
-
max_connections: 50
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.rate_limit_config
|
47
|
-
{
|
48
|
-
requests_per_minute: 1000,
|
49
|
-
burst_size: 100,
|
50
|
-
enabled: true
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.health_status
|
55
|
-
"healthy"
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.memory_usage_mb
|
59
|
-
512
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.active_connections
|
63
|
-
45
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class OrderService
|
68
|
-
# Service metadata
|
69
|
-
SERVICE_NAME = "order-service"
|
70
|
-
VERSION = "1.8.5"
|
71
|
-
PORT = 8002
|
72
|
-
ENVIRONMENT = "production"
|
73
|
-
|
74
|
-
# Feature flags
|
75
|
-
ENABLE_CACHING = true
|
76
|
-
ENABLE_METRICS = true
|
77
|
-
ENABLE_TRACING = true
|
78
|
-
RATE_LIMITING_ENABLED = true
|
79
|
-
|
80
|
-
# Configuration methods
|
81
|
-
def self.database_config
|
82
|
-
{
|
83
|
-
host: "order-db.internal",
|
84
|
-
port: 5432,
|
85
|
-
database: "orders_production",
|
86
|
-
pool_size: 30,
|
87
|
-
timeout: 45,
|
88
|
-
ssl: true,
|
89
|
-
backup_enabled: true,
|
90
|
-
read_replicas: 2
|
91
|
-
}
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.redis_config
|
95
|
-
{
|
96
|
-
host: "order-redis.internal",
|
97
|
-
port: 6379,
|
98
|
-
database: 1,
|
99
|
-
timeout: 3,
|
100
|
-
max_connections: 100,
|
101
|
-
cluster_enabled: true
|
102
|
-
}
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.rate_limit_config
|
106
|
-
{
|
107
|
-
requests_per_minute: 500,
|
108
|
-
burst_size: 50,
|
109
|
-
enabled: true,
|
110
|
-
premium_multiplier: 2.0
|
111
|
-
}
|
112
|
-
end
|
113
|
-
|
114
|
-
def self.health_status
|
115
|
-
"healthy"
|
116
|
-
end
|
117
|
-
|
118
|
-
def self.memory_usage_mb
|
119
|
-
768
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.active_connections
|
123
|
-
127
|
124
|
-
end
|
125
|
-
|
126
|
-
def self.queue_size
|
127
|
-
42
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
class PaymentService
|
132
|
-
# Service metadata
|
133
|
-
SERVICE_NAME = "payment-service"
|
134
|
-
VERSION = "3.0.1"
|
135
|
-
PORT = 8003
|
136
|
-
ENVIRONMENT = "production"
|
137
|
-
|
138
|
-
# Feature flags
|
139
|
-
ENABLE_CACHING = false # Disabled for security
|
140
|
-
ENABLE_METRICS = true
|
141
|
-
ENABLE_TRACING = true
|
142
|
-
RATE_LIMITING_ENABLED = true
|
143
|
-
|
144
|
-
# Configuration methods
|
145
|
-
def self.database_config
|
146
|
-
{
|
147
|
-
host: "payment-db.internal",
|
148
|
-
port: 5432,
|
149
|
-
database: "payments_production",
|
150
|
-
pool_size: 15,
|
151
|
-
timeout: 60,
|
152
|
-
ssl: true,
|
153
|
-
backup_enabled: true,
|
154
|
-
encryption: "AES-256"
|
155
|
-
}
|
156
|
-
end
|
157
|
-
|
158
|
-
def self.redis_config
|
159
|
-
{
|
160
|
-
host: "payment-redis.internal",
|
161
|
-
port: 6379,
|
162
|
-
database: 2,
|
163
|
-
timeout: 2,
|
164
|
-
max_connections: 25,
|
165
|
-
ssl: true
|
166
|
-
}
|
167
|
-
end
|
168
|
-
|
169
|
-
def self.rate_limit_config
|
170
|
-
{
|
171
|
-
requests_per_minute: 100,
|
172
|
-
burst_size: 10,
|
173
|
-
enabled: true,
|
174
|
-
strict_mode: true
|
175
|
-
}
|
176
|
-
end
|
177
|
-
|
178
|
-
def self.health_status
|
179
|
-
"healthy"
|
180
|
-
end
|
181
|
-
|
182
|
-
def self.memory_usage_mb
|
183
|
-
256
|
184
|
-
end
|
185
|
-
|
186
|
-
def self.active_connections
|
187
|
-
12
|
188
|
-
end
|
189
|
-
|
190
|
-
def self.encryption_status
|
191
|
-
"AES-256-GCM"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
puts "=== Microservices Defined ==="
|
196
|
-
puts "UserService, OrderService, PaymentService"
|
197
|
-
puts "Each service has metadata, feature flags, and configuration methods"
|
198
|
-
puts
|
199
|
-
|
200
|
-
# 1. Service Overview
|
201
|
-
puts "🏢 1. SERVICE OVERVIEW"
|
202
|
-
puts "=" * 70
|
203
|
-
result = ClassMetrix.extract(:constants)
|
204
|
-
.from([UserService, OrderService, PaymentService])
|
205
|
-
.filter(/SERVICE_NAME|VERSION|PORT|ENVIRONMENT/)
|
206
|
-
.to_markdown
|
207
|
-
|
208
|
-
puts result
|
209
|
-
puts
|
210
|
-
|
211
|
-
# 2. Feature Flags Comparison
|
212
|
-
puts "🚩 2. FEATURE FLAGS COMPARISON"
|
213
|
-
puts "=" * 70
|
214
|
-
result = ClassMetrix.extract(:constants)
|
215
|
-
.from([UserService, OrderService, PaymentService])
|
216
|
-
.filter(/ENABLE_|RATE_LIMITING/)
|
217
|
-
.to_markdown
|
218
|
-
|
219
|
-
puts result
|
220
|
-
puts
|
221
|
-
|
222
|
-
# 3. Database Configuration Analysis
|
223
|
-
puts "🗄️ 3. DATABASE CONFIGURATION ANALYSIS"
|
224
|
-
puts "=" * 70
|
225
|
-
result = ClassMetrix.extract(:class_methods)
|
226
|
-
.from([UserService, OrderService, PaymentService])
|
227
|
-
.filter(/database_config/)
|
228
|
-
.expand_hashes
|
229
|
-
.to_markdown
|
230
|
-
|
231
|
-
puts result
|
232
|
-
puts
|
233
|
-
|
234
|
-
# 4. Redis Configuration Comparison
|
235
|
-
puts "🔴 4. REDIS CONFIGURATION COMPARISON"
|
236
|
-
puts "=" * 70
|
237
|
-
result = ClassMetrix.extract(:class_methods)
|
238
|
-
.from([UserService, OrderService, PaymentService])
|
239
|
-
.filter(/redis_config/)
|
240
|
-
.expand_hashes
|
241
|
-
.to_markdown
|
242
|
-
|
243
|
-
puts result
|
244
|
-
puts
|
245
|
-
|
246
|
-
# 5. Rate Limiting Configuration
|
247
|
-
puts "⚡ 5. RATE LIMITING CONFIGURATION"
|
248
|
-
puts "=" * 70
|
249
|
-
result = ClassMetrix.extract(:class_methods)
|
250
|
-
.from([UserService, OrderService, PaymentService])
|
251
|
-
.filter(/rate_limit_config/)
|
252
|
-
.expand_hashes
|
253
|
-
.to_markdown
|
254
|
-
|
255
|
-
puts result
|
256
|
-
puts
|
257
|
-
|
258
|
-
# 6. Service Health & Performance
|
259
|
-
puts "📊 6. SERVICE HEALTH & PERFORMANCE METRICS"
|
260
|
-
puts "=" * 70
|
261
|
-
result = ClassMetrix.extract(:class_methods)
|
262
|
-
.from([UserService, OrderService, PaymentService])
|
263
|
-
.filter(/health_status|memory_usage|active_connections/)
|
264
|
-
.to_markdown
|
265
|
-
|
266
|
-
puts result
|
267
|
-
puts
|
268
|
-
|
269
|
-
# 7. Security Features
|
270
|
-
puts "🔒 7. SECURITY FEATURES ANALYSIS"
|
271
|
-
puts "=" * 70
|
272
|
-
result = ClassMetrix.extract(:constants, :class_methods)
|
273
|
-
.from([UserService, OrderService, PaymentService])
|
274
|
-
.filter(/CACHING|ssl|encryption/)
|
275
|
-
.to_markdown
|
276
|
-
|
277
|
-
puts result
|
278
|
-
puts
|
279
|
-
|
280
|
-
# 8. Complete Configuration Audit
|
281
|
-
puts "📋 8. COMPLETE CONFIGURATION AUDIT"
|
282
|
-
puts "=" * 70
|
283
|
-
result = ClassMetrix.extract(:constants, :class_methods)
|
284
|
-
.from([UserService, OrderService, PaymentService])
|
285
|
-
.handle_errors
|
286
|
-
.expand_hashes
|
287
|
-
.to_markdown
|
288
|
-
|
289
|
-
puts "Full audit contains #{result.lines.count} lines"
|
290
|
-
puts "Saving to microservices_audit_report.md..."
|
291
|
-
|
292
|
-
# Save comprehensive report
|
293
|
-
ClassMetrix.extract(:constants, :class_methods)
|
294
|
-
.from([UserService, OrderService, PaymentService])
|
295
|
-
.handle_errors
|
296
|
-
.expand_hashes
|
297
|
-
.to_markdown("microservices_audit_report.md")
|
298
|
-
|
299
|
-
puts "✅ Complete audit saved to: microservices_audit_report.md"
|
300
|
-
puts
|
301
|
-
|
302
|
-
puts "🎯 Real-World Use Cases Demonstrated:"
|
303
|
-
puts "• Service metadata comparison across microservices"
|
304
|
-
puts "• Feature flag consistency analysis"
|
305
|
-
puts "• Database configuration standardization check"
|
306
|
-
puts "• Cache configuration comparison"
|
307
|
-
puts "• Rate limiting policy analysis"
|
308
|
-
puts "• Performance metrics monitoring"
|
309
|
-
puts "• Security configuration audit"
|
310
|
-
puts "• Complete infrastructure overview"
|
311
|
-
puts "• Configuration drift detection"
|
312
|
-
puts "• Compliance reporting"
|