rails_stats 2.0.1 → 2.2.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +23 -15
  3. data/CHANGELOG.md +18 -3
  4. data/Gemfile +2 -2
  5. data/README.md +224 -232
  6. data/bin/rails-stats +27 -0
  7. data/lib/rails_stats/all.rb +8 -0
  8. data/lib/rails_stats/app_statistics.rb +1 -1
  9. data/lib/rails_stats/code_statistics_calculator.rb +18 -0
  10. data/lib/rails_stats/console_formatter.rb +60 -12
  11. data/lib/rails_stats/cucumber_statistics.rb +1 -1
  12. data/lib/rails_stats/gem_statistics.rb +1 -1
  13. data/lib/rails_stats/json_formatter.rb +59 -6
  14. data/lib/rails_stats/pack_finder.rb +67 -0
  15. data/lib/rails_stats/root_statistics.rb +1 -1
  16. data/lib/rails_stats/spec_statistics.rb +1 -1
  17. data/lib/rails_stats/stats_calculator.rb +135 -5
  18. data/lib/rails_stats/stats_formatter.rb +1 -0
  19. data/lib/rails_stats/tasks.rb +4 -1
  20. data/lib/rails_stats/test_statistics.rb +1 -1
  21. data/lib/rails_stats/util.rb +10 -2
  22. data/lib/rails_stats/version.rb +1 -1
  23. data/rails_stats.gemspec +4 -3
  24. data/test/dummy/app/javascript/dummy.jsx +1 -0
  25. data/test/dummy/app/javascript/dummy.tsx +0 -0
  26. data/test/dummy/app/javascript/index.ts +0 -0
  27. data/test/dummy/app/models/comment.rb +3 -0
  28. data/test/dummy/app/models/pet.rb +2 -0
  29. data/test/dummy/app/models/user.rb +2 -0
  30. data/test/dummy/db/schema.rb +10 -0
  31. data/test/fixtures/console-output.txt +8 -24
  32. data/test/fixtures/packwerk_app/app/controllers/core_controller.rb +4 -0
  33. data/test/fixtures/packwerk_app/app/models/core_model.rb +5 -0
  34. data/test/fixtures/packwerk_app/components/billing/app/models/billing_model.rb +4 -0
  35. data/test/fixtures/packwerk_app/components/billing/lib/billing.rb +2 -0
  36. data/test/fixtures/packwerk_app/lib/core_lib.rb +3 -0
  37. data/test/fixtures/packwerk_app/package.yml +1 -0
  38. data/test/fixtures/packwerk_app/packs/pack1/app/controllers/pack1_controller.rb +4 -0
  39. data/test/fixtures/packwerk_app/packs/pack1/app/models/pack1_model.rb +6 -0
  40. data/test/fixtures/packwerk_app/packs/pack1/lib/pack1_lib.rb +2 -0
  41. data/test/fixtures/packwerk_app/packs/pack1/package.yml +3 -0
  42. data/test/fixtures/packwerk_app/packs/pack1/spec/models/pack1_model_spec.rb +4 -0
  43. data/test/fixtures/packwerk_app/packs/pack2/app/models/pack2_model.rb +4 -0
  44. data/test/fixtures/packwerk_app/packs/pack2/test/models/pack2_model_test.rb +4 -0
  45. data/test/lib/rails_stats/code_statistics_test.rb +5 -5
  46. data/test/lib/rails_stats/console_formatter_test.rb +48 -0
  47. data/test/lib/rails_stats/json_formatter_test.rb +70 -127
  48. data/test/lib/rails_stats/pack_finder_test.rb +29 -0
  49. data/test/lib/rails_stats/stats_calculator_test.rb +64 -0
  50. data/test/lib/rails_stats/util_test.rb +49 -0
  51. metadata +56 -3
data/README.md CHANGED
@@ -6,62 +6,159 @@ There were a few things missing to the included `rake stats`
6
6
 
7
7
  RailsStats mainly adds the ability to be run from outside the project in question. This can be helpful if the app you are interested in can not be booted for some reason.
8
8
 
9
- ### Run it outside Rails project
9
+ ### Run it as a command line tool
10
+
11
+ Once the gem is installed you can point the `rails-stats` executable at any
12
+ directory, without setting up a `Rakefile`. It accepts both absolute and
13
+ relative paths:
14
+
15
+ ```bash
16
+ $ rails-stats /path/to/app
17
+ $ rails-stats path/to/app
18
+ ```
19
+
20
+ When no path is given it defaults to the current directory:
21
+
22
+ ```bash
23
+ $ rails-stats
24
+ ```
10
25
 
11
- You will need a `Rakefile` in the directory where you call `rake` and you will
12
- need to require `rails_stats`:
26
+ You can also request JSON output by passing `json` as a second argument:
13
27
 
14
- ```ruby
15
- # Rakefile
16
- require "rails_stats"
28
+ ```bash
29
+ $ rails-stats path/to/app json
17
30
  ```
18
31
 
19
- Then you can call it:
32
+ #### Calling it through `rake`
33
+
34
+ If you prefer `rake`, there are two ways to reach the same code:
35
+
36
+ - **From any directory**, add a `Rakefile` that requires `rails_stats` and call
37
+ the task with a path:
38
+
39
+ ```ruby
40
+ # Rakefile
41
+ require "rails_stats"
42
+ ```
43
+
44
+ ```bash
45
+ $ rake stats\[/path/to/app/\]
46
+ ```
47
+
48
+ - **Inside your own Rails app**, add `rails_stats` to your `Gemfile` to
49
+ _replace_ the default `rake stats` implementation (you might need to
50
+ `require "rails_stats"` in your `Rakefile`), then run:
51
+
52
+ ```bash
53
+ $ bundle exec rake stats
54
+ ```
55
+
56
+ ### Run it outside Rails project
57
+
58
+ The quickest way is the `rails-stats` executable, which does not require a
59
+ `Rakefile`:
20
60
 
21
61
  ```bash
