Class: RSpecLetAnalyzer::Formatters::JsonFormatter
- Inherits:
-
Object
- Object
- RSpecLetAnalyzer::Formatters::JsonFormatter
- Defined in:
- lib/rspec_let_analyzer/formatters/json_formatter.rb
Instance Method Summary collapse
Instance Method Details
#add_runtime_metrics(output, metrics) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/rspec_let_analyzer/formatters/json_formatter.rb', line 31 def add_runtime_metrics(output, metrics) parsed = JSON.parse(output) parsed['runtime_metrics'] = { analyze_time: metrics[:analyze_time].round(4), format_time: metrics[:format_time].round(4), total_time: metrics[:total_time].round(4) } parsed.to_json end |
#format(analyzer:, limit:, sort_by:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rspec_let_analyzer/formatters/json_formatter.rb', line 8 def format(analyzer:, limit:, sort_by:) sorted = analyzer.top(limit, sort_by) result = { top_files: sorted, totals: analyzer.totals, total_files: analyzer.results.size, nesting_depth: analyzer.nesting_depth, sort_by: sort_by } if analyzer.factory_stats top_factories = analyzer.top_factories(limit) result[:factorybot] = { top_factories: top_factories.map { |factory, count| { factory: factory, count: count } }, total_unique: analyzer.factory_stats.size, total_usage: analyzer.factory_stats.values.sum } end result.to_json end |