ruby-progress 1.3.5 → 1.3.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.
@@ -9,6 +9,16 @@ require_relative 'cli/worm_runner'
9
9
  module RubyProgress
10
10
  # Animated progress indicator with ripple effect using Unicode combining characters
11
11
  class Worm
12
+ # Worm indicator renders a small ripple/wave of characters. Use this
13
+ # class directly to control a running indicator, or use the CLI helpers
14
+ # which wrap this behavior for daemonization and command execution.
15
+ #
16
+ # Public instance methods (selected): #generate_dots
17
+ # Public module mixins provide the main animation loop via WormRunner.
18
+ #
19
+ # @example
20
+ # w = RubyProgress::Worm.new(length: 5, message: 'loading')
21
+ # w.send(:generate_dots, 2, 1) # => "..o.."
12
22
  # Ripple effect styles
13
23
  RIPPLE_STYLES = {
14
24
  'circles' => {
@@ -56,6 +66,13 @@ module RubyProgress
56
66
  }.freeze
57
67
 
58
68
  def initialize(options = {})
69
+ # Create a new Worm indicator instance.
70
+ #
71
+ # @param options [Hash] configuration options
72
+ # @option options [Integer] :length number of characters in the ripple (default 3)
73
+ # @option options [String] :message optional label text
74
+ # @option options [String,Symbol] :style ripple style name or custom spec
75
+ # @return [void]
59
76
  @length = options[:length] || 3
60
77
  @message = options[:message]
61
78
  @speed = parse_speed(options[:speed] || 'medium')
@@ -154,7 +171,7 @@ module RubyProgress
154
171
  input_chars.all? do |char|
155
172
  idx = key_chars.index(char)
156
173
  if idx
157
- key_chars = key_chars[idx + 1..-1] # Remove matched chars and continue
174
+ key_chars = key_chars[(idx + 1)..-1] # Remove matched chars and continue
158
175
  true
159
176
  else
160
177
  false
@@ -207,6 +224,11 @@ module RubyProgress
207
224
  # @output_capture&.redraw) will be overridden.
208
225
 
209
226
  def generate_dots(ripple_position, direction)
227
+ # Generate the string representing the ripple at a given position.
228
+ #
229
+ # @param ripple_position [Integer] index of the ripple peak
230
+ # @param direction [Integer] -1 for left-moving, +1 for right-moving
231
+ # @return [String] composed characters for current frame
210
232
  dots = Array.new(@length) { @style[:baseline] }
211
233
 
212
234
  # Apply ripple effect
data/project-page.md ADDED
@@ -0,0 +1,162 @@
1
+ # Ruby Progress Indicators
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/ruby-progress.svg)](https://badge.fury.io/rb/ruby-progress)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Ruby](https://img.shields.io/badge/ruby-%3E%3D%202.5.0-ruby.svg)](https://www.ruby-lang.org/)
6
+
7
+ A collection of Ruby progress indicator projects: **Ripple**, **Worm**,
8
+ **Twirl**, and **Fill**. All provide animated terminal progress indicators
9
+ with different visual styles and features.
10
+
11
+ ## Quick Start
12
+
13
+ Install the gem:
14
+
15
+ {% iterm "gem install ruby-progress" %}
16
+
17
+ Use the unified interface:
18
+
19
+ {% iterm "prg worm --message 'Processing data' --style blocks --checkmark" %}
20
+
21
+ {% iterm "prg ripple 'Loading...' --style rainbow --speed fast" %}
22
+
23
+ {% iterm "prg twirl --message 'Working...' --style dots --speed fast" %}
24
+
25
+ ## Unified Interface
26
+
27
+ The gem provides a unified `prg` command that supports all progress
28
+ indicators through subcommands. Run commands with progress animation:
29
+
30
+ {% iterm "prg worm --command 'sleep 5' --success 'Completed!' --error 'Failed!' --checkmark" %}
31
+
32
+ {% iterm "prg ripple 'Building...' --command 'make build' --success 'Build complete!' --stdout" %}
33
+
34
+ {% iterm "prg twirl --command 'npm install' --message 'Installing packages' --style arc" %}
35
+
36
+ [See the README for more CLI examples](https://github.com/ttscoff/ruby-progress/blob/main/README.md#ripple-cli-examples)
37
+
38
+ ## Ripple
39
+
40
+ Sophisticated text animation library that creates ripple effects across
41
+ text strings in the terminal. Supports various animation modes including
42
+ bidirectional movement and rainbow colors.
43
+
44
+ **Key Features:**
45
+
46
+ - Text ripple animations with customizable speed and direction
47
+ - Style system supporting rainbow colors and inverse highlighting
48
+ - Multiple animation formats: forward-only, bidirectional
49
+ - Command execution with animated progress display
50
+
51
+ Basic text animation:
52
+
53
+ {% iterm "prg ripple 'Loading...'" %}
54
+
55
+ With style options:
56
+
57
+ {% iterm "prg ripple 'Processing Data' --speed fast --style rainbow --direction bidirectional" %}
58
+
59
+ Run a command with progress animation:
60
+
61
+ {% iterm "prg ripple 'Installing packages' --command 'sleep 5' --success 'Installation complete!' --checkmark" %}
62
+
63
+ [See the README for more Ripple CLI examples](https://github.com/ttscoff/ruby-progress/blob/main/README.md#ripple-cli-examples)
64
+
65
+ ## Twirl
66
+
67
+ Lightweight spinner animation system providing over 35 different spinner
68
+ styles for terminal progress indication. Perfect for showing indefinite
69
+ progress during command execution.
70
+
71
+ **Key Features:**
72
+
73
+ - 35+ spinner styles including dots, arrows, blocks, and geometric patterns
74
+ - Flexible speed control (1-10 scale or named speeds)
75
+ - Command execution with animated progress display
76
+ - Daemon mode for background progress indication
77
+
78
+ Basic spinner animation:
79
+
80
+ {% iterm "prg twirl --message 'Processing...' --style dots" %}
81
+
82
+ With command execution:
83
+
84
+ {% iterm "prg twirl --command 'npm install' --message 'Installing' --style arc" %}
85
+
86
+ Different spinner styles:
87
+
88
+ {% iterm "prg twirl --message 'Working' --style arrows --speed fast" %}
89
+
90
+ [See the README for more Twirl CLI examples](https://github.com/ttscoff/ruby-progress/blob/main/README.md#twirl-usage)
91
+
92
+ ## Worm
93
+
94
+ Clean, Unicode-based progress indicator that creates a ripple effect using
95
+ combining characters. Designed for running commands with visual progress
96
+ feedback.
97
+
98
+ **Key Features:**
99
+
100
+ - Ripple wave animation using Unicode characters
101
+ - Multiple visual styles (circles, blocks, geometric)
102
+ - Configurable speed and customizable length
103
+ - Command execution with progress indication
104
+ - Custom styles with 3-character patterns
105
+
106
+ Run indefinitely without a command:
107
+
108
+ {% iterm "prg worm --message 'Loading...' --speed fast --style circles" %}
109
+
110
+ Run a command with progress animation:
111
+
112
+ {% iterm "prg worm --command 'sleep 5' --message 'Installing' --success 'Done!'" %}
113
+
114
+ Custom animations with 3-character patterns:
115
+
116
+ {% iterm "prg worm --message 'Custom style' --style 'custom=_-=' --command 'sleep 2'" %}
117
+
118
+ {% iterm "prg worm --message 'Emoji worm!' --style 'custom=🟦🟨🟥' --success 'Complete!'" %}
119
+
120
+ [See the README for more Worm CLI examples](https://github.com/ttscoff/ruby-progress/blob/main/README.md#worm-usage)
121
+
122
+ ## Background Mode
123
+
124
+ All progress indicators support daemon mode for background tasks:
125
+
126
+ Start a background indicator:
127
+
128
+ {% iterm "prg worm --daemon-as mytask --message 'Background processing'" %}
129
+
130
+ Stop it later with a message:
131
+
132
+ {% iterm "prg job stop --daemon-name mytask --message 'Task complete!' --checkmark" %}
133
+
134
+ [See the README for more background mode examples](https://github.com/ttscoff/ruby-progress/blob/main/README.md#example-background-mode-demo)
135
+
136
+ ## Installation
137
+
138
+ As a gem (recommended):
139
+
140
+ {% iterm "gem install ruby-progress" %}
141
+
142
+ From source:
143
+
144
+ {% iterm "git clone https://github.com/ttscoff/ruby-progress.git" %}
145
+
146
+ {% iterm "cd ruby-progress" %}
147
+
148
+ {% iterm "bundle install" %}
149
+
150
+ {% iterm "bundle exec rake build" %}
151
+
152
+ {% iterm "gem install pkg/ruby-progress-*.gem" %}
153
+
154
+ [See the README for more installation options](https://github.com/ttscoff/ruby-progress/blob/main/README.md#installation)
155
+
156
+ ## Requirements
157
+
158
+ - Ruby 2.7 or higher
159
+ - Terminal with Unicode support (for Worm)
160
+ - ANSI color support (for Ripple rainbow effects)
161
+
162
+ [See the README for complete documentation](https://github.com/ttscoff/ruby-progress/blob/main/README.md)
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.3.5
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
@@ -140,6 +140,7 @@ files:
140
140
  - lib/ruby-progress/utils.rb
141
141
  - lib/ruby-progress/version.rb
142
142
  - lib/ruby-progress/worm.rb
143
+ - project-page.md
143
144
  - quick_demo.rb
144
145
  - readme_demo.rb
145
146
  - ruby-progress.gemspec