22
- $ rake stats\[/path/to/app/\]
23
-
24
- Directory: /path/to/app/
25
-
26
- +----------------------+-------+-------+---------+---------+-----+-------+
27
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
28
- +----------------------+-------+-------+---------+---------+-----+-------+
29
- | Controllers | 1848 | 1483 | 32 | 174 | 5 | 6 |
30
- | Helpers | 2257 | 1892 | 45 | 245 | 5 | 5 |
31
- | Jobs | 399 | 295 | 11 | 33 | 3 | 6 |
32
- | Models | 4584 | 3509 | 61 | 526 | 8 | 4 |
33
- | Observers | 42 | 22 | 2 | 5 | 2 | 2 |
34
- | Libraries | 2987 | 2272 | 30 | 287 | 9 | 5 |
35
- | Configuration | 1233 | 669 | 4 | 17 | 4 | 37 |
36
- | Spec Support | 1416 | 1152 | 4 | 30 | 7 | 36 |
37
- | Integration Tests | 91 | 73 | 0 | 1 | 0 | 71 |
38
- | Lib Tests | 101 | 83 | 0 | 1 | 0 | 81 |
39
- | Model Tests | 3397 | 2522 | 0 | 18 | 0 | 138 |
40
- | Cucumber Support | 739 | 521 | 0 | 1 | 0 | 519 |
41
- | Cucumber Features | 2711 | 2487 | 29 | 145 | 5 | 15 |
42
- +----------------------+-------+-------+---------+---------+-----+-------+
43
- | Total | 21805 | 16980 | 218 | 1483 | 6 | 9 |
44
- +----------------------+-------+-------+---------+---------+-----+-------+
45
- Code LOC: 10142 Test LOC: 6838 Code to Test Ratio: 1:0.7
62
+ $ rails-stats /path/to/app
63
+
64
+ Directory: /path/to/app
65
+
66
+ +-----------------------|------------|----------------+
67
+ | Name | Total Deps | 1st Level Deps |
68
+ +-----------------------|------------|----------------+
69
+ | simplecov-console | 7 | 3 |
70
+ | codecov | 5 | 2 |
71
+ | rails_stats | 4 | 2 |
72
+ | simplecov | 3 | 3 |
73
+ | minitest-around | 1 | 1 |
74
+ | bundler | 0 | 0 |
75
+ | byebug | 0 | 0 |
76
+ | minitest | 0 | 0 |
77
+ | minitest-spec-context | 0 | 0 |
78
+ +-----------------------|------------|----------------+
79
+
80
+ Declared Gems 9
81
+ Total Gems 18
82
+ Unpinned Versions 8
83
+ Github Refs 0
84
+
85
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
86
+ | Name | Files | Lines | LOC | Classes | Methods | M/C | LOC/M |
87
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
88
+ | Channels | 2 | 8 | 8 | 2 | 0 | 0 | 0 |
89
+ | Configuration | 19 | 417 | 111 | 1 | 0 | 0 | 0 |
90
+ | Controllers | 1 | 7 | 6 | 1 | 1 | 1 | 4 |
91
+ | Helpers | 1 | 3 | 3 | 0 | 0 | 0 | 0 |
92
+ | Javascripts | 3 | 27 | 7 | 0 | 0 | 0 | 0 |
93
+ | Jobs | 1 | 7 | 2 | 1 | 0 | 0 | 0 |
94
+ | Libraries | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
95
+ | Mailers | 1 | 4 | 4 | 1 | 0 | 0 | 0 |
96
+ | Model Tests | 2 | 5 | 4 | 2 | 0 | 0 | 0 |
97
+ | Models | 1 | 3 | 3 | 1 | 0 | 0 | 0 |
98
+ | Spec Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
99
+ | Test Support | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
100
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
101
+ | Code | 30 | 477 | 145 | 7 | 1 | 0 | 143 |
102
+ | Tests | 4 | 7 | 6 | 2 | 0 | 0 | 0 |
103
+ | Total | 34 | 484 | 151 | 9 | 1 | 0 | 149 |
104
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
105
+ Code LOC: 145 Test LOC: 6 Code to Test Ratio: 1:0.0 Files: 34
46
106
  ```
47
107
 
48
108
  ### Run it on many Rails engines
49
109
 
50
110
  ```bash
51
- $ for dir in /path/to/many/engines/*/; do bundle exec rake stats[$dir]; done
111
+ $ for dir in /path/to/many/engines/*/; do rails-stats "$dir"; done
112
+ ```
113
+
114
+ ### Component-based and Packwerk (packs) applications
115
+
116
+ RailsStats understands large Rails monoliths that are organized into
117
+ [packs](https://github.com/Shopify/packwerk) (via
118
+ [packs-rails](https://github.com/rubyatscale/packs-rails)) or
119
+ [components](https://cbra.info/) (component-based Rails).
120
+
121
+ When packs or components are detected, `rails-stats` automatically prints a
122
+ breakdown per pack/component, a `Core Application` section for everything that
123
+ lives in the main app, and a `Total (all packs)` section that aggregates the
124
+ whole monolith:
125
+
126
+ ```bash
127
+ $ rails-stats /path/to/monolith
128
+
129
+ == Core Application ==
130
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
131
+ | Name | Files | Lines | LOC | Classes | Methods | M/C | LOC/M |
132
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
133
+ | ... |
134
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
135
+
136
+ == Pack: packs/pack1 ==
137
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
138
+ | ... |
139
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
140
+
141
+ == Total (all packs) ==
142
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
143
+ | ... |
144
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
52
145
  ```
53
146
 
54
- ### Within your Rails project
147
+ A directory is treated as a pack when it contains a `package.yml` file (the
148
+ Packwerk marker) or when it lives directly under a `packs/` or `components/`
149
+ directory and holds any of the usual code folders (`app`, `lib`, `spec`,
150
+ `test`). Nested packs (`packs/a/packs/b`) are supported.
55
151
 
56
- You can also include it within your Rails application to _replace_ the default `rake stats` implementation.
152
+ You can also scope stats to a single pack:
57
153
 
58
- Just add rails_stats to your Gemfile.
59
- Depending on your setup, you might need to `require rails_stats` in your Rakefile.
154
+ ```bash
155
+ $ rails-stats packs/pack1
156
+ ```
60
157
 
61
- Then you'll be able to just run:
158
+ The same breakdown is available in JSON under a `"packs"` key:
62
159
 
63
160
  ```bash
64
- $ bundle exec rake stats
161
+ $ rails-stats . json
65
162
  ```
66
163
 
67
164
  ### Things it knows about
@@ -80,193 +177,88 @@ RailsStats adds more coverage than the default.
80
177
  Here are some open source Rails projects and their output.
81
178
 
82
179
  ```bash
