rails_stats 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49a95d6e3cccd65728bc591f5beacb216608d9a6
4
- data.tar.gz: 14506184a365bc2af465fa3e927cf3cbdb8f8e75
3
+ metadata.gz: 9af14747fe8ba3a62bfd8f9a6429b8ee15575dde
4
+ data.tar.gz: 7332aa9e39e69ddec3247ceac542f13560fa7ccb
5
5
  SHA512:
6
- metadata.gz: c579583a0acdefaa7388cc5c60df668c39d586575396d89d2a97abe24e594533c06a196b62a8369c92e46bb5d3f86facd3fd56d7b141fa54e441dbbcc025d981
7
- data.tar.gz: 8dca4a07de86d2be8e26ae13767a611fb1d348c1bfc744648af333fa931680e9d438f4dd5dc8ff206c445a8b7bd4871919379effeff7283279fb190103361c24
6
+ metadata.gz: 4a64731b6ae1560acf963a4f30d9c14f80e10cd050c5fa841f354f186002a219be0939d3fb2f45cf14dfb99a9381ff4a318c3bfdd2da0e93f496878981e8ac42
7
+ data.tar.gz: b7580dcd7f47e03728156d5ce0c0e5bc61904ddaf366010ba9f7414d27dff70d196413683f6be3beef09bae5181d8e4136000caf53e77dbc8c193130bc694570
data/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  See stuff about a Rails app.
4
4
 
