rails_stats 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +42 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +21 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +12 -2
- data/README.md +48 -5
- data/Rakefile +12 -0
- data/codecov.yml +2 -0
- data/lib/rails_stats/all.rb +4 -0
- data/lib/rails_stats/app_statistics.rb +9 -8
- data/lib/rails_stats/code_statistics.rb +9 -148
- data/lib/rails_stats/code_statistics_calculator.rb +5 -1
- data/lib/rails_stats/console_formatter.rb +59 -0
- data/lib/rails_stats/json_formatter.rb +46 -0
- data/lib/rails_stats/spec_statistics.rb +1 -1
- data/lib/rails_stats/stats_calculator.rb +137 -0
- data/lib/rails_stats/stats_formatter.rb +13 -0
- data/lib/rails_stats/tasks.rb +4 -3
- data/lib/rails_stats/test_statistics.rb +1 -1
- data/lib/rails_stats/util.rb +3 -3
- data/lib/rails_stats/version.rb +3 -1
- data/pull_request_template.md +9 -0
- data/rails_stats.gemspec +2 -2
- data/test/dummy/Gemfile +43 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +2 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +7 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +3 -0
- data/test/dummy/app/javascript/channels/consumer.js +6 -0
- data/test/dummy/app/javascript/channels/index.js +5 -0
- data/test/dummy/app/javascript/packs/application.js +16 -0
- data/test/dummy/app/jobs/application_job.rb +7 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +15 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +36 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config/application.rb +35 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/credentials.yml.enc +1 -0
- data/test/dummy/config/database.yml +85 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +62 -0
- data/test/dummy/config/environments/production.rb +112 -0
- data/test/dummy/config/environments/test.rb +49 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/content_security_policy.rb +30 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/pagy.rb +1 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/master.key +1 -0
- data/test/dummy/config/puma.rb +38 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config/storage.yml +34 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/lib/monkeypatches.rb +1 -0
- data/test/dummy/package.json +10 -0
- data/test/dummy/spec/models/user_spec.rb +3 -0
- data/test/dummy/spec/support/support_file.rb +1 -0
- data/test/dummy/test/models/user_test.rb +2 -0
- data/test/dummy/test/support/test_helper.rb +1 -0
- data/test/fixtures/console-output.txt +40 -0
- data/test/lib/rails_stats/code_statistics_test.rb +20 -0
- data/test/lib/rails_stats/json_formatter_test.rb +144 -0
- data/test/test_helper.rb +27 -0
- metadata +143 -15
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
describe RailsStats::JSONFormatter do
|
6
|
+
describe "#result" do
|
7
|
+
JSON_STRING = <<~EOS
|
8
|
+
[{
|
9
|
+
"name": "Libraries",
|
10
|
+
"files": "1",
|
11
|
+
"lines": "1",
|
12
|
+
"loc": "1",
|
13
|
+
"classes": "0",
|
14
|
+
"methods": "0",
|
15
|
+
"m_over_c": "0",
|
16
|
+
"loc_over_m": "0"
|
17
|
+
}, {
|
18
|
+
"name": "Mailers",
|
19
|
+
"files": "1",
|
20
|
+
"lines": "4",
|
21
|
+
"loc": "4",
|
22
|
+
"classes": "1",
|
23
|
+
"methods": "0",
|
24
|
+
"m_over_c": "0",
|
25
|
+
"loc_over_m": "0"
|
26
|
+
}, {
|
27
|
+
"name": "Model Tests",
|
28
|
+
"files": "2",
|
29
|
+
"lines": "5",
|
30
|
+
"loc": "4",
|
31
|
+
"classes": "2",
|
32
|
+
"methods": "0",
|
33
|
+
"m_over_c": "0",
|
34
|
+
"loc_over_m": "0"
|
35
|
+
}, {
|
36
|
+
"name": "Models",
|
37
|
+
"files": "1",
|
38
|
+
"lines": "3",
|
39
|
+
"loc": "3",
|
40
|
+
"classes": "1",
|
41
|
+
"methods": "0",
|
42
|
+
"m_over_c": "0",
|
43
|
+
"loc_over_m": "0"
|
44
|
+
}, {
|
45
|
+
"name": "Javascripts",
|
46
|
+
"files": "3",
|
47
|
+
"lines": "27",
|
48
|
+
"loc": "7",
|
49
|
+
"classes": "0",
|
50
|
+
"methods": "0",
|
51
|
+
"m_over_c": "0",
|
52
|
+
"loc_over_m": "0"
|
53
|
+
}, {
|
54
|
+
"name": "Jobs",
|
55
|
+
"files": "1",
|
56
|
+
"lines": "7",
|
57
|
+
"loc": "2",
|
58
|
+
"classes": "1",
|
59
|
+
"methods": "0",
|
60
|
+
"m_over_c": "0",
|
61
|
+
"loc_over_m": "0"
|
62
|
+
}, {
|
63
|
+
"name": "Controllers",
|
64
|
+
"files": "1",
|
65
|
+
"lines": "7",
|
66
|
+
"loc": "6",
|
67
|
+
"classes": "1",
|
68
|
+
"methods": "1",
|
69
|
+
"m_over_c": "1",
|
70
|
+
"loc_over_m": "4"
|
71
|
+
}, {
|
72
|
+
"name": "Helpers",
|
73
|
+
"files": "1",
|
74
|
+
"lines": "3",
|
75
|
+
"loc": "3",
|
76
|
+
"classes": "0",
|
77
|
+
"methods": "0",
|
78
|
+
"m_over_c": "0",
|
79
|
+
"loc_over_m": "0"
|
80
|
+
}, {
|
81
|
+
"name": "Channels",
|
82
|
+
"files": "2",
|
83
|
+
"lines": "8",
|
84
|
+
"loc": "8",
|
85
|
+
"classes": "2",
|
86
|
+
"methods": "0",
|
87
|
+
"m_over_c": "0",
|
88
|
+
"loc_over_m": "0"
|
89
|
+
}, {
|
90
|
+
"name": "Configuration",
|
91
|
+
"files": "19",
|
92
|
+
"lines": "417",
|
93
|
+
"loc": "111",
|
94
|
+
"classes": "1",
|
95
|
+
"methods": "0",
|
96
|
+
"m_over_c": "0",
|
97
|
+
"loc_over_m": "0"
|
98
|
+
}, {
|
99
|
+
"name": "Spec Support",
|
100
|
+
"files": "1",
|
101
|
+
"lines": "1",
|
102
|
+
"loc": "1",
|
103
|
+
"classes": "0",
|
104
|
+
"methods": "0",
|
105
|
+
"m_over_c": "0",
|
106
|
+
"loc_over_m": "0"
|
107
|
+
}, {
|
108
|
+
"name": "Test Support",
|
109
|
+
"files": "1",
|
110
|
+
"lines": "1",
|
111
|
+
"loc": "1",
|
112
|
+
"classes": "0",
|
113
|
+
"methods": "0",
|
114
|
+
"m_over_c": "0",
|
115
|
+
"loc_over_m": "0"
|
116
|
+
}, {
|
117
|
+
"name": "Total",
|
118
|
+
"files": "34",
|
119
|
+
"lines": "484",
|
120
|
+
"loc": "151",
|
121
|
+
"classes": "9",
|
122
|
+
"methods": "1",
|
123
|
+
"m_over_c": "0",
|
124
|
+
"loc_over_m": "149",
|
125
|
+
"code_to_test_ratio": "0.0",
|
126
|
+
"total": true
|
127
|
+
}]
|
128
|
+
EOS
|
129
|
+
|
130
|
+
it "outputs useful stats for a Rails project" do
|
131
|
+
root_directory = File.absolute_path("./test/dummy")
|
132
|
+
|
133
|
+
calculator = RailsStats::StatsCalculator.new(root_directory)
|
134
|
+
formatter = RailsStats::JSONFormatter.new(calculator)
|
135
|
+
|
136
|
+
sorted_expectation = JSON.parse(JSON_STRING).sort {|x, y| x["name"] <=> y["name"] }
|
137
|
+
sorted_result = formatter.result.sort {|x, y| x["name"] <=> y["name"] }
|
138
|
+
|
139
|
+
sorted_expectation.each_with_index do |x, i|
|
140
|
+
assert_equal x, sorted_result[i]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if ENV["COVERAGE"] == "true"
|
4
|
+
require "simplecov"
|
5
|
+
require "simplecov-console"
|
6
|
+
require "codecov"
|
7
|
+
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
10
|
+
SimpleCov::Formatter::Console,
|
11
|
+
SimpleCov::Formatter::Codecov,
|
12
|
+
]
|
13
|
+
|
14
|
+
SimpleCov.start do
|
15
|
+
track_files "lib/**/*.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "Using SimpleCov v#{SimpleCov::VERSION}"
|
19
|
+
end
|
20
|
+
|
21
|
+
require "byebug"
|
22
|
+
|
23
|
+
require "minitest/autorun"
|
24
|
+
require "minitest/pride"
|
25
|
+
require "minitest/around/spec"
|
26
|
+
require "minitest-spec-context"
|
27
|
+
require "rails_stats/all"
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Leonard
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
28
|
+
name: bundler-stats
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
34
|
-
type: :
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
40
|
+
version: '2.1'
|
41
41
|
description: Point it to a directory and see stuff about the app
|
42
42
|
email:
|
43
43
|
- brian@bleonard.com
|
@@ -45,31 +45,100 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/test.yml"
|
48
49
|
- ".gitignore"
|
50
|
+
- CHANGELOG.md
|
51
|
+
- CODE_OF_CONDUCT.md
|
49
52
|
- Gemfile
|
50
53
|
- LICENSE.txt
|
51
54
|
- README.md
|
52
55
|
- Rakefile
|
56
|
+
- codecov.yml
|
53
57
|
- lib/rails_stats.rb
|
54
58
|
- lib/rails_stats/all.rb
|
55
59
|
- lib/rails_stats/app_statistics.rb
|
56
60
|
- lib/rails_stats/code_statistics.rb
|
57
61
|
- lib/rails_stats/code_statistics_calculator.rb
|
62
|
+
- lib/rails_stats/console_formatter.rb
|
58
63
|
- lib/rails_stats/cucumber_statistics.rb
|
59
64
|
- lib/rails_stats/gem_statistics.rb
|
60
65
|
- lib/rails_stats/inflector.rb
|
66
|
+
- lib/rails_stats/json_formatter.rb
|
61
67
|
- lib/rails_stats/root_statistics.rb
|
62
68
|
- lib/rails_stats/spec_statistics.rb
|
69
|
+
- lib/rails_stats/stats_calculator.rb
|
70
|
+
- lib/rails_stats/stats_formatter.rb
|
63
71
|
- lib/rails_stats/tasks.rb
|
64
72
|
- lib/rails_stats/test_statistics.rb
|
65
73
|
- lib/rails_stats/util.rb
|
66
74
|
- lib/rails_stats/version.rb
|
75
|
+
- pull_request_template.md
|
67
76
|
- rails_stats.gemspec
|
68
|
-
|
77
|
+
- test/dummy/Gemfile
|
78
|
+
- test/dummy/Rakefile
|
79
|
+
- test/dummy/app/assets/config/manifest.js
|
80
|
+
- test/dummy/app/assets/images/.keep
|
81
|
+
- test/dummy/app/assets/stylesheets/application.css
|
82
|
+
- test/dummy/app/channels/application_cable/channel.rb
|
83
|
+
- test/dummy/app/channels/application_cable/connection.rb
|
84
|
+
- test/dummy/app/controllers/application_controller.rb
|
85
|
+
- test/dummy/app/controllers/concerns/.keep
|
86
|
+
- test/dummy/app/helpers/application_helper.rb
|
87
|
+
- test/dummy/app/javascript/channels/consumer.js
|
88
|
+
- test/dummy/app/javascript/channels/index.js
|
89
|
+
- test/dummy/app/javascript/packs/application.js
|
90
|
+
- test/dummy/app/jobs/application_job.rb
|
91
|
+
- test/dummy/app/mailers/application_mailer.rb
|
92
|
+
- test/dummy/app/models/application_record.rb
|
93
|
+
- test/dummy/app/models/concerns/.keep
|
94
|
+
- test/dummy/app/views/layouts/application.html.erb
|
95
|
+
- test/dummy/app/views/layouts/mailer.html.erb
|
96
|
+
- test/dummy/app/views/layouts/mailer.text.erb
|
97
|
+
- test/dummy/bin/rails
|
98
|
+
- test/dummy/bin/rake
|
99
|
+
- test/dummy/bin/setup
|
100
|
+
- test/dummy/bin/yarn
|
101
|
+
- test/dummy/config.ru
|
102
|
+
- test/dummy/config/application.rb
|
103
|
+
- test/dummy/config/boot.rb
|
104
|
+
- test/dummy/config/cable.yml
|
105
|
+
- test/dummy/config/credentials.yml.enc
|
106
|
+
- test/dummy/config/database.yml
|
107
|
+
- test/dummy/config/environment.rb
|
108
|
+
- test/dummy/config/environments/development.rb
|
109
|
+
- test/dummy/config/environments/production.rb
|
110
|
+
- test/dummy/config/environments/test.rb
|
111
|
+
- test/dummy/config/initializers/application_controller_renderer.rb
|
112
|
+
- test/dummy/config/initializers/assets.rb
|
113
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
114
|
+
- test/dummy/config/initializers/content_security_policy.rb
|
115
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
116
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
117
|
+
- test/dummy/config/initializers/inflections.rb
|
118
|
+
- test/dummy/config/initializers/mime_types.rb
|
119
|
+
- test/dummy/config/initializers/pagy.rb
|
120
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
121
|
+
- test/dummy/config/locales/en.yml
|
122
|
+
- test/dummy/config/master.key
|
123
|
+
- test/dummy/config/puma.rb
|
124
|
+
- test/dummy/config/routes.rb
|
125
|
+
- test/dummy/config/spring.rb
|
126
|
+
- test/dummy/config/storage.yml
|
127
|
+
- test/dummy/lib/monkeypatches.rb
|
128
|
+
- test/dummy/package.json
|
129
|
+
- test/dummy/spec/models/user_spec.rb
|
130
|
+
- test/dummy/spec/support/support_file.rb
|
131
|
+
- test/dummy/test/models/user_test.rb
|
132
|
+
- test/dummy/test/support/test_helper.rb
|
133
|
+
- test/fixtures/console-output.txt
|
134
|
+
- test/lib/rails_stats/code_statistics_test.rb
|
135
|
+
- test/lib/rails_stats/json_formatter_test.rb
|
136
|
+
- test/test_helper.rb
|
137
|
+
homepage: https://github.com/fastruby/rails_stats
|
69
138
|
licenses:
|
70
139
|
- MIT
|
71
140
|
metadata: {}
|
72
|
-
post_install_message:
|
141
|
+
post_install_message:
|
73
142
|
rdoc_options: []
|
74
143
|
require_paths:
|
75
144
|
- lib
|
@@ -84,9 +153,68 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
153
|
- !ruby/object:Gem::Version
|
85
154
|
version: '0'
|
86
155
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
signing_key:
|
156
|
+
rubygems_version: 3.0.3.1
|
157
|
+
signing_key:
|
90
158
|
specification_version: 4
|
91
159
|
summary: Analyze a Rails project
|
92
|
-
test_files:
|
160
|
+
test_files:
|
161
|
+
- test/dummy/Gemfile
|
162
|
+
- test/dummy/Rakefile
|
163
|
+
- test/dummy/app/assets/config/manifest.js
|
164
|
+
- test/dummy/app/assets/images/.keep
|
165
|
+
- test/dummy/app/assets/stylesheets/application.css
|
166
|
+
- test/dummy/app/channels/application_cable/channel.rb
|
167
|
+
- test/dummy/app/channels/application_cable/connection.rb
|
168
|
+
- test/dummy/app/controllers/application_controller.rb
|
169
|
+
- test/dummy/app/controllers/concerns/.keep
|
170
|
+
- test/dummy/app/helpers/application_helper.rb
|
171
|
+
- test/dummy/app/javascript/channels/consumer.js
|
172
|
+
- test/dummy/app/javascript/channels/index.js
|
173
|
+
- test/dummy/app/javascript/packs/application.js
|
174
|
+
- test/dummy/app/jobs/application_job.rb
|
175
|
+
- test/dummy/app/mailers/application_mailer.rb
|
176
|
+
- test/dummy/app/models/application_record.rb
|
177
|
+
- test/dummy/app/models/concerns/.keep
|
178
|
+
- test/dummy/app/views/layouts/application.html.erb
|
179
|
+
- test/dummy/app/views/layouts/mailer.html.erb
|
180
|
+
- test/dummy/app/views/layouts/mailer.text.erb
|
181
|
+
- test/dummy/bin/rails
|
182
|
+
- test/dummy/bin/rake
|
183
|
+
- test/dummy/bin/setup
|
184
|
+
- test/dummy/bin/yarn
|
185
|
+
- test/dummy/config.ru
|
186
|
+
- test/dummy/config/application.rb
|
187
|
+
- test/dummy/config/boot.rb
|
188
|
+
- test/dummy/config/cable.yml
|
189
|
+
- test/dummy/config/credentials.yml.enc
|
190
|
+
- test/dummy/config/database.yml
|
191
|
+
- test/dummy/config/environment.rb
|
192
|
+
- test/dummy/config/environments/development.rb
|
193
|
+
- test/dummy/config/environments/production.rb
|
194
|
+
- test/dummy/config/environments/test.rb
|
195
|
+
- test/dummy/config/initializers/application_controller_renderer.rb
|
196
|
+
- test/dummy/config/initializers/assets.rb
|
197
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
198
|
+
- test/dummy/config/initializers/content_security_policy.rb
|
199
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
200
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
201
|
+
- test/dummy/config/initializers/inflections.rb
|
202
|
+
- test/dummy/config/initializers/mime_types.rb
|
203
|
+
- test/dummy/config/initializers/pagy.rb
|
204
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
205
|
+
- test/dummy/config/locales/en.yml
|
206
|
+
- test/dummy/config/master.key
|
207
|
+
- test/dummy/config/puma.rb
|
208
|
+
- test/dummy/config/routes.rb
|
209
|
+
- test/dummy/config/spring.rb
|
210
|
+
- test/dummy/config/storage.yml
|
211
|
+
- test/dummy/lib/monkeypatches.rb
|
212
|
+
- test/dummy/package.json
|
213
|
+
- test/dummy/spec/models/user_spec.rb
|
214
|
+
- test/dummy/spec/support/support_file.rb
|
215
|
+
- test/dummy/test/models/user_test.rb
|
216
|
+
- test/dummy/test/support/test_helper.rb
|
217
|
+
- test/fixtures/console-output.txt
|
218
|
+
- test/lib/rails_stats/code_statistics_test.rb
|
219
|
+
- test/lib/rails_stats/json_formatter_test.rb
|
220
|
+
- test/test_helper.rb
|