gloc 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/gloc +30 -7
- data/lib/gloc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9597ef8cbe66bd1bbabd842ce14ec2f704480ceaadf0dd31c378b6e9d5c9e32
|
4
|
+
data.tar.gz: 20fc8dd502a50480c0432f6b7261da11217e1c8d74e4d33a29a2f2c2deeba60e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c071d0a4803d928cd37d6394c084449776ed7f9162248fc5dcbdf61890ff46f4353a30673d6fefff1ae386ff921d840580dc3949ee0454fdffeb215269010fb
|
7
|
+
data.tar.gz: 463124056b75f7099654b03d338d94c0be65789d54058eed901c8bbd39ef89745fb262dc327c0538ad127058f394b1f2d3f1dcfa5285ce82d5de914b94303d77
|
data/Gemfile.lock
CHANGED
data/exe/gloc
CHANGED
@@ -120,6 +120,12 @@ sort_metric = case
|
|
120
120
|
else :code_count
|
121
121
|
end
|
122
122
|
|
123
|
+
file_stats = Hash[
|
124
|
+
STATS_FOR_FILE.sort_by { |_, stats|
|
125
|
+
stats.send(sort_metric)
|
126
|
+
}.reverse
|
127
|
+
]
|
128
|
+
|
123
129
|
source_stats = Hash[
|
124
130
|
STATS_FOR.sort_by { |_, stats|
|
125
131
|
stats.send(sort_metric)
|
@@ -176,13 +182,6 @@ source_stats.values.each do |stats_for_ext|
|
|
176
182
|
stats_for_ext.code_count = stats_for_ext.code_count.commify
|
177
183
|
end
|
178
184
|
|
179
|
-
# widest_file_ext = source_stats.keys.map(&:length).max
|
180
|
-
# widest_file_count = source_stats.values.map(&:file_count).map(&:length).max
|
181
|
-
# widest_line_count = source_stats.values.map(&:line_count).map(&:length).max
|
182
|
-
# widest_blank_count = source_stats.values.map(&:blank_count).map(&:length).max
|
183
|
-
# widest_comment_count = source_stats.values.map(&:comment_count).map(&:length).max
|
184
|
-
# widest_code_count = source_stats.values.map(&:code_count).map(&:length).max
|
185
|
-
|
186
185
|
DIVIDER = ('-' * 80) # because loc uses 80 columns
|
187
186
|
TEMPLATE = ' %-13s %12s %12s %12s %12s %12s'.freeze
|
188
187
|
|
@@ -208,6 +207,30 @@ puts format(
|
|
208
207
|
'Total', *source_stats.delete('TOTAL').to_h.values
|
209
208
|
)
|
210
209
|
|
210
|
+
exit unless $visual # show summary stats only
|
211
|
+
|
212
|
+
require 'rainbow'
|
213
|
+
require 'io/console'
|
214
|
+
|
215
|
+
max_line_count = file_stats.values.map(&:line_count).max
|
216
|
+
longest_filename = file_stats.keys.map(&:first).map(&:length).max
|
217
|
+
_, console_width = IO.console.winsize
|
218
|
+
available_width = Float(console_width - longest_filename - 5)
|
219
|
+
|
220
|
+
file_stats.each_pair do |(file, _, _), stats|
|
221
|
+
code_width = (available_width * stats.code_count / max_line_count)
|
222
|
+
comment_width = (available_width * stats.comment_count / max_line_count)
|
223
|
+
blank_width = (available_width * stats.blank_count / max_line_count)
|
224
|
+
|
225
|
+
puts format(
|
226
|
+
" %-#{longest_filename}<file>s | %<code>s%<comment>s%<blank>s",
|
227
|
+
file: file,
|
228
|
+
code: Rainbow('+' * code_width).green,
|
229
|
+
comment: Rainbow('-' * comment_width).red,
|
230
|
+
blank: Rainbow('⍽' * blank_width).blue,
|
231
|
+
)
|
232
|
+
end
|
233
|
+
|
211
234
|
#
|
212
235
|
# rubocop:enable Style/RegexpLiteral
|
213
236
|
# rubocop:enable Style/GlobalVars
|
data/lib/gloc/version.rb
CHANGED