5
+ There were a few things missing to the included `rake stats`
6
+ 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.
7
+
8
+ ### Run it
9
+
5
10
  ```bash
6
11
  $ bundle exec rake:stats[/path/to/app/]
7
12
 
@@ -32,6 +37,8 @@ Directory: /path/to/app/
32
37
 
33
38
  ### Things it knows about
34
39
 
40
+ RailsStats also adds more coverage than the default.
41
+
35
42
  * Any concepts you've added within an `app` directory
36
43
  * Configuration files
37
44
  * Library files
@@ -39,6 +46,201 @@ Directory: /path/to/app/
39
46
  * Engines and their code
40
47
  * RSpec/Unit/Cucumber Tests
41
48
 
49
+ ### Example output
50
+
51
+ Here are some open source Rails projects an their output.
52
+
53
+ ```bash
54
+ $ bundle exec rake stats[/users/brian/examples/diaspora/]
55
+
56
+ Directory: /users/brian/examples/diaspora
57
+
58
+ +----------------------+-------+-------+---------+---------+-----+-------+
59
+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
60
+ +----------------------+-------+-------+---------+---------+-----+-------+
61
+ | Collections | 259 | 198 | 0 | 56 | 0 | 1 |
62
+ | Helpers | 1863 | 1478 | 0 | 218 | 0 | 4 |
63
+ | Models | 4694 | 3517 | 55 | 580 | 10 | 4 |
64
+ | Pages | 201 | 158 | 0 | 21 | 0 | 5 |
65
+ | Controllers | 2797 | 2168 | 40 | 208 | 5 | 8 |
66
+ | Mailers | 313 | 263 | 13 | 32 | 2 | 6 |
67
+ | Presenters | 516 | 425 | 18 | 71 | 3 | 3 |
68
+ | Uploaders | 84 | 63 | 2 | 9 | 4 | 5 |
69
+ | Workers | 600 | 399 | 32 | 33 | 1 | 10 |
70
+ | Javascripts | 7550 | 4941 | 0 | 741 | 0 | 4 |
71
+ | Libraries | 7031 | 4890 | 69 | 701 | 10 | 4 |
72
+ | Configuration | 2556 | 833 | 5 | 10 | 2 | 81 |
73
+ | Controller Tests | 4628 | 3775 | 0 | 2 | 0 | 1885 |
74
+ | Spec Support | 1141 | 900 | 6 | 56 | 9 | 14 |
75
+ | Helper Tests | 771 | 615 | 0 | 6 | 0 | 100 |
76
+ | Integration Tests | 891 | 647 | 0 | 14 | 0 | 44 |
77
+ | Lib Tests | 4076 | 3259 | 2 | 4 | 2 | 812 |
78
+ | Other Tests | 120 | 101 | 0 | 0 | 0 | 0 |
79
+ | Mailer Tests | 412 | 328 | 0 | 0 | 0 | 0 |
80
+ | Model Tests | 6120 | 4964 | 0 | 1 | 0 | 4962 |
81
+ | Presenter Tests | 353 | 303 | 0 | 0 | 0 | 0 |
82
+ | Worker Tests | 821 | 648 | 0 | 0 | 0 | 0 |
83
+ | Cucumber Features | 2157 | 1863 | 47 | 155 | 3 | 10 |
84
+ +----------------------+-------+-------+---------+---------+-----+-------+
85
+ | Total | 49954 | 36736 | 289 | 2918 | 10 | 10 |
86
+ +----------------------+-------+-------+---------+---------+-----+-------+
87
+ Code LOC: 19333 Test LOC: 17403 Code to Test Ratio: 1:0.9
88
+
89
+
90
+ $ bundle exec rake stats[/users/brian/examples/discourse]
91
+
92
+ Directory: /users/brian/examples/discourse
93
+
94
+ +----------------------+-------+-------+---------+---------+-----+-------+
95
+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
96
+ +----------------------+-------+-------+---------+---------+-----+-------+
97
+ | Controllers | 5005 | 3812 | 56 | 416 | 7 | 7 |
98
+ | Helpers | 286 | 218 | 0 | 32 | 0 | 4 |
99
+ | Jobs | 1830 | 1343 | 53 | 114 | 2 | 9 |
100
+ | Mailers | 438 | 340 | 7 | 24 | 3 | 12 |
101
+ | Models | 12378 | 8393 | 123 | 983 | 7 | 6 |
102
+ | Serializers | 2809 | 2223 | 73 | 374 | 5 | 3 |
103
+ | Services | 1353 | 1060 | 20 | 106 | 5 | 8 |
104
+ | Javascripts | 21722 | 13649 | 0 | 1844 | 0 | 5 |
105
+ | Libraries | 35298 | 27521 | 189 | 2565 | 13 | 8 |
106
+ | Configuration | 1758 | 1179 | 6 | 12 | 2 | 96 |
107
+ | Other Tests | 12998 | 9830 | 20 | 41 | 2 | 237 |
108
+ | Controller Tests | 7673 | 5911 | 0 | 4 | 0 | 1475 |
109
+ | Spec Support | 707 | 560 | 1 | 16 | 16 | 33 |
110
+ | Helper Tests | 88 | 71 | 0 | 0 | 0 | 0 |
111
+ | Integration Tests | 307 | 235 | 0 | 1 | 0 | 233 |
112
+ | Job Tests | 1343 | 1017 | 3 | 9 | 3 | 111 |
113
+ | Mailer Tests | 421 | 302 | 0 | 1 | 0 | 300 |
114
+ | Model Tests | 11236 | 8599 | 2 | 49 | 24 | 173 |
115
+ | Serializer Tests | 297 | 236 | 0 | 2 | 0 | 116 |
116
+ | Service Tests | 1767 | 1406 | 0 | 2 | 0 | 701 |
117
+ +----------------------+-------+-------+---------+---------+-----+-------+
118
+ | Total | 119714| 87905 | 553 | 6595 | 11 | 11 |
119
+ +----------------------+-------+-------+---------+---------+-----+-------+
120
+ Code LOC: 59738 Test LOC: 28167 Code to Test Ratio: 1:0.5
121
+
122
+
123
+ $ bundle exec rake stats[/users/brian/examples/gitlabhq]
124
+
125
+ Directory: /users/brian/examples/gitlabhq
126
+
127
+ +----------------------+-------+-------+---------+---------+-----+-------+
128
+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
129
+ +----------------------+-------+-------+---------+---------+-----+-------+
130
+ | Controllers | 3690 | 2890 | 66 | 384 | 5 | 5 |
131
+ | Finders | 428 | 267 | 8 | 27 | 3 | 7 |
132
+ | Helpers | 2280 | 1761 | 0 | 222 | 0 | 5 |
133
+ | Mailers | 382 | 275 | 1 | 29 | 29 | 7 |
134
+ | Models | 6922 | 4680 | 58 | 714 | 12 | 4 |
135
+ | Services | 2021 | 1502 | 51 | 149 | 2 | 8 |
136
+ | Uploaders | 81 | 62 | 2 | 14 | 7 | 2 |
137
+ | Workers | 128 | 99 | 6 | 8 | 1 | 10 |
138
+ | Javascripts | 3843 | 2936 | 1 | 534 | 534 | 3 |
139
+ | Libraries | 7246 | 4785 | 120 | 438 | 3 | 8 |
140
+ | Configuration | 1421 | 782 | 4 | 11 | 2 | 69 |
141
+ | Controller Tests | 428 | 334 | 0 | 0 | 0 | 0 |
142
+ | Spec Support | 1119 | 715 | 2 | 27 | 13 | 24 |
143
+ | Other Tests | 67 | 55 | 0 | 0 | 0 | 0 |
144
+ | Feature Tests | 2209 | 1765 | 0 | 8 | 0 | 218 |
145
+ | Finder Tests | 281 | 230 | 0 | 0 | 0 | 0 |
146
+ | Helper Tests | 1608 | 1255 | 0 | 5 | 0 | 249 |
147
+ | Lib Tests | 1459 | 1180 | 1 | 11 | 11 | 105 |
148
+ | Mailer Tests | 630 | 478 | 0 | 0 | 0 | 0 |
149
+ | Model Tests | 3856 | 2669 | 0 | 10 | 0 | 264 |
150
+ | Request Tests | 4229 | 3600 | 0 | 10 | 0 | 358 |
151
+ | Routing Tests | 849 | 520 | 0 | 0 | 0 | 0 |
152
+ | Service Tests | 1611 | 1307 | 0 | 34 | 0 | 36 |
153
+ | Worker Tests | 45 | 35 | 0 | 2 | 0 | 15 |
154
+ | Cucumber Features | 6749 | 5734 | 141 | 947 | 6 | 4 |
155
+ | Cucumber Support | 6235 | 4980 | 65 | 71 | 1 | 68 |
156
+ +----------------------+-------+-------+---------+---------+-----+-------+
157
+ | Total | 59817 | 44896 | 526 | 3655 | 6 | 10 |
158
+ +----------------------+-------+-------+---------+---------+-----+-------+
159
+ Code LOC: 20039 Test LOC: 24857 Code to Test Ratio: 1:1.2
160
+
161
+
162
+ $ bundle exec rake stats[/users/brian/examples/redmine/]
163
+
164
+ Directory: /users/brian/examples/redmine
165
+
166
+ +----------------------+-------+-------+---------+---------+-----+-------+
167
+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
168
+ +----------------------+-------+-------+---------+---------+-----+-------+
169
+ | Controllers | 6738 | 5005 | 51 | 416 | 8 | 10 |
170
+ | Helpers | 4445 | 3014 | 2 | 281 | 140 | 8 |
171
+ | Models | 13221 | 9369 | 86 | 1026 | 11 | 7 |
172
+ | Libraries | 19041 | 13499 | 137 | 1147 | 8 | 9 |
173
+ | Configuration | 779 | 550 | 14 | 18 | 1 | 28 |
174
+ | Integration Tests | 8286 | 6032 | 92 | 202 | 2 | 27 |
175
+ | Other Tests | 669 | 521 | 3 | 53 | 17 | 7 |
176
+ | Test Support | 1102 | 791 | 8 | 70 | 8 | 9 |
177
+ | Functional Tests | 18448 | 14784 | 61 | 1372 | 22 | 8 |
178
+ | Unit Tests | 23680 | 18217 | 117 | 1783 | 15 | 8 |
179
+ | Helper Tests | 3321 | 2567 | 16 | 171 | 10 | 13 |
180
+ +----------------------+-------+-------+---------+---------+-----+-------+
181
+ | Total | 99730 | 74349 | 587 | 6539 | 11 | 9 |
182
+ +----------------------+-------+-------+---------+---------+-----+-------+
183
+ Code LOC: 31437 Test LOC: 42912 Code to Test Ratio: 1:1.4
184
+
185
+
186
+ $ bundle exec rake stats[/users/brian/examples/refinerycms]
187
+
188
+ Directory: /users/brian/examples/refinerycms
189
+
190
+ +----------------------+-------+-------+---------+---------+-----+-------+
191
+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
192
+ +----------------------+-------+-------+---------+---------+-----+-------+
193
+ | Controllers | 950 | 748 | 17 | 83 | 4 | 7 |
194
+ | Helpers | 399 | 308 | 0 | 28 | 0 | 9 |
195
+ | Mailers | 22 | 18 | 1 | 2 | 2 | 7 |
196
+ | Models | 846 | 570 | 14 | 86 | 6 | 4 |
197
+ | Presenters | 365 | 271 | 8 | 44 | 5 | 4 |
198
+ | Javascripts | 717 | 531 | 0 | 52 | 0 | 8 |
199
+ | Libraries | 4 | 4 | 0 | 0 | 0 | 0 |
200
+ | Gems | 4166 | 2997 | 44 | 372 | 8 | 6 |
201
+ | Controller Tests | 207 | 170 | 1 | 1 | 1 | 168 |
202
+ | Spec Support | 309 | 243 | 2 | 6 | 3 | 38 |
203
+ | Feature Tests | 1907 | 1484 | 0 | 4 | 0 | 369 |
204
+ | Lib Tests | 1952 | 1687 | 6 | 4 | 0 | 419 |
205
+ | Model Tests | 1323 | 1072 | 0 | 5 | 0 | 212 |
206
+ | Helper Tests | 324 | 264 | 0 | 1 | 0 | 262 |
207
+ | Presenter Tests | 355 | 299 | 0 | 0 | 0 | 0 |
208
+ +----------------------+-------+-------+---------+---------+-----+-------+
209
+ | Total | 13846 | 10666 | 93 | 688 | 7 | 13 |
210
+ +----------------------+-------+-------+---------+---------+-----+-------+
211
+ Code LOC: 5447 Test LOC: 5219 Code to Test Ratio: 1:1.0
212
+
213
+
214
+ $ bundle exec rake stats[/users/brian/examples/spree]
215
+
216
+ Directory: /users/brian/examples/spree
217
+
218
+ +----------------------+-------+-------+---------+---------+-----+-------+
219
+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
220
+ +----------------------+-------+-------+---------+---------+-----+-------+
221
+ | Controllers | 4653 | 3800 | 86 | 492 | 5 | 5 |
222
+ | Helpers | 1142 | 949 | 0 | 90 | 0 | 8 |
223
+ | Models | 9893 | 7308 | 167 | 973 | 5 | 5 |
224
+ | Javascripts | 2770 | 2100 | 9 | 416 | 46 | 3 |
225
+ | Mailers | 63 | 58 | 5 | 8 | 1 | 5 |
226
+ | Libraries | 15 | 14 | 0 | 0 | 0 | 0 |
227
+ | Gems | 4690 | 3641 | 35 | 254 | 7 | 12 |
228
+ | Controller Tests | 7344 | 6000 | 6 | 19 | 3 | 313 |
229
+ | Model Tests | 16747 | 13452 | 20 | 27 | 1 | 496 |
230
+ | Request Tests | 32 | 24 | 0 | 0 | 0 | 0 |
231
+ | Spec Support | 577 | 427 | 3 | 9 | 3 | 45 |
232
+ | Feature Tests | 6079 | 4809 | 0 | 17 | 0 | 280 |
233
+ | Helper Tests | 602 | 470 | 2 | 1 | 0 | 468 |
234
+ | Lib Tests | 1455 | 1216 | 8 | 11 | 1 | 108 |
235
+ | Mailer Tests | 252 | 208 | 0 | 0 | 0 | 0 |
236
+ | Other Tests | 33 | 27 | 0 | 0 | 0 | 0 |
237
+ +----------------------+-------+-------+---------+---------+-----+-------+
238
+ | Total | 56347 | 44503 | 341 | 2317 | 6 | 17 |
239
+ +----------------------+-------+-------+---------+---------+-----+-------+
240
+ Code LOC: 17870 Test LOC: 26633 Code to Test Ratio: 1:1.5
241
+
242
+ ```
243
+
42
244
  ### TODO
43
245
 
44
246
  * Option to print out by app directory (stats per engine)
@@ -76,15 +76,15 @@ module RailsStats
76
76
  end
77
77
 
78
78
  def calculate_spec_projects
79
- specs = Util.calculate_projects(@root_directory, "**", "spec", "spec_helper.rb")
79
+ specs = Util.calculate_shared_projects("spec", @root_directory, "**", "spec", "**", "*_spec.rb")
80
80
  specs.collect do |root_path|
81
81
  SpecStatistics.new(root_path, @key_concepts)
82
82
  end
83
83
  end
84
84
 
85
85
  def calculate_test_projects
86
- specs = Util.calculate_projects(@root_directory, "**", "test", "test_helper.rb")
87
- specs.collect do |root_path|
86
+ tests = Util.calculate_shared_projects("test", @root_directory, "**", "test", "**", "*_test.rb")
87
+ tests.collect do |root_path|
88
88
  TestStatistics.new(root_path, @key_concepts)
89
89
  end
90
90
  end
@@ -11,7 +11,9 @@ module RailsStats
11
11
  'integrations',
12
12
  'integration',
13
13
  'mailers',
14
- 'lib']
14
+ 'lib',
15
+ 'acceptance',
16
+ 'factories']
15
17
 
16
18
  def initialize(directory, key_concepts)
17
19
  @test = true
@@ -22,6 +22,20 @@ module RailsStats
22
22
  out
23
23
  end
24
24
 
25
+ def calculate_shared_projects(shared, *args)
26
+ projects = {}
27
+ calculate_projects(*args).each do |path|
28
+ if path =~ /(^.*\/#{shared}\/).*/
29
+ projects[$1] = true
30
+ end
31
+ end
32
+
33
+ out = projects.keys
34
+
35
+ # TODO: make sure none are children of other ones in there
36
+ out
37
+ end
38
+
25
39
  def calculate_file_statistics(file, type = :code, &block)
26
40
  stats = CodeStatisticsCalculator.new
27
41
 
@@ -1,3 +1,3 @@
1
1
  module RailsStats
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Leonard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake