starlined 0.2.5 → 0.2.7
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 +4 -4
- data/lib/starlined/animation.rb +34 -3
- data/lib/starlined/messages.rb +5 -1
- data/lib/starlined/runner.rb +7 -0
- data/lib/starlined/version.rb +1 -1
- data/starlined.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1d1051ec7e3bbb187be26b08945792e7838eba17a02a8e7ac99d740d2d1ee3b
|
|
4
|
+
data.tar.gz: 95ca8766b86583470c000f8c487f5d7798371329eaf428cd0af208c20449287b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42405d2736503fe09ed8c8b778a577d4dfe206e257c9e0bc0d7082fa8bdbc5b5c6e435ccdbd3db05c8186c26b5ad34fa59fb1ab50a36e5eea353ccf49eb62187
|
|
7
|
+
data.tar.gz: 6c637fd92646be7c03a02c0e60b35ad25a9fdd48765c4e0b7d8749b8dc1d7bb8cb94d2508ce827266d236a28064d1d2bdeb5384db9822257c3d0894ea961f393
|
data/lib/starlined/animation.rb
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'colorize'
|
|
4
|
+
require 'io/console'
|
|
4
5
|
|
|
5
6
|
module Starlined
|
|
6
7
|
class Animation
|
|
7
|
-
attr_reader :thread, :message, :start_time, :steps, :current_steps
|
|
8
|
+
attr_reader :thread, :message, :start_time, :steps, :current_steps, :last_lines
|
|
8
9
|
attr_accessor :aliases
|
|
9
10
|
|
|
11
|
+
# líneas pendientes de limpiar (persiste entre instancias para que Messages pueda acceder)
|
|
12
|
+
@pending_clear_lines = 1
|
|
13
|
+
class << self
|
|
14
|
+
attr_accessor :pending_clear_lines
|
|
15
|
+
end
|
|
16
|
+
|
|
10
17
|
def initialize(message = 'Booting up', steps = 0)
|
|
11
18
|
@message = message
|
|
12
19
|
@start_time = Time.now
|
|
@@ -26,6 +33,9 @@ module Starlined
|
|
|
26
33
|
# semáforo para pasos
|
|
27
34
|
@steps_semaphore = Mutex.new
|
|
28
35
|
|
|
36
|
+
# líneas visuales que ocupa la última impresión
|
|
37
|
+
@last_lines = 1
|
|
38
|
+
|
|
29
39
|
@running = false
|
|
30
40
|
@thread = nil
|
|
31
41
|
end
|
|
@@ -81,7 +91,10 @@ module Starlined
|
|
|
81
91
|
extra = build_extra_info
|
|
82
92
|
|
|
83
93
|
clear_line
|
|
84
|
-
|
|
94
|
+
output = "[#{stars}] #{@message.ljust(config.msg_ljust)} #{extra}"
|
|
95
|
+
print "\r#{output}"
|
|
96
|
+
@last_lines = visible_line_count(output)
|
|
97
|
+
self.class.pending_clear_lines = @last_lines
|
|
85
98
|
|
|
86
99
|
move_stars
|
|
87
100
|
update_alias_timer
|
|
@@ -159,7 +172,25 @@ module Starlined
|
|
|
159
172
|
end
|
|
160
173
|
|
|
161
174
|
def clear_line
|
|
162
|
-
|
|
175
|
+
clear = Starlined.configuration.clear_line_string
|
|
176
|
+
# limpiar cada línea visual que ocupó la última impresión
|
|
177
|
+
(@last_lines - 1).times { print "\e[1A#{clear}" }
|
|
178
|
+
print "\r#{clear}"
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def visible_line_count(str)
|
|
182
|
+
cols = terminal_columns
|
|
183
|
+
return 1 if cols <= 0
|
|
184
|
+
|
|
185
|
+
# longitud visible sin escape sequences ANSI
|
|
186
|
+
visible = str.gsub(/\e\[[0-9;]*m/, '')
|
|
187
|
+
[(visible.length.to_f / cols).ceil, 1].max
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def terminal_columns
|
|
191
|
+
IO.console&.winsize&.last || 80
|
|
192
|
+
rescue StandardError
|
|
193
|
+
80
|
|
163
194
|
end
|
|
164
195
|
end
|
|
165
196
|
end
|
data/lib/starlined/messages.rb
CHANGED
|
@@ -49,7 +49,11 @@ module Starlined
|
|
|
49
49
|
private
|
|
50
50
|
|
|
51
51
|
def clear_line
|
|
52
|
-
|
|
52
|
+
clear = Starlined.configuration.clear_line_string
|
|
53
|
+
lines = Animation.pending_clear_lines || 1
|
|
54
|
+
(lines - 1).times { print "\e[1A#{clear}" }
|
|
55
|
+
print "\r#{clear}"
|
|
56
|
+
Animation.pending_clear_lines = 1
|
|
53
57
|
end
|
|
54
58
|
end
|
|
55
59
|
end
|
data/lib/starlined/runner.rb
CHANGED
data/lib/starlined/version.rb
CHANGED
data/starlined.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
|
|
11
11
|
spec.summary = 'Terminal output utilities with animated progress indicators'
|
|
12
12
|
spec.homepage = 'https://github.com/miermontoto/starlined'
|
|
13
|
-
spec.license = 'CC-NC-
|
|
13
|
+
spec.license = 'CC-BY-NC-4.0'
|
|
14
14
|
spec.required_ruby_version = '>= 2.6.0'
|
|
15
15
|
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: starlined
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mier
|
|
@@ -116,7 +116,7 @@ files:
|
|
|
116
116
|
- starlined.gemspec
|
|
117
117
|
homepage: https://github.com/miermontoto/starlined
|
|
118
118
|
licenses:
|
|
119
|
-
- CC-NC-
|
|
119
|
+
- CC-BY-NC-4.0
|
|
120
120
|
metadata:
|
|
121
121
|
homepage_uri: https://github.com/miermontoto/starlined
|
|
122
122
|
source_code_uri: https://github.com/miermontoto/starlined
|