gloc 0.4.0 → 0.5.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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/exe/gloc +30 -7
  4. data/lib/gloc/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd73796e1c759d5340ea4478edab80c3b9bfe05af571a23caaeee56f024564bb
4
- data.tar.gz: eab787cfeaaa52b9eadee669ddfbbfec46bf517766f9c06ca888d8ed890cf634
3
+ metadata.gz: e9597ef8cbe66bd1bbabd842ce14ec2f704480ceaadf0dd31c378b6e9d5c9e32
4
+ data.tar.gz: 20fc8dd502a50480c0432f6b7261da11217e1c8d74e4d33a29a2f2c2deeba60e
5
5
  SHA512:
6
- metadata.gz: 610cb691e8cba874108f5e8081405f5044a372df81469a71ef0fe03dde46640ffea2ff92a5ef27e27dae4ad818823fcffc145a2a2872e1b0df664b4e7b6558fe
7
- data.tar.gz: 592969a3042bab78d38b1dc53df591c9362ebc42fff0161e52157f36533e75708cf50ba7280173ae81baa58e4e9b92bbd4871850a52fbd3def3b468f64b90e9d
6
+ metadata.gz: 8c071d0a4803d928cd37d6394c084449776ed7f9162248fc5dcbdf61890ff46f4353a30673d6fefff1ae386ff921d840580dc3949ee0454fdffeb215269010fb
7
+ data.tar.gz: 463124056b75f7099654b03d338d94c0be65789d54058eed901c8bbd39ef89745fb262dc327c0538ad127058f394b1f2d3f1dcfa5285ce82d5de914b94303d77
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gloc (0.4.0)
4
+ gloc (0.5.0)
5
5
  rainbow (~> 3.0)
6
6
 
7
7
  GEM
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
@@ -1,6 +1,6 @@
1
1
  module GLOC
2
2
  NAME = 'gloc'.freeze
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.5.0'.freeze
4
4
 
5
5
  def self.version
6
6
  "#{NAME} v#{VERSION}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gloc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenberk