Skip to content

Commit 2ae8cf5

Browse files
committed
add @code_total and @tests_total to output in json
adjust labels adjust order fix console output to fix tests adjust json tests fix tests from console output Add change to CHANGELOG.md
1 parent 00ccb50 commit 2ae8cf5

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# main ([unreleased](https://github.com/fastruby/rails_stats/compare/v1.0.2...main))
22

3-
*
3+
* [BUGFIX: Fix JSON output missing Code and Tests total count](https://github.com/fastruby/rails_stats/pull/40)
44

55
# v2.0.1 ([commits](https://github.com/fastruby/rails_stats/compare/v2.0.0...v2.0.1))
66

lib/rails_stats/json_formatter.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ class JSONFormatter < StatsFormatter
55
def result
66
@result = @statistics.map { |key, stats| stat_hash(key, stats) }
77

8-
if @grand_total
9-
@result << stat_hash("Total", @grand_total).merge(code_test_hash)
10-
end
8+
@result << stat_hash("Code", @code_total).merge(code_test_hash) if @code_total
9+
@result << stat_hash("Tests", @tests_total).merge(code_test_hash) if @tests_total
10+
@result << stat_hash("Total", @grand_total).merge(code_test_hash) if @grand_total
1111

1212
@result
1313
end

test/fixtures/console-output.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
+-----------------------|------------|----------------+
22
| Name | Total Deps | 1st Level Deps |
33
+-----------------------|------------|----------------+
4-
| simplecov-console | 7 | 3 |
5-
| codecov | 5 | 2 |
4+
| simplecov-console | 8 | 3 |
5+
| codecov | 4 | 1 |
66
| rails_stats | 4 | 2 |
77
| simplecov | 3 | 3 |
88
| minitest-around | 1 | 1 |
@@ -21,7 +21,7 @@
2121
| Name | Files | Lines | LOC | Classes | Methods | M/C | LOC/M |
2222
+----------------------+---------+---------+---------+---------+---------+-----+-------+
2323
| Channels | 2 | 8 | 8 | 2 | 0 | 0 | 0 |
24-
| Configuration | 19 | 417 | 111 | 1 | 0 | 0 | 0 |
24+
| Configuration | 19 | 417 | 111 | 1 | 0 | 0 | 0 |
2525
| Controllers | 1 | 7 | 6 | 1 | 1 | 1 | 4 |
2626
| Helpers | 1 | 3 | 3 | 0 | 0 | 0 | 0 |
2727
| Javascripts | 3 | 27 | 7 | 0 | 0 | 0 | 0 |

test/lib/rails_stats/json_formatter_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,28 @@
113113
"methods": "0",
114114
"m_over_c": "0",
115115
"loc_over_m": "0"
116+
},{
117+
"name": "Code",
118+
"files": "30",
119+
"lines": "477",
120+
"loc": "145",
121+
"classes": "7",
122+
"methods": "1",
123+
"m_over_c": "0",
124+
"loc_over_m": "143",
125+
"code_to_test_ratio": "0.0",
126+
"total": true
127+
},{
128+
"name": "Tests",
129+
"files": "4",
130+
"lines": "7",
131+
"loc": "6",
132+
"classes": "2",
133+
"methods": "0",
134+
"m_over_c": "0",
135+
"loc_over_m": "0",
136+
"code_to_test_ratio": "0.0",
137+
"total": true
116138
}, {
117139
"name": "Total",
118140
"files": "34",

0 commit comments

Comments
 (0)