ruby-progress 1.2.4 → 1.3.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 +4 -4
- data/.rubocop_todo.yml +26 -45
- data/CHANGELOG.md +38 -1
- data/Gemfile.lock +1 -1
- data/README.md +126 -133
- data/Rakefile +0 -3
- data/bin/prg +50 -0
- data/demo_screencast.rb +180 -36
- data/examples/daemon_job_example.sh +25 -0
- data/lib/ruby-progress/cli/fill_options.rb +73 -1
- data/lib/ruby-progress/cli/job_cli.rb +159 -0
- data/lib/ruby-progress/cli/ripple_cli.rb +88 -9
- data/lib/ruby-progress/cli/ripple_options.rb +22 -0
- data/lib/ruby-progress/cli/twirl_options.rb +30 -1
- data/lib/ruby-progress/cli/twirl_runner.rb +62 -5
- data/lib/ruby-progress/cli/twirl_spinner.rb +19 -2
- data/lib/ruby-progress/cli/worm_cli.rb +61 -19
- data/lib/ruby-progress/cli/worm_options.rb +32 -3
- data/lib/ruby-progress/cli/worm_runner.rb +37 -17
- data/lib/ruby-progress/daemon.rb +65 -0
- data/lib/ruby-progress/fill.rb +9 -3
- data/lib/ruby-progress/fill_cli.rb +189 -38
- data/lib/ruby-progress/output_capture.rb +136 -0
- data/lib/ruby-progress/ripple.rb +4 -2
- data/lib/ruby-progress/utils.rb +47 -26
- data/lib/ruby-progress/version.rb +6 -6
- data/lib/ruby-progress/worm.rb +8 -7
- data/screencast +26 -0
- metadata +5 -2
- data/ruby-progress.gemspec +0 -40
data/lib/ruby-progress/utils.rb
CHANGED
|
@@ -13,12 +13,17 @@ module RubyProgress
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def self.clear_line(output_stream = :stderr)
|
|
16
|
-
case output_stream
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
io = case output_stream
|
|
17
|
+
when :stdout
|
|
18
|
+
$stdout
|
|
19
|
+
when :stderr
|
|
20
|
+
$stderr
|
|
21
|
+
else
|
|
22
|
+
# allow passing an IO-like object (e.g. StringIO) directly
|
|
23
|
+
output_stream.respond_to?(:print) ? output_stream : $stderr
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
io.print "\r\e[K"
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
# Enhanced line clearing for daemon mode that handles output interruption
|
|
@@ -33,39 +38,55 @@ module RubyProgress
|
|
|
33
38
|
# @param success [Boolean] Whether this represents success or failure
|
|
34
39
|
# @param show_checkmark [Boolean] Whether to show checkmark/X symbols
|
|
35
40
|
# @param output_stream [Symbol] Where to output (:stdout, :stderr, :warn)
|
|
36
|
-
def self.display_completion(message, success: true, show_checkmark: false, output_stream: :warn)
|
|
41
|
+
def self.display_completion(message, success: true, show_checkmark: false, output_stream: :warn, icons: {})
|
|
37
42
|
return unless message
|
|
38
43
|
|
|
39
|
-
mark =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
mark = if show_checkmark
|
|
45
|
+
icon = success ? (icons[:success] || '✅') : (icons[:error] || '🛑')
|
|
46
|
+
"#{icon} "
|
|
47
|
+
else
|
|
48
|
+
''
|
|
49
|
+
end
|
|
43
50
|
|
|
44
51
|
formatted_message = "#{mark}#{message}"
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
# Resolve destination IO: support symbols (:stdout/:stderr/:warn) or an IO-like object
|
|
54
|
+
dest_io = case output_stream
|
|
55
|
+
when :stdout
|
|
56
|
+
$stdout
|
|
57
|
+
when :stderr
|
|
58
|
+
$stderr
|
|
59
|
+
when :warn
|
|
60
|
+
$stderr
|
|
61
|
+
else
|
|
62
|
+
output_stream.respond_to?(:print) ? output_stream : $stderr
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Only treat explicit :stdout and :stderr as non-clearing requests.
|
|
66
|
+
# For :warn and any other/custom stream, clear the current line first.
|
|
67
|
+
unless %i[stdout stderr].include?(output_stream)
|
|
68
|
+
# Always include a leading carriage return when clearing to match
|
|
69
|
+
# terminal behavior expected by the test-suite.
|
|
70
|
+
dest_io.print "\r\e[2K"
|
|
71
|
+
dest_io.flush if dest_io.respond_to?(:flush)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Emit the message to the resolved destination IO. Use warn/puts when targeting
|
|
75
|
+
# the standard streams to preserve familiar behavior (warn writes to $stderr).
|
|
76
|
+
if dest_io == $stdout
|
|
77
|
+
$stdout.puts formatted_message
|
|
78
|
+
elsif dest_io == $stderr
|
|
55
79
|
warn formatted_message
|
|
56
80
|
else
|
|
57
|
-
|
|
58
|
-
$stderr.print "\r\e[2K"
|
|
59
|
-
$stderr.flush
|
|
60
|
-
warn formatted_message
|
|
81
|
+
dest_io.puts formatted_message
|
|
61
82
|
end
|
|
62
83
|
end
|
|
63
84
|
|
|
64
85
|
# Clear current line and display completion message
|
|
65
86
|
# Convenience method that combines line clearing with message display
|
|
66
|
-
def self.complete_with_clear(message, success: true, show_checkmark: false, output_stream: :warn)
|
|
87
|
+
def self.complete_with_clear(message, success: true, show_checkmark: false, output_stream: :warn, icons: {})
|
|
67
88
|
clear_line(output_stream) if output_stream != :warn # warn already includes clear in display_completion
|
|
68
|
-
display_completion(message, success: success, show_checkmark: show_checkmark, output_stream: output_stream)
|
|
89
|
+
display_completion(message, success: success, show_checkmark: show_checkmark, output_stream: output_stream, icons: icons)
|
|
69
90
|
end
|
|
70
91
|
|
|
71
92
|
# Parse start/end characters for animation wrapping
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module RubyProgress
|
|
4
4
|
# Main gem version
|
|
5
|
-
VERSION = '1.2
|
|
5
|
+
VERSION = '1.3.2'
|
|
6
6
|
|
|
7
|
-
# Component-specific versions
|
|
8
|
-
WORM_VERSION = '1.1.
|
|
9
|
-
TWIRL_VERSION = '1.1.
|
|
10
|
-
RIPPLE_VERSION = '1.1.
|
|
11
|
-
FILL_VERSION = '1.0.
|
|
7
|
+
# Component-specific versions (patch bumps)
|
|
8
|
+
WORM_VERSION = '1.1.4'
|
|
9
|
+
TWIRL_VERSION = '1.1.4'
|
|
10
|
+
RIPPLE_VERSION = '1.1.4'
|
|
11
|
+
FILL_VERSION = '1.0.4'
|
|
12
12
|
end
|
data/lib/ruby-progress/worm.rb
CHANGED
|
@@ -76,13 +76,14 @@ module RubyProgress
|
|
|
76
76
|
def display_completion_message(message, success)
|
|
77
77
|
return unless message
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
# Delegate to Utils.display_completion so carriage-return and clearing
|
|
80
|
+
# behavior is consistent across all indicators and respects TTY state.
|
|
81
|
+
RubyProgress::Utils.display_completion(
|
|
82
|
+
message,
|
|
83
|
+
success: success,
|
|
84
|
+
show_checkmark: @show_checkmark,
|
|
85
|
+
output_stream: :warn
|
|
86
|
+
)
|
|
86
87
|
end
|
|
87
88
|
|
|
88
89
|
def parse_speed(speed_input)
|
data/screencast
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{"version":2,"width":146,"height":24,"timestamp":1760358387,"duration":4.124379,"env":{"SHELL":"/opt/homebrew/bin/fish","TERM":"xterm-256color"}}
|
|
2
|
+
[0.002162,"o","$ bin/prg worm --command \"sleep 4\"\r\n"]
|
|
3
|
+
[0.052412,"o","\u001b[?25l"]
|
|
4
|
+
[0.054304,"o","\r\u001b[2K⬤··"]
|
|
5
|
+
[0.260053,"o","\r\u001b[2K●⬤·"]
|
|
6
|
+
[0.462807,"o","\r\u001b[2K··⬤"]
|
|
7
|
+
[0.667558,"o","\r\u001b[2K·⬤●"]
|
|
8
|
+
[0.86773,"o","\r\u001b[2K⬤··"]
|
|
9
|
+
[1.06914,"o","\r\u001b[2K●⬤·"]
|
|
10
|
+
[1.273207,"o","\r\u001b[2K··⬤"]
|
|
11
|
+
[1.477782,"o","\r\u001b[2K·⬤●"]
|
|
12
|
+
[1.682846,"o","\r\u001b[2K⬤··"]
|
|
13
|
+
[1.885136,"o","\r\u001b[2K●⬤·"]
|
|
14
|
+
[2.087746,"o","\r\u001b[2K··⬤"]
|
|
15
|
+
[2.290181,"o","\r\u001b[2K·⬤●"]
|
|
16
|
+
[2.494656,"o","\r\u001b[2K⬤··"]
|
|
17
|
+
[2.69979,"o","\r\u001b[2K●⬤·"]
|
|
18
|
+
[2.900129,"o","\r\u001b[2K··⬤"]
|
|
19
|
+
[3.102774,"o","\r\u001b[2K·⬤●"]
|
|
20
|
+
[3.303982,"o","\r\u001b[2K⬤··"]
|
|
21
|
+
[3.507771,"o","\r\u001b[2K●⬤·"]
|
|
22
|
+
[3.711678,"o","\r\u001b[2K··⬤"]
|
|
23
|
+
[3.915598,"o","\r\u001b[2K·⬤●"]
|
|
24
|
+
[4.120702,"o","\r\u001b[2K"]
|
|
25
|
+
[4.121323,"o","\u001b[?25h"]
|
|
26
|
+
[4.124379,"o",""]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-progress
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brett Terpstra
|
|
@@ -101,10 +101,12 @@ files:
|
|
|
101
101
|
- demo_worm_infinite.rb
|
|
102
102
|
- examples/bash_daemon_demo.sh
|
|
103
103
|
- examples/daemon_demo.rb
|
|
104
|
+
- examples/daemon_job_example.sh
|
|
104
105
|
- examples/utils_demo.rb
|
|
105
106
|
- experimental_terminal.rb
|
|
106
107
|
- lib/ruby-progress.rb
|
|
107
108
|
- lib/ruby-progress/cli/fill_options.rb
|
|
109
|
+
- lib/ruby-progress/cli/job_cli.rb
|
|
108
110
|
- lib/ruby-progress/cli/ripple_cli.rb
|
|
109
111
|
- lib/ruby-progress/cli/ripple_options.rb
|
|
110
112
|
- lib/ruby-progress/cli/twirl_cli.rb
|
|
@@ -117,13 +119,14 @@ files:
|
|
|
117
119
|
- lib/ruby-progress/daemon.rb
|
|
118
120
|
- lib/ruby-progress/fill.rb
|
|
119
121
|
- lib/ruby-progress/fill_cli.rb
|
|
122
|
+
- lib/ruby-progress/output_capture.rb
|
|
120
123
|
- lib/ruby-progress/ripple.rb
|
|
121
124
|
- lib/ruby-progress/utils.rb
|
|
122
125
|
- lib/ruby-progress/version.rb
|
|
123
126
|
- lib/ruby-progress/worm.rb
|
|
124
127
|
- quick_demo.rb
|
|
125
128
|
- readme_demo.rb
|
|
126
|
-
-
|
|
129
|
+
- screencast
|
|
127
130
|
- scripts/run_matrix_mise.fish
|
|
128
131
|
- test_daemon_interruption.rb
|
|
129
132
|
- test_daemon_orphan.rb
|
data/ruby-progress.gemspec
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'lib/ruby-progress/version'
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = 'ruby-progress'
|
|
7
|
-
spec.version = RubyProgress::VERSION
|
|
8
|
-
spec.authors = ['Brett Terpstra']
|
|
9
|
-
spec.email = ['me@brettterpstra.com']
|
|
10
|
-
|
|
11
|
-
spec.summary = 'Animated terminal progress indicators'
|
|
12
|
-
spec.description = 'Animated progress indicators for Ruby: Ripple (text ripple effects), Worm (Unicode wave animations), and Twirl (spinner indicators)'
|
|
13
|
-
spec.homepage = 'https://github.com/ttscoff/ruby-progress'
|
|
14
|
-
spec.license = 'MIT'
|
|
15
|
-
spec.required_ruby_version = '>= 2.5.0'
|
|
16
|
-
|
|
17
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
-
spec.metadata['source_code_uri'] = spec.homepage
|
|
19
|
-
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
20
|
-
|
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
|
22
|
-
spec.files = Dir.chdir(__dir__) do
|
|
23
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
|
24
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
spec.bindir = 'bin'
|
|
28
|
-
spec.executables = %w[prg ripple worm twirl fill]
|
|
29
|
-
spec.require_paths = ['lib']
|
|
30
|
-
|
|
31
|
-
# Runtime dependencies
|
|
32
|
-
# None required - uses only standard library
|
|
33
|
-
|
|
34
|
-
# Development dependencies
|
|
35
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
|
36
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
37
|
-
spec.add_development_dependency 'rubocop', '~> 1.21'
|
|
38
|
-
spec.add_development_dependency 'simplecov', '~> 0.21'
|
|
39
|
-
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
40
|
-
end
|