is-term 0.8.0 → 0.8.4

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: c37ae2be256250fa7dae77e58c31839bbfd9e80aec7bf62d00e6711f1d71d20c
4
+ data.tar.gz: b578b427433c8d856ecae60bbf1dc0cd6e34557566efc0de62267b48d708cc95
5
5
  SHA512:
6
- metadata.gz: e2e418bc52946002d187d349d393bd39b73b95524a5d7ffebd3891bb2182d70e30bdd41c2058603062ca95a165c122732fca1891b5379fdbbef623d3a3023057
7
- data.tar.gz: 5174cae5ca73ad0cf976ed29346ffce7926f00e323e5fa7014eb6a6cd912532863157290b66130a3ad484d9147293e990539c81f33a95fb413972071dd7866f2
6
+ metadata.gz: 141f30cefe750f957776bce3e48ac34b82e9b69322d117722c385b2ad1032e4a3268d057bab819a4b9142277793aa740460bb6439b4c6b01da27bbe620210def
7
+ data.tar.gz: 8f339644c5eba0f6cf265951c4f0898daf4cb7fd79be6341216bd53ebc23d357f9eabfe8ddd7d9fc563404337d1cbb0a5cdc387aaf4ae4bee0c150e40fb455e9
@@ -39,17 +39,26 @@ 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 skip value
43
+ ''
44
+ end
45
+
46
+ # @return [String]
47
+ def percent_bar value, width, complete: '=', incomplete: ' ', head: '>', done: '≡', widths: [ nil, nil, nil, nil ]
43
48
  return '' if value.nil?
49
+ cw = widths[0] || complete&.width || 0
50
+ iw = widths[1] || incomplete&.width || 0
51
+ hw = widths[2] || head&.width || 0
52
+ dw = widths[3] || done&.width || 0
44
53
  if value >= 100
45
- done * (width / done.width)
54
+ done * (width / dw)
46
55
  elsif value == 0
47
- incomplete * (width / incomplete.width)
56
+ incomplete * (width / iw)
48
57
  else
49
58
  point = 100 / width
50
- i = (100 - value) / (point * incomplete.width)
59
+ i = (100 - value) / (point * iw)
51
60
  #h = 1
52
- c = width - i * incomplete.width - head.width
61
+ c = (width - i * iw - hw) / cw
53
62
  if c < 0
54
63
  i += c
55
64
  c = 0
@@ -62,10 +71,12 @@ module IS::Term::StatusTable::Formats
62
71
 
63
72
  end
64
73
 
65
- SPECIAL_FORMATS = [ :duration ]
74
+ SPECIAL_FORMATS = [ :duration, :skip ]
66
75
 
67
76
  class << self
68
77
 
78
+ using IS::Term::StringHelpers
79
+
69
80
  # @group Formatter Access
70
81
 
71
82
  # @return [Proc]
@@ -90,7 +101,8 @@ module IS::Term::StatusTable::Formats
90
101
  complete: complete,
91
102
  incomplete: incomplete,
92
103
  head: head,
93
- done: done
104
+ done: done,
105
+ widths: [ complete&.width, incomplete&.width, head&.width, done&.width ]
94
106
  }
95
107
  lambda { |value| self.percent_bar(value, width, **opts) }
96
108
  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.4'
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.4
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: []