83
- $ bundle exec rake stats[/users/brian/examples/diaspora/]
84
-
85
- Directory: /users/brian/examples/diaspora
86
-
87
- +----------------------+-------+-------+---------+---------+-----+-------+
88
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
89
- +----------------------+-------+-------+---------+---------+-----+-------+
90
- | Collections | 259 | 198 | 0 | 56 | 0 | 1 |
91
- | Helpers | 1863 | 1478 | 0 | 218 | 0 | 4 |
92
- | Models | 4694 | 3517 | 55 | 580 | 10 | 4 |
93
- | Pages | 201 | 158 | 0 | 21 | 0 | 5 |
94
- | Controllers | 2797 | 2168 | 40 | 208 | 5 | 8 |
95
- | Mailers | 313 | 263 | 13 | 32 | 2 | 6 |
96
- | Presenters | 516 | 425 | 18 | 71 | 3 | 3 |
97
- | Uploaders | 84 | 63 | 2 | 9 | 4 | 5 |
98
- | Workers | 600 | 399 | 32 | 33 | 1 | 10 |
99
- | Javascripts | 7550 | 4941 | 0 | 741 | 0 | 4 |
100
- | Libraries | 7031 | 4890 | 69 | 701 | 10 | 4 |
101
- | Configuration | 2556 | 833 | 5 | 10 | 2 | 81 |
102
- | Controller Tests | 4628 | 3775 | 0 | 2 | 0 | 1885 |
103
- | Spec Support | 1141 | 900 | 6 | 56 | 9 | 14 |
104
- | Helper Tests | 771 | 615 | 0 | 6 | 0 | 100 |
105
- | Integration Tests | 891 | 647 | 0 | 14 | 0 | 44 |
106
- | Lib Tests | 4076 | 3259 | 2 | 4 | 2 | 812 |
107
- | Other Tests | 120 | 101 | 0 | 0 | 0 | 0 |
108
- | Mailer Tests | 412 | 328 | 0 | 0 | 0 | 0 |
109
- | Model Tests | 6120 | 4964 | 0 | 1 | 0 | 4962 |
110
- | Presenter Tests | 353 | 303 | 0 | 0 | 0 | 0 |
111
- | Worker Tests | 821 | 648 | 0 | 0 | 0 | 0 |
112
- | Cucumber Features | 2157 | 1863 | 47 | 155 | 3 | 10 |
113
- +----------------------+-------+-------+---------+---------+-----+-------+
114
- | Total | 49954 | 36736 | 289 | 2918 | 10 | 10 |
115
- +----------------------+-------+-------+---------+---------+-----+-------+
116
- Code LOC: 19333 Test LOC: 17403 Code to Test Ratio: 1:0.9
117
-
118
-
119
- $ bundle exec rake stats[/users/brian/examples/discourse]
120
-
121
- Directory: /users/brian/examples/discourse
122
-
123
- +----------------------+-------+-------+---------+---------+-----+-------+
124
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
125
- +----------------------+-------+-------+---------+---------+-----+-------+
126
- | Controllers | 5005 | 3812 | 56 | 416 | 7 | 7 |
127
- | Helpers | 286 | 218 | 0 | 32 | 0 | 4 |
128
- | Jobs | 1830 | 1343 | 53 | 114 | 2 | 9 |
129
- | Mailers | 438 | 340 | 7 | 24 | 3 | 12 |
130
- | Models | 12378 | 8393 | 123 | 983 | 7 | 6 |
131
- | Serializers | 2809 | 2223 | 73 | 374 | 5 | 3 |
132
- | Services | 1353 | 1060 | 20 | 106 | 5 | 8 |
133
- | Javascripts | 21722 | 13649 | 0 | 1844 | 0 | 5 |
134
- | Libraries | 35298 | 27521 | 189 | 2565 | 13 | 8 |
135
- | Configuration | 1758 | 1179 | 6 | 12 | 2 | 96 |
136
- | Other Tests | 12998 | 9830 | 20 | 41 | 2 | 237 |
137
- | Controller Tests | 7673 | 5911 | 0 | 4 | 0 | 1475 |
138
- | Spec Support | 707 | 560 | 1 | 16 | 16 | 33 |
139
- | Helper Tests | 88 | 71 | 0 | 0 | 0 | 0 |
140
- | Integration Tests | 307 | 235 | 0 | 1 | 0 | 233 |
141
- | Job Tests | 1343 | 1017 | 3 | 9 | 3 | 111 |
142
- | Mailer Tests | 421 | 302 | 0 | 1 | 0 | 300 |
143
- | Model Tests | 11236 | 8599 | 2 | 49 | 24 | 173 |
144
- | Serializer Tests | 297 | 236 | 0 | 2 | 0 | 116 |
145
- | Service Tests | 1767 | 1406 | 0 | 2 | 0 | 701 |
146
- +----------------------+-------+-------+---------+---------+-----+-------+
147
- | Total | 119714| 87905 | 553 | 6595 | 11 | 11 |
148
- +----------------------+-------+-------+---------+---------+-----+-------+
149
- Code LOC: 59738 Test LOC: 28167 Code to Test Ratio: 1:0.5
150
-
151
-
152
- $ bundle exec rake stats[/users/brian/examples/gitlabhq]
153
-
154
- Directory: /users/brian/examples/gitlabhq
155
-
156
- +----------------------+-------+-------+---------+---------+-----+-------+
157
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
158
- +----------------------+-------+-------+---------+---------+-----+-------+
159
- | Controllers | 3690 | 2890 | 66 | 384 | 5 | 5 |
160
- | Finders | 428 | 267 | 8 | 27 | 3 | 7 |
161
- | Helpers | 2280 | 1761 | 0 | 222 | 0 | 5 |
162
- | Mailers | 382 | 275 | 1 | 29 | 29 | 7 |
163
- | Models | 6922 | 4680 | 58 | 714 | 12 | 4 |
164
- | Services | 2021 | 1502 | 51 | 149 | 2 | 8 |
165
- | Uploaders | 81 | 62 | 2 | 14 | 7 | 2 |
166
- | Workers | 128 | 99 | 6 | 8 | 1 | 10 |
167
- | Javascripts | 3843 | 2936 | 1 | 534 | 534 | 3 |
168
- | Libraries | 7246 | 4785 | 120 | 438 | 3 | 8 |
169
- | Configuration | 1421 | 782 | 4 | 11 | 2 | 69 |
170
- | Controller Tests | 428 | 334 | 0 | 0 | 0 | 0 |
171
- | Spec Support | 1119 | 715 | 2 | 27 | 13 | 24 |
172
- | Other Tests | 67 | 55 | 0 | 0 | 0 | 0 |
173
- | Feature Tests | 2209 | 1765 | 0 | 8 | 0 | 218 |
174
- | Finder Tests | 281 | 230 | 0 | 0 | 0 | 0 |
175
- | Helper Tests | 1608 | 1255 | 0 | 5 | 0 | 249 |
176
- | Lib Tests | 1459 | 1180 | 1 | 11 | 11 | 105 |
177
- | Mailer Tests | 630 | 478 | 0 | 0 | 0 | 0 |
178
- | Model Tests | 3856 | 2669 | 0 | 10 | 0 | 264 |
179
- | Request Tests | 4229 | 3600 | 0 | 10 | 0 | 358 |
180
- | Routing Tests | 849 | 520 | 0 | 0 | 0 | 0 |
181
- | Service Tests | 1611 | 1307 | 0 | 34 | 0 | 36 |
182
- | Worker Tests | 45 | 35 | 0 | 2 | 0 | 15 |
183
- | Cucumber Features | 6749 | 5734 | 141 | 947 | 6 | 4 |
184
- | Cucumber Support | 6235 | 4980 | 65 | 71 | 1 | 68 |
185
- +----------------------+-------+-------+---------+---------+-----+-------+
186
- | Total | 59817 | 44896 | 526 | 3655 | 6 | 10 |
187
- +----------------------+-------+-------+---------+---------+-----+-------+
188
- Code LOC: 20039 Test LOC: 24857 Code to Test Ratio: 1:1.2
189
-
190
-
191
- $ bundle exec rake stats[/users/brian/examples/redmine/]
192
-
193
- Directory: /users/brian/examples/redmine
194
-
195
- +----------------------+-------+-------+---------+---------+-----+-------+
196
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
197
- +----------------------+-------+-------+---------+---------+-----+-------+
198
- | Controllers | 6738 | 5005 | 51 | 416 | 8 | 10 |
199
- | Helpers | 4445 | 3014 | 2 | 281 | 140 | 8 |
200
- | Models | 13221 | 9369 | 86 | 1026 | 11 | 7 |
201
- | Libraries | 19041 | 13499 | 137 | 1147 | 8 | 9 |
202
- | Configuration | 779 | 550 | 14 | 18 | 1 | 28 |
203
- | Integration Tests | 8286 | 6032 | 92 | 202 | 2 | 27 |
204
- | Other Tests | 669 | 521 | 3 | 53 | 17 | 7 |
205
- | Test Support | 1102 | 791 | 8 | 70 | 8 | 9 |
206
- | Functional Tests | 18448 | 14784 | 61 | 1372 | 22 | 8 |
207
- | Unit Tests | 23680 | 18217 | 117 | 1783 | 15 | 8 |
208
- | Helper Tests | 3321 | 2567 | 16 | 171 | 10 | 13 |
209
- +----------------------+-------+-------+---------+---------+-----+-------+
210
- | Total | 99730 | 74349 | 587 | 6539 | 11 | 9 |
211
- +----------------------+-------+-------+---------+---------+-----+-------+
212
- Code LOC: 31437 Test LOC: 42912 Code to Test Ratio: 1:1.4
213
-
214
-
215
- $ bundle exec rake stats[/users/brian/examples/refinerycms]
216
-
217
- Directory: /users/brian/examples/refinerycms
218
-
219
- +----------------------+-------+-------+---------+---------+-----+-------+
220
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
221
- +----------------------+-------+-------+---------+---------+-----+-------+
222
- | Controllers | 950 | 748 | 17 | 83 | 4 | 7 |
223
- | Helpers | 399 | 308 | 0 | 28 | 0 | 9 |
224
- | Mailers | 22 | 18 | 1 | 2 | 2 | 7 |
225
- | Models | 846 | 570 | 14 | 86 | 6 | 4 |
226
- | Presenters | 365 | 271 | 8 | 44 | 5 | 4 |
227
- | Javascripts | 717 | 531 | 0 | 52 | 0 | 8 |
228
- | Libraries | 4 | 4 | 0 | 0 | 0 | 0 |
229
- | Gems | 4166 | 2997 | 44 | 372 | 8 | 6 |
230
- | Controller Tests | 207 | 170 | 1 | 1 | 1 | 168 |
231
- | Spec Support | 309 | 243 | 2 | 6 | 3 | 38 |
232
- | Feature Tests | 1907 | 1484 | 0 | 4 | 0 | 369 |
233
- | Lib Tests | 1952 | 1687 | 6 | 4 | 0 | 419 |
234
- | Model Tests | 1323 | 1072 | 0 | 5 | 0 | 212 |
235
- | Helper Tests | 324 | 264 | 0 | 1 | 0 | 262 |
236
- | Presenter Tests | 355 | 299 | 0 | 0 | 0 | 0 |
237
- +----------------------+-------+-------+---------+---------+-----+-------+
238
- | Total | 13846 | 10666 | 93 | 688 | 7 | 13 |
239
- +----------------------+-------+-------+---------+---------+-----+-------+
240
- Code LOC: 5447 Test LOC: 5219 Code to Test Ratio: 1:1.0
241
-
242
-
243
- $ bundle exec rake stats[/users/brian/examples/spree]
244
-
245
- Directory: /users/brian/examples/spree
246
-
247
- +----------------------+-------+-------+---------+---------+-----+-------+
248
- | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
249
- +----------------------+-------+-------+---------+---------+-----+-------+
250
- | Controllers | 4653 | 3800 | 86 | 492 | 5 | 5 |
251
- | Helpers | 1142 | 949 | 0 | 90 | 0 | 8 |
252
- | Models | 9893 | 7308 | 167 | 973 | 5 | 5 |
253
- | Javascripts | 2770 | 2100 | 9 | 416 | 46 | 3 |
254
- | Mailers | 63 | 58 | 5 | 8 | 1 | 5 |
255
- | Libraries | 15 | 14 | 0 | 0 | 0 | 0 |
256
- | Gems | 4690 | 3641 | 35 | 254 | 7 | 12 |
257
- | Controller Tests | 7344 | 6000 | 6 | 19 | 3 | 313 |
258
- | Model Tests | 16747 | 13452 | 20 | 27 | 1 | 496 |
259
- | Request Tests | 32 | 24 | 0 | 0 | 0 | 0 |
260
- | Spec Support | 577 | 427 | 3 | 9 | 3 | 45 |
261
- | Feature Tests | 6079 | 4809 | 0 | 17 | 0 | 280 |
262
- | Helper Tests | 602 | 470 | 2 | 1 | 0 | 468 |
263
- | Lib Tests | 1455 | 1216 | 8 | 11 | 1 | 108 |
264
- | Mailer Tests | 252 | 208 | 0 | 0 | 0 | 0 |
265
- | Other Tests | 33 | 27 | 0 | 0 | 0 | 0 |
266
- +----------------------+-------+-------+---------+---------+-----+-------+
267
- | Total | 56347 | 44503 | 341 | 2317 | 6 | 17 |
268
- +----------------------+-------+-------+---------+---------+-----+-------+
269
- Code LOC: 17870 Test LOC: 26633 Code to Test Ratio: 1:1.5
180
+
181
+ $ rails-stats /users/brian/examples/redmine/
182
+
183
+ +-----------------------|------------|----------------+
184
+ | Name | Total Deps | 1st Level Deps |
185
+ +-----------------------|------------|----------------+
186
+ | rails | 62 | 13 |
187
+ | roadie-rails | 45 | 2 |
188
+ | actionpack-xml_parser | 41 | 2 |
189
+ | importmap-rails | 41 | 3 |
190
+ | propshaft | 41 | 4 |
191
+ | stimulus-rails | 41 | 1 |
192
+ | rubocop-rails | 28 | 5 |
193
+ | rubocop-performance | 15 | 3 |
194
+ | html-pipeline | 14 | 2 |
195
+ | rails-dom-testing | 14 | 3 |
196
+ | rubocop | 14 | 10 |
197
+ | bullet | 13 | 2 |
198
+ | capybara | 10 | 8 |
199
+ | debug | 10 | 2 |
200
+ | mail | 7 | 4 |
201
+ | selenium-webdriver | 5 | 5 |
202
+ | rails_stats | 4 | 2 |
203
+ | svg_sprite | 4 | 3 |
204
+ | bundle-audit | 3 | 1 |
205
+ | listen | 3 | 2 |
206
+ | net-imap | 3 | 2 |
207
+ | sanitize | 3 | 2 |
208
+ | simplecov | 3 | 3 |
209
+ | mini_magick | 2 | 2 |
210
+ | net-pop | 2 | 1 |
211
+ | net-smtp | 2 | 1 |
212
+ | rbpdf | 2 | 2 |
213
+ | rqrcode | 2 | 2 |
214
+ | addressable | 1 | 1 |
215
+ | i18n | 1 | 1 |
216
+ | mocha | 1 | 1 |
217
+ | nokogiri | 1 | 1 |
218
+ | puma | 1 | 1 |
219
+ | commonmarker | 0 | 0 |
220
+ | csv | 0 | 0 |
221
+ | ffi | 0 | 0 |
222
+ | marcel | 0 | 0 |
223
+ | mini_mime | 0 | 0 |
224
+ | net-ldap | 0 | 0 |
225
+ | rack | 0 | 0 |
226
+ | rotp | 0 | 0 |
227
+ | rouge | 0 | 0 |
228
+ | rubyzip | 0 | 0 |
229
+ | tzinfo-data | 0 | 0 |
230
+ | yard | 0 | 0 |
231
+ +-----------------------|------------|----------------+
232
+
233
+ Declared Gems 45
234
+ Total Gems 144
235
+ Unpinned Versions 19
236
+ Github Refs 0
237
+
238
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
239
+ | Name | Files | Lines | LOC | Classes | Methods | M/C | LOC/M |
240
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
241
+ | Configuration | 17 | 1090 | 666 | 7 | 14 | 2 | 45 |
242
+ | Controllers | 57 | 9042 | 6746 | 60 | 554 | 9 | 10 |
243
+ | Functional Tests | 65 | 35754 | 30234 | 65 | 2104 | 32 | 12 |
244
+ | Helper Tests | 27 | 5369 | 4090 | 28 | 302 | 10 | 11 |
245
+ | Helpers | 49 | 7068 | 5168 | 1 | 413 | 413 | 10 |
246
+ | Integration Tests | 98 | 10349 | 7237 | 104 | 297 | 2 | 22 |
247
+ | Javascripts | 117 | 6930 | 5362 | 0 | 446 | 0 | 10 |
248
+ | Job Tests | 2 | 142 | 94 | 2 | 2 | 1 | 45 |
249
+ | Jobs | 3 | 115 | 90 | 3 | 9 | 3 | 8 |
250
+ | Libraries | 134 | 18922 | 13178 | 128 | 1167 | 9 | 9 |
251
+ | Models | 88 | 20110 | 14528 | 110 | 1532 | 13 | 7 |
252
+ | Other Tests | 19 | 2339 | 1525 | 19 | 98 | 5 | 13 |
253
+ | Test Support | 16 | 1637 | 1229 | 20 | 142 | 7 | 6 |
254
+ | Unit Tests | 147 | 37173 | 28642 | 161 | 2778 | 17 | 8 |
255
+ | Validators | 1 | 29 | 10 | 1 | 1 | 1 | 8 |
256
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
257
+ | Code | 466 | 63306 | 45748 | 310 | 4136 | 13 | 9 |
258
+ | Tests | 374 | 92763 | 73051 | 399 | 5723 | 14 | 10 |
259
+ | Total | 840 | 156069 | 118799 | 709 | 9859 | 13 | 10 |
260
+ +----------------------+---------+---------+---------+---------+---------+-----+-------+
261
+ Code LOC: 45748 Test LOC: 73051 Code to Test Ratio: 1:1.6 Files: 840
270
262
 
