is-term 0.8.0 → 0.8.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4ae56431794997d6094441cfb78c837bad34ff05debaa1316cb8cd7bb2b02d4
4
- data.tar.gz: e0d5da7fa5ffe144e8d4a907563c484deba362a27f8c7e1ce9d05f85d84cde1d
3
+ metadata.gz: 725f8786862370f0da3dc92df025a7060298063b82d0cd626eb2a9edf298aae5
4
+ data.tar.gz: 6f6f9dbd2114fec0c053e3f48e3c82bce2cc9260bb72fdb132877faae9d843da
5
5
  SHA512:
6
- metadata.gz: e2e418bc52946002d187d349d393bd39b73b95524a5d7ffebd3891bb2182d70e30bdd41c2058603062ca95a165c122732fca1891b5379fdbbef623d3a3023057
7
- data.tar.gz: 5174cae5ca73ad0cf976ed29346ffce7926f00e323e5fa7014eb6a6cd912532863157290b66130a3ad484d9147293e990539c81f33a95fb413972071dd7866f2
6
+ metadata.gz: 84d03e3d7fac52f9f0af576febbbbe29d6cb5d1e5fdcb9719c396cad958b4957d40621b7b60a290a803225a0a5d6ea9bc65f04d4c2198e81f05852c872f3d652
7
+ data.tar.gz: 59792281dcc91931318d467a89fd45d7f6f1f0876cb4f872003f85de986c2b5c17426296dbd6fa0b092f471d17b9766e94949a30dde7cd7c33088e0a9288dffc
@@ -39,17 +39,21 @@ module IS::Term::StatusTable::Formats
39
39
  end
40
40
 
41
41
  # @return [String]
42
- def percent_bar value, width, complete: '=', incomplete: ' ', head: '>', done: '≡'
42
+ def percent_bar value, width, complete: '=', incomplete: ' ', head: '>', done: '≡', widths: [ nil, nil, nil, nil ]
43
43
  return '' if value.nil?
44
+ cw = widths[0] || complete&.width || 0
45
+ iw = widths[1] || incomplete&.width || 0
46
+ hw = widths[2] || head&.width || 0
47
+ dw = widths[3] || done&.width || 0
44
48
  if value >= 100
45
- done * (width / done.width)
49
+ done * (width / dw)
46
50
  elsif value == 0
47
- incomplete * (width / incomplete.width)
51
+ incomplete * (width / iw)
48
52
  else
49
53
  point = 100 / width
50
- i = (100 - value) / (point * incomplete.width)
54
+ i = (100 - value) / (point * iw)
51
55
  #h = 1
52
- c = width - i * incomplete.width - head.width
56
+ c = (width - i * iw - hw) / cw
53
57
  if c < 0
54
58
  i += c
55
59
  c = 0
@@ -66,6 +70,8 @@ module IS::Term::StatusTable::Formats
66
70
 
67
71
  class << self
68
72
 
73
+ using IS::Term::StringHelpers
74
+
69
75
  # @group Formatter Access
70
76
 
71
77
  # @return [Proc]
@@ -90,7 +96,8 @@ module IS::Term::StatusTable::Formats
90
96
  complete: complete,
91
97
  incomplete: incomplete,
92
98
  head: head,
93
- done: done
99
+ done: done,
100
+ widths: [ complete&.width, incomplete&.width, head&.width, done&.width ]
94
101
  }
95
102
  lambda { |value| self.percent_bar(value, width, **opts) }
96
103
  end
data/lib/is-term/info.rb CHANGED
@@ -7,7 +7,7 @@ module IS::Term; end
7
7
  module IS::Term::Info
8
8
 
9
9
  NAME = 'is-term'
10
- VERSION = '0.8.0'
10
+ VERSION = '0.8.2'
11
11
  AUTHOR = "Ivan Shikhalev"
12
12
  AUTHOR_URL = "https://github.com/shikhalev"
13
13
  EMAIL = "shikhalev@gmail.com"
@@ -202,6 +202,7 @@ class IS::Term::StatusTable
202
202
  end
203
203
  if definition[:width] && !skip_width
204
204
  value = value.ellipsis definition[:width]
205
+ value = value.align definition[:width], definition[:align]
205
206
  end
206
207
  return false if !skip_width && value.width > definition[:_width] && !@in_table_render
207
208
  result << value
@@ -246,6 +247,7 @@ class IS::Term::StatusTable
246
247
  end
247
248
  if definition[:width] && !skip_width
248
249
  value = value.ellipsis definition[:width]
250
+ value = value.align definition[:width], definition[:align]
249
251
  end
250
252
  return false if !skip_width && value.width > definition[:_width] && !@in_table_render
251
253
  result << value
@@ -354,6 +356,7 @@ class IS::Term::StatusTable
354
356
  end
355
357
  raise ArgumentError, "Invalid width value: #{ width.inspect }", caller_locations unless width.nil? || width.is_a?(Integer)
356
358
  raise ArgumentError, "Invalid align value: #{ align.inspect }", caller_locations unless align.nil? || IS::Term::StringHelpers::ALIGN_MODES.include?(align)
359
+ align = IS::Term::StringHelpers::DEFAULT_ALIGN_MODE if align.nil?
357
360
  summary_keys = Set[*(SUMMARY_NONE + SUMMARY_VALS)]
358
361
  if self.class.const_defined?(:Functions)
359
362
  summary_keys |= Set[*(Functions::TABLE_METHODS + Functions::AGGREGATE_METHODS)]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is-term
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Shikhalev
@@ -93,6 +93,20 @@ dependencies:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: simplecov
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
96
110
  executables: []
97
111
  extensions: []
98
112
  extra_rdoc_files: []