File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 3
3
module RailsStats
4
4
class JSONFormatter < StatsFormatter
5
5
def result
6
- @result = @statistics . map { |key , stats | stat_hash ( key , stats ) }
7
-
6
+ @result = [ ]
7
+ # Capture stdout
8
+ old_stdout = $stdout
9
+ $stdout = StringIO . new
10
+ Bundler ::Stats ::CLI . start ( [ "-f" , "json" ] )
11
+ bundler_stats_cli_json_result = $stdout. string
12
+ $stdout = old_stdout
13
+
14
+ # Parse and append the JSON result
15
+ @result << JSON . parse ( bundler_stats_cli_json_result ) unless bundler_stats_cli_json_result . strip . empty?
16
+
17
+ @result += @statistics . map { |key , stats | stat_hash ( key , stats ) }
8
18
@result << stat_hash ( "Code" , @code_total ) . merge ( code_test_hash ) if @code_total
9
19
@result << stat_hash ( "Tests" , @tests_total ) . merge ( code_test_hash ) if @tests_total
10
20
@result << stat_hash ( "Total" , @grand_total ) . merge ( code_test_hash ) if @grand_total
You can’t perform that action at this time.
0 commit comments