271
263
  ```
272
264
 
@@ -275,11 +267,11 @@ Directory: /users/brian/examples/spree
275
267
  If you want to export the details using JSON, you can use this command:
276
268
 
277
269
  ```
278
- $ rake stats\[test/dummy,json\]
270
+ $ rails-stats test/dummy json
279
271
 
280
- Directory: /Users/etagwerker/Projects/fastruby/rails_stats/test/dummy
272
+ Directory: /Users/etagwerker/Projects/redmine
281
273
 
282
- [{"name":"Mailers","lines":"4","loc":"4","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Models","lines":"3","loc":"3","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Javascripts","lines":"27","loc":"7","classes":"0","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Jobs","lines":"7","loc":"2","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Controllers","lines":"7","loc":"6","classes":"1","methods":"1","m_over_c":"1","loc_over_m":"4"},{"name":"Helpers","lines":"3","loc":"3","classes":"0","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Channels","lines":"8","loc":"8","classes":"2","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Configuration","lines":"417","loc":"111","classes":"1","methods":"0","m_over_c":"0","loc_over_m":"0"},{"name":"Total","lines":"476","loc":"144","classes":"7","methods":"1","m_over_c":"0","loc_over_m":"142","code_to_test_ratio":"0.0","total":true}]
274
+ [{"summary":{"declared":45,"unpinned":19,"total":144,"github":0},"gems":[{"name":"rails","total_dependencies":62,"first_level_dependencies":13,"top_level_dependencies":{},"transitive_dependencies":["actioncable (= 7.2.2.1)","actionmailbox (= 7.2.2.1)","actionmailer (= 7.2.2.1)","actionpack (= 7.2.2.1)","actiontext (= 7.2.2.1)","actionview (= 7.2.2.1)","activejob (= 7.2.2.1)","activemodel (= 7.2.2.1)","activerecord (= 7.2.2.1)","activestorage (= 7.2.2.1)","activesupport (= 7.2.2.1)","bundler (>= 1.15.0)","railties (= 7.2.2.1)","nio4r (~> 2.0)","websocket-driver (>= 0.6.1)","zeitwerk (~> 2.6)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","websocket-extensions (>= 0.1.0)","mail (>= 2.8.0)","globalid (>= 0.3.6)","timeout (>= 0.4.0)","marcel (~> 1.0)","mini_mime (>= 0.1.1)","net-imap (>= 0)","net-pop (>= 0)","net-smtp (>= 0)","date (>= 0)","net-protocol (>= 0)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"roadie-rails","total_dependencies":45,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["railties (>= 5.1, < 8.1)","roadie (~> 5.0)","actionpack (= 7.2.2.1)","activesupport (= 7.2.2.1)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)","css_parser (~> 1.4)","addressable (>= 0)","public_suffix (>= 2.0.2, < 7.0)"]},{"name":"actionpack-xml_parser","total_dependencies":41,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["actionpack (>= 5.0)","railties (>= 5.0)","actionview (= 7.2.2.1)","activesupport (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"importmap-rails","total_dependencies":41,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["actionpack (>= 6.0.0)","activesupport (>= 6.0.0)","railties (>= 6.0.0)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"propshaft","total_dependencies":41,"first_level_dependencies":4,"top_level_dependencies":{},"transitive_dependencies":["actionpack (>= 7.0.0)","activesupport (>= 7.0.0)","rack (>= 0)","railties (>= 7.0.0)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"stimulus-rails","total_dependencies":41,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["railties (>= 6.0.0)","actionpack (= 7.2.2.1)","activesupport (= 7.2.2.1)","irb (~> 1.13)","rackup (>= 1.0.0)","rake (>= 12.2)","thor (~> 1.0, >= 1.2.2)","zeitwerk (~> 2.6)","actionview (= 7.2.2.1)","nokogiri (>= 1.8.5)","racc (>= 0)","rack (>= 2.2.4, < 3.2)","rack-session (>= 1.0.1)","rack-test (>= 0.6.3)","rails-dom-testing (~> 2.2)","rails-html-sanitizer (~> 1.6)","useragent (~> 0.16)","builder (~> 3.1)","erubi (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","loofah (~> 2.21)","crass (~> 1.0.2)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","reline (>= 0.4.2)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"rubocop-rails","total_dependencies":28,"first_level_dependencies":5,"top_level_dependencies":{},"transitive_dependencies":["activesupport (>= 4.2.0)","lint_roller (~> 1.1)","rack (>= 1.1)","rubocop (>= 1.75.0, < 2.0)","rubocop-ast (>= 1.38.0, < 2.0)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","json (~> 2.3)","language_server-protocol (~> 3.17.0.2)","parallel (~> 1.10)","parser (>= 3.3.0.2)","rainbow (>= 2.2.2, < 4.0)","regexp_parser (>= 2.9.3, < 3.0)","ruby-progressbar (~> 1.7)","unicode-display_width (>= 2.4.0, < 4.0)","ast (~> 2.4.1)","racc (>= 0)","prism (~> 1.4)","unicode-emoji (~> 4.0, >= 4.0.4)"]},{"name":"rubocop-performance","total_dependencies":15,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["lint_roller (~> 1.1)","rubocop (>= 1.75.0, < 2.0)","rubocop-ast (>= 1.38.0, < 2.0)","json (~> 2.3)","language_server-protocol (~> 3.17.0.2)","parallel (~> 1.10)","parser (>= 3.3.0.2)","rainbow (>= 2.2.2, < 4.0)","regexp_parser (>= 2.9.3, < 3.0)","ruby-progressbar (~> 1.7)","unicode-display_width (>= 2.4.0, < 4.0)","ast (~> 2.4.1)","racc (>= 0)","prism (~> 1.4)","unicode-emoji (~> 4.0, >= 4.0.4)"]},{"name":"html-pipeline","total_dependencies":14,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["activesupport (>= 2)","nokogiri (>= 1.4)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","racc (~> 1.4)"]},{"name":"rails-dom-testing","total_dependencies":14,"first_level_dependencies":3,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","actionview":"actionview (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","importmap-rails":"importmap-rails (2.1.0)","propshaft":"propshaft (1.1.0)","rails":"rails (7.2.2.1)","railties":"railties (7.2.2.1)","roadie-rails":"roadie-rails (3.3.0)","stimulus-rails":"stimulus-rails (1.3.4)"},"transitive_dependencies":["activesupport (>= 5.0.0)","minitest (>= 0)","nokogiri (>= 1.6)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)","racc (~> 1.4)"]},{"name":"rubocop","total_dependencies":14,"first_level_dependencies":10,"top_level_dependencies":{"rubocop-performance":"rubocop-performance (1.25.0)","rubocop-rails":"rubocop-rails (2.31.0)"},"transitive_dependencies":["json (~> 2.3)","language_server-protocol (~> 3.17.0.2)","lint_roller (~> 1.1.0)","parallel (~> 1.10)","parser (>= 3.3.0.2)","rainbow (>= 2.2.2, < 4.0)","regexp_parser (>= 2.9.3, < 3.0)","rubocop-ast (>= 1.44.0, < 2.0)","ruby-progressbar (~> 1.7)","unicode-display_width (>= 2.4.0, < 4.0)","ast (~> 2.4.1)","racc (>= 0)","prism (~> 1.4)","unicode-emoji (~> 4.0, >= 4.0.4)"]},{"name":"bullet","total_dependencies":13,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["activesupport (>= 3.0.0)","uniform_notifier (~> 1.11)","base64 (>= 0)","benchmark (>= 0.3)","bigdecimal (>= 0)","concurrent-ruby (~> 1.0, >= 1.3.1)","connection_pool (>= 2.2.5)","drb (>= 0)","i18n (>= 1.6, < 2)","logger (>= 1.4.2)","minitest (>= 5.1)","securerandom (>= 0.3)","tzinfo (~> 2.0, >= 2.0.5)"]},{"name":"capybara","total_dependencies":10,"first_level_dependencies":8,"top_level_dependencies":{},"transitive_dependencies":["addressable (>= 0)","matrix (>= 0)","mini_mime (>= 0.1.3)","nokogiri (~> 1.11)","rack (>= 1.6.0)","rack-test (>= 0.6.3)","regexp_parser (>= 1.5, < 3.0)","xpath (~> 3.2)","public_suffix (>= 2.0.2, < 7.0)","racc (~> 1.4)"]},{"name":"debug","total_dependencies":10,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["irb (~> 1.10)","reline (>= 0.3.8)","pp (>= 0.6.0)","rdoc (>= 4.0.0)","prettyprint (>= 0)","erb (>= 0)","psych (>= 4.0.0)","date (>= 0)","stringio (>= 0)","io-console (~> 0.5)"]},{"name":"mail","total_dependencies":7,"first_level_dependencies":4,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["mini_mime (>= 0.1.1)","net-imap (>= 0)","net-pop (>= 0)","net-smtp (>= 0)","date (>= 0)","net-protocol (>= 0)","timeout (>= 0)"]},{"name":"selenium-webdriver","total_dependencies":5,"first_level_dependencies":5,"top_level_dependencies":{},"transitive_dependencies":["base64 (~> 0.2)","logger (~> 1.4)","rexml (~> 3.2, >= 3.2.5)","rubyzip (>= 1.2.2, < 3.0)","websocket (~> 1.0)"]},{"name":"rails_stats","total_dependencies":4,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["bundler-stats (>= 2.1)","rake (>= 0)","bundler (>= 1.9, < 3)","thor (>= 0.19.0, < 2.0)"]},{"name":"svg_sprite","total_dependencies":4,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["nokogiri (>= 0)","svg_optimizer (>= 0)","thor (>= 0)","racc (~> 1.4)"]},{"name":"bundle-audit","total_dependencies":3,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["bundler-audit (>= 0)","bundler (>= 1.2.0, < 3)","thor (~> 1.0)"]},{"name":"listen","total_dependencies":3,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["rb-fsevent (~> 0.10, >= 0.10.3)","rb-inotify (~> 0.9, >= 0.9.10)","ffi (~> 1.0)"]},{"name":"net-imap","total_dependencies":3,"first_level_dependencies":2,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["date (>= 0)","net-protocol (>= 0)","timeout (>= 0)"]},{"name":"sanitize","total_dependencies":3,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["crass (~> 1.0.2)","nokogiri (>= 1.12.0)","racc (~> 1.4)"]},{"name":"simplecov","total_dependencies":3,"first_level_dependencies":3,"top_level_dependencies":{},"transitive_dependencies":["docile (~> 1.1)","simplecov-html (~> 0.11)","simplecov_json_formatter (~> 0.1)"]},{"name":"mini_magick","total_dependencies":2,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["benchmark (>= 0)","logger (>= 0)"]},{"name":"net-pop","total_dependencies":2,"first_level_dependencies":1,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["net-protocol (>= 0)","timeout (>= 0)"]},{"name":"net-smtp","total_dependencies":2,"first_level_dependencies":1,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":["net-protocol (>= 0)","timeout (>= 0)"]},{"name":"rbpdf","total_dependencies":2,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["htmlentities (>= 0)","rbpdf-font (~> 1.19.0)"]},{"name":"rqrcode","total_dependencies":2,"first_level_dependencies":2,"top_level_dependencies":{},"transitive_dependencies":["chunky_png (~> 1.0)","rqrcode_core (~> 2.0)"]},{"name":"addressable","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{"capybara":"capybara (3.40.0)","css_parser":"css_parser (1.21.1)","roadie":"roadie (5.2.1)","roadie-rails":"roadie-rails (3.3.0)"},"transitive_dependencies":["public_suffix (>= 2.0.2, < 7.0)"]},{"name":"i18n","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","actionview":"actionview (7.2.2.1)","activejob":"activejob (7.2.2.1)","activemodel":"activemodel (7.2.2.1)","activerecord":"activerecord (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","activesupport":"activesupport (7.2.2.1)","bullet":"bullet (8.0.7)","globalid":"globalid (1.2.1)","html-pipeline":"html-pipeline (2.13.2)","importmap-rails":"importmap-rails (2.1.0)","propshaft":"propshaft (1.1.0)","rails":"rails (7.2.2.1)","rails-dom-testing":"rails-dom-testing (2.2.0)","railties":"railties (7.2.2.1)","roadie-rails":"roadie-rails (3.3.0)","rubocop-rails":"rubocop-rails (2.31.0)","stimulus-rails":"stimulus-rails (1.3.4)"},"transitive_dependencies":["concurrent-ruby (~> 1.0)"]},{"name":"mocha","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["ruby2_keywords (>= 0.0.5)"]},{"name":"nokogiri","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","actionview":"actionview (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","capybara":"capybara (3.40.0)","html-pipeline":"html-pipeline (2.13.2)","importmap-rails":"importmap-rails (2.1.0)","loofah":"loofah (2.24.1)","propshaft":"propshaft (1.1.0)","rails":"rails (7.2.2.1)","rails-dom-testing":"rails-dom-testing (2.2.0)","rails-html-sanitizer":"rails-html-sanitizer (1.6.2)","railties":"railties (7.2.2.1)","roadie":"roadie (5.2.1)","roadie-rails":"roadie-rails (3.3.0)","sanitize":"sanitize (6.1.3)","stimulus-rails":"stimulus-rails (1.3.4)","svg_optimizer":"svg_optimizer (0.3.0)","svg_sprite":"svg_sprite (1.0.3)","xpath":"xpath (3.2.0)"},"transitive_dependencies":["racc (~> 1.4)"]},{"name":"puma","total_dependencies":1,"first_level_dependencies":1,"top_level_dependencies":{},"transitive_dependencies":["nio4r (~> 2.0)"]},{"name":"commonmarker","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"csv","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"ffi","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"listen":"listen (3.9.0)","rb-inotify":"rb-inotify (0.11.1)"},"transitive_dependencies":[]},{"name":"marcel","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actiontext":"actiontext (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":[]},{"name":"mini_mime","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","capybara":"capybara (3.40.0)","mail":"mail (2.8.1)","rails":"rails (7.2.2.1)"},"transitive_dependencies":[]},{"name":"net-ldap","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"rack","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"actioncable":"actioncable (7.2.2.1)","actionmailbox":"actionmailbox (7.2.2.1)","actionmailer":"actionmailer (7.2.2.1)","actionpack":"actionpack (7.2.2.1)","actionpack-xml_parser":"actionpack-xml_parser (2.0.1)","actiontext":"actiontext (7.2.2.1)","activestorage":"activestorage (7.2.2.1)","capybara":"capybara (3.40.0)","importmap-rails":"importmap-rails (2.1.0)","propshaft":"propshaft (1.1.0)","rack-session":"rack-session (2.1.1)","rack-test":"rack-test (2.2.0)","rackup":"rackup (2.2.1)","rails":"rails (7.2.2.1)","railties":"railties (7.2.2.1)","roadie-rails":"roadie-rails (3.3.0)","rubocop-rails":"rubocop-rails (2.31.0)","stimulus-rails":"stimulus-rails (1.3.4)"},"transitive_dependencies":[]},{"name":"rotp","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"rouge","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"rubyzip","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{"selenium-webdriver":"selenium-webdriver (4.32.0)"},"transitive_dependencies":[]},{"name":"tzinfo-data","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]},{"name":"yard","total_dependencies":0,"first_level_dependencies":0,"top_level_dependencies":{},"transitive_dependencies":[]}]},{"name":"Models","files":"88","lines":"20110","loc":"14528","classes":"110","methods":"1532","m_over_c":"13","loc_over_m":"7"},{"name":"Validators","files":"1","lines":"29","loc":"10","classes":"1","methods":"1","m_over_c":"1","loc_over_m":"8"},{"name":"Javascripts","files":"117","lines":"6930","loc":"5362","classes":"0","methods":"446","m_over_c":"0","loc_over_m":"10"},{"name":"Jobs","files":"3","lines":"115","loc":"90","classes":"3","methods":"9","m_over_c":"3","loc_over_m":"8"},{"name":"Controllers","files":"57","lines":"9042","loc":"6746","classes":"60","methods":"554","m_over_c":"9","loc_over_m":"10"},{"name":"Helpers","files":"49","lines":"7068","loc":"5168","classes":"1","methods":"413","m_over_c":"413","loc_over_m":"10"},{"name":"Libraries","files":"134","lines":"18922","loc":"13178","classes":"128","methods":"1167","m_over_c":"9","loc_over_m":"9"},{"name":"Configuration","files":"17","lines":"1090","loc":"666","classes":"7","methods":"14","m_over_c":"2","loc_over_m":"45"},{"name":"Integration Tests","files":"98","lines":"10349","loc":"7237","classes":"104","methods":"297","m_over_c":"2","loc_over_m":"22"},{"name":"Test Support","files":"16","lines":"1637","loc":"1229","classes":"20","methods":"142","m_over_c":"7","loc_over_m":"6"},{"name":"Other Tests","files":"19","lines":"2339","loc":"1525","classes":"19","methods":"98","m_over_c":"5","loc_over_m":"13"},{"name":"Functional Tests","files":"65","lines":"35754","loc":"30234","classes":"65","methods":"2104","m_over_c":"32","loc_over_m":"12"},{"name":"Helper Tests","files":"27","lines":"5369","loc":"4090","classes":"28","methods":"302","m_over_c":"10","loc_over_m":"11"},{"name":"Unit Tests","files":"147","lines":"37173","loc":"28642","classes":"161","methods":"2778","m_over_c":"17","loc_over_m":"8"},{"name":"Job Tests","files":"2","lines":"142","loc":"94","classes":"2","methods":"2","m_over_c":"1","loc_over_m":"45"},{"name":"Code","files":"466","lines":"63306","loc":"45748","classes":"310","methods":"4136","m_over_c":"13","loc_over_m":"9","code_to_test_ratio":"1.6","total":true},{"name":"Tests","files":"374","lines":"92763","loc":"73051","classes":"399","methods":"5723","m_over_c":"14","loc_over_m":"10","code_to_test_ratio":"1.6","total":true},{"name":"Total","files":"840","lines":"156069","loc":"118799","classes":"709","methods":"9859","m_over_c":"13","loc_over_m":"10","code_to_test_ratio":"1.6","total":true}]
283
275
  ```
284
276
 
285
277
  ### Testing
@@ -287,15 +279,15 @@ Directory: /Users/etagwerker/Projects/fastruby/rails_stats/test/dummy
287
279
  In order to run the tests for this gem:
288
280
 
289
281
  ```bash
