colorls 1.2.1.pre.606 → 1.2.1.pre.613

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/colorls/core.rb +17 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e0e4f5763d6b85717a9641b9aee9d22673052a36d5db71ff4ee886b6a87ffff
4
- data.tar.gz: d146ac598c0ddfd1fe64959b1e44b96f7dc6f4b843bda08dbfc748414bfb233c
3
+ metadata.gz: ca1363c7e1f385fc4effe36186a63c319d1c9cee648d00f91824a7eae280b36a
4
+ data.tar.gz: b28a5dc5053606ec1e969ac7a5565e3c8ce5faa2ee94e74b20a313ea054f1dbe
5
5
  SHA512:
6
- metadata.gz: 2f227bdc38ef847d0a98162c8614beca1bb696dab8f44ac961208665372d2cbd69e0fdcb33618fae17442cd24b61d8c014345849f97fb227bd8cd93516789456
7
- data.tar.gz: 4cde5e0b18faec82635dc201a2a45eebc6cb64321de25dfe25e688fe0fa2ad5214ee1731364e321b725558f8327a0eed1ab80e0f0f78a209b858cc142dacbc22
6
+ metadata.gz: 7efd794bf0de142a9167150fc3b20b489e91127b0f8d2f760d3d747e090c58f2499b1473cd681fe64aeab16a34694cccf4ced2dbbb047ccf3e8e29329d80917c
7
+ data.tar.gz: d9cf7fb635e51c9dedb03f17c562a54b6e680c1af8124b06879719a4c2b06f877f6d86fb4520acb474577378c5c20e0a6574f121e10c10f6c0becd54bf67ecf9
data/lib/colorls/core.rb CHANGED
@@ -93,10 +93,8 @@ module ColorLS
93
93
  end
94
94
  @total_content_length = @contents.length
95
95
 
96
- return @contents unless @long
96
+ init_column_lengths
97
97
 
98
- init_user_lengths
99
- init_group_lengths
100
98
  @contents
101
99
  end
102
100
 
@@ -105,16 +103,20 @@ module ColorLS
105
103
  @contents.keep_if { |x| !x.start_with? '.' } unless @all || @almost_all
106
104
  end
107
105
 
108
- def init_user_lengths
109
- @userlength = @contents.map do |c|
110
- c.owner.length
111
- end.max
112
- end
106
+ def init_column_lengths
107
+ return unless @long
108
+
109
+ maxlink = maxuser = maxgroup = 0
113
110
 
114
- def init_group_lengths
115
- @grouplength = @contents.map do |c|
116
- c.group.length
117
- end.max
111
+ @contents.each do |c|
112
+ maxlink = c.nlink if c.nlink > maxlink
113
+ maxuser = c.owner.length if c.owner.length > maxuser
114
+ maxgroup = c.group.length if c.group.length > maxgroup
115
+ end
116
+
117
+ @linklength = maxlink.digits.length
118
+ @userlength = maxuser
119
+ @grouplength = maxgroup
118
120
  end
119
121
 
120
122
  def filter_contents
@@ -257,7 +259,9 @@ module ColorLS
257
259
  def long_info(content)
258
260
  return '' unless @long
259
261
 
260
- [mode_info(content.stats), content.nlink, user_info(content), group_info(content.group),
262
+ links = content.nlink.to_s.rjust(@linklength)
263
+
264
+ [mode_info(content.stats), links, user_info(content), group_info(content.group),
261
265
  size_info(content.size), mtime_info(content.mtime)].join(' ')
262
266
  end
263
267
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1.pre.606
4
+ version: 1.2.1.pre.613
5
5
  platform: ruby
6
6
  authors:
7
7
  - Athitya Kumar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-03 00:00:00.000000000 Z
11
+ date: 2019-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clocale