console 1.24.0 → 1.25.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2020-2022, by Samuel Williams.
5
-
6
- require_relative 'generic'
7
-
8
- module Console
9
- module Event
10
- class Progress < Generic
11
- BLOCK = [
12
- " ",
13
- "▏",
14
- "▎",
15
- "▍",
16
- "▌",
17
- "▋",
18
- "▊",
19
- "▉",
20
- "█",
21
- ]
22
-
23
- def initialize(current, total)
24
- @current = current
25
- @total = total
26
- end
27
-
28
- attr :current
29
- attr :total
30
-
31
- def value
32
- @current.to_f / @total.to_f
33
- end
34
-
35
- def bar(value = self.value, width = 70)
36
- blocks = width * value
37
- full_blocks = blocks.floor
38
- partial_block = ((blocks - full_blocks) * BLOCK.size).floor
39
-
40
- if partial_block.zero?
41
- BLOCK.last * full_blocks
42
- else
43
- "#{BLOCK.last * full_blocks}#{BLOCK[partial_block]}"
44
- end.ljust(width)
45
- end
46
-
47
- def self.register(terminal)
48
- terminal[:progress_bar] ||= terminal.style(:blue, :white)
49
- end
50
-
51
- def to_h
52
- {current: @current, total: @total}
53
- end
54
-
55
- def format(output, terminal, verbose)
56
- output.puts "#{terminal[:progress_bar]}#{self.bar}#{terminal.reset} #{sprintf('%6.2f', self.value * 100)}%"
57
- end
58
- end
59
- end
60
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2021-2023, by Samuel Williams.
5
-
6
- require_relative '../serialized/logger'
7
-
8
- module Console
9
- module Output
10
- module JSON
11
- def self.new(output, **options)
12
- Serialized::Logger.new(output, format: Format.default_json, **options)
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
5
-
6
- require_relative '../terminal/logger'
7
-
8
- module Console
9
- module Output
10
- module Text
11
- def self.new(output, **options)
12
- Terminal::Logger.new(output, format: Terminal::Text, **options)
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
5
-
6
- require_relative '../terminal/logger'
7
-
8
- module Console
9
- module Output
10
- module XTerm
11
- def self.new(output, **options)
12
- Terminal::Logger.new(output, format: Terminal::XTerm, **options)
13
- end
14
- end
15
- end
16
- end
data/lib/console/split.rb DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
5
-
6
- require_relative 'output/split'
7
-
8
- module Console
9
- Split = Output::Split
10
- end