290
- bundle exec rake
282
+ bundle exec rake test
291
283
 
292
284
  # Running:
293
285
 
294
- .
286
+ ..
295
287
 
296
- Fabulous run in 0.013349s, 74.9120 runs/s, 74.9120 assertions/s.
288
+ Fabulous run in 0.097903s, 20.4284 runs/s, 142.9987 assertions/s.
297
289
 
298
- 1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
290
+ 2 runs, 14 assertions, 0 failures, 0 errors, 0 skips
299
291
  ```
300
292
 
301
293
  ### TODO
data/bin/rails-stats ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Standalone CLI for running rails_stats against a directory without having to
5
+ # set up a Rakefile. Accepts both absolute and relative paths:
6
+ #
7
+ # rails-stats /path/to/app
8
+ # rails-stats path/to/app
9
+ # rails-stats # defaults to the current directory
10
+ # rails-stats path/to/app json
11
+ #
12
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
13
+
14
+ require "rails_stats/all"
15
+
16
+ path = ARGV[0] || "."
17
+ format = ARGV[1] || ""
18
+
19
+ root_directory = File.absolute_path(path)
20
+
21
+ unless File.directory?(root_directory)
22
+ warn "rails-stats: no such directory - #{path}"
23
+ exit 1
24
+ end
25
+
26
+ puts "\nDirectory: #{root_directory}\n\n"
27
+ RailsStats::CodeStatistics.new(root_directory, format: format).to_s