philiprehberger-progress 0.2.0 → 0.3.0

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: c6f9be35e1424be64489b24f5d9b63bbf9a9b202b154c6c5c2139a8845a94f75
4
- data.tar.gz: 0d8fedddb6f6a594f7ad766d996d2c98fb5a974ee4893942ce6be419eaaa653a
3
+ metadata.gz: f8cedfd9240c3ab6dd70848fbc63dca19ca4e3eea6d13ccada9e1663c73ca75d
4
+ data.tar.gz: 3a81c872fc39dc070eaa68e0393c0e65d9878f7d54b01bd3ec9af557a40b92e2
5
5
  SHA512:
6
- metadata.gz: cefbeb2571f5812ffbacc35d5dbf1df5b36523d7a51809b7030e945c7a3081e24934066a8cf3b8d4a261d87104da492d4d75637657da485c70ad48506688ddd7
7
- data.tar.gz: fff6cb774a53a996ec6c757c8d5c3123656691d5cf7fe91dc21169ff4ac37819070427980784b852ce908b240cc18394c7bb584a8fffe74352e6dab01343f25b
6
+ metadata.gz: 309c39e3e947e5dc7c9465cd4f1a1feff1fa9ec38221a11325243202c8f9e6326f1e60b458138b9d7fb2ec50ddd5b98cdf7425227d4a913b0dda464a3fd3d137
7
+ data.tar.gz: 985d65af32ab52d1310b2f01e24b7024a1595e1357a1f09c074ad9bc636ffb0445a33b00fc5a943472955cf5c0d663df516905cb67140db80734ed6af218300e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.0] - 2026-04-09
11
+
12
+ ### Added
13
+ - `Spinner#auto_spin(interval: 0.1)` starts a background thread that animates the spinner until `stop` is called
14
+ - `Progress.map(enumerable) { |item| ... }` transforms items with a progress bar, returning the collected results
15
+
16
+ ### Fixed
17
+ - Gemspec `required_ruby_version` format to `'>= 3.1.0'` (was `'>= 3.1'`)
18
+
10
19
  ## [0.2.0] - 2026-04-04
11
20
 
12
21
  ### Added
@@ -83,3 +92,17 @@ and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
83
92
  - `Progress.spin` convenience method with block support
84
93
  - `Progress.each` for iterating enumerables with progress display
85
94
  - TTY detection to auto-disable rendering in non-terminal environments
95
+
96
+ [0.3.0]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.3.0
97
+ [0.2.0]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.2.0
98
+ [0.1.11]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.11
99
+ [0.1.10]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.10
100
+ [0.1.9]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.9
101
+ [0.1.8]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.8
102
+ [0.1.7]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.7
103
+ [0.1.6]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.6
104
+ [0.1.5]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.5
105
+ [0.1.4]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.4
106
+ [0.1.3]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.3
107
+ [0.1.2]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.2
108
+ [0.1.0]: https://github.com/philiprehberger/rb-progress/releases/tag/v0.1.0
data/README.md CHANGED
@@ -68,6 +68,19 @@ Philiprehberger::Progress.spin('Processing...') do |spinner|
68
68
  end
69
69
  ```
70
70
 
71
+ ### Auto-spinning
72
+
73
+ Start a background thread that animates the spinner automatically:
74
+
75
+ ```ruby
76
+ Philiprehberger::Progress.spin("Deploying...") do |spinner|
77
+ spinner.auto_spin
78
+ deploy! # spinner animates while you work
79
+ end
80
+ ```
81
+
82
+ The thread is joined automatically when `stop` is called (or when the block completes).
83
+
71
84
  ### Enumerable Integration
72
85
 
73
86
  ```ruby
@@ -77,6 +90,15 @@ Philiprehberger::Progress.each(items) do |item|
77
90
  end
78
91
  ```
79
92
 
93
+ ### Mapping with Progress
94
+
95
+ Transform items while displaying progress:
96
+
97
+ ```ruby
98
+ results = Philiprehberger::Progress.map(urls) { |url| fetch(url) }
99
+ # results contains the return values from each block call
100
+ ```
101
+
80
102
  ### Multi-bar
81
103
 
82
104
  ```ruby
@@ -115,7 +137,8 @@ multi.finished? # => true
115
137
  |--------|-------------|
116
138
  | `.new(message:, output: $stderr)` | Create a spinner |
117
139
  | `#spin` | Advance to the next frame |
118
- | `#stop(final_message = 'done')` | Stop with a message |
140
+ | `#auto_spin(interval: 0.1)` | Start background thread animation |
141
+ | `#stop(final_message = 'done')` | Stop with a message (joins background thread) |
119
142
  | `#stopped?` | Whether the spinner is stopped |
120
143
  | `#to_s` | Render the current frame with message |
121
144
 
@@ -140,6 +163,7 @@ multi.finished? # => true
140
163
  | `Progress.spin(message, &block)` | Create spinner, auto-stop after block |
141
164
  | `Progress.multi(output: $stderr, &block)` | Create multi-bar tracker |
142
165
  | `Progress.each(enumerable, label: nil) { \|item\| }` | Iterate with progress |
166
+ | `Progress.map(enumerable, label: nil) { \|item\| }` | Transform with progress, returns results |
143
167
 
144
168
  ## Development
145
169
 
@@ -23,8 +23,20 @@ module Philiprehberger
23
23
  self
24
24
  end
25
25
 
26
+ def auto_spin(interval: 0.1)
27
+ @auto_thread = Thread.new do
28
+ until @stopped
29
+ spin
30
+ sleep(interval)
31
+ end
32
+ end
33
+ self
34
+ end
35
+
26
36
  def stop(final_message = 'done')
27
37
  @stopped = true
38
+ @auto_thread&.join
39
+ @auto_thread = nil
28
40
  @output.write("\r\e[2K#{final_message}\n") if tty?
29
41
  self
30
42
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module Progress
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -53,5 +53,19 @@ module Philiprehberger
53
53
  bar.finish
54
54
  items
55
55
  end
56
+
57
+ def self.map(enumerable, label: nil, output: $stderr)
58
+ items = enumerable.to_a
59
+ bar = Bar.new(total: items.length, output: output)
60
+
61
+ results = items.map do |item|
62
+ result = yield item
63
+ bar.advance
64
+ result
65
+ end
66
+
67
+ bar.finish
68
+ results
69
+ end
56
70
  end
57
71
  end
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-progress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-05 00:00:00.000000000 Z
11
+ date: 2026-04-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Display progress bars with percentage, ETA, and throughput, or spinners
14
- for indeterminate tasks. Supports block-based usage, enumerable iteration, and auto-disables
15
- rendering when not connected to a terminal.
14
+ for indeterminate tasks. Supports block-based usage, enumerable iteration with each/map,
15
+ background auto-spinning, multi-bar tracking, and auto-disables rendering when not
16
+ connected to a terminal.
16
17
  email:
17
18
  - me@philiprehberger.com
18
19
  executables: []
@@ -44,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
44
45
  requirements:
45
46
  - - ">="
46
47
  - !ruby/object:Gem::Version
47
- version: '3.1'
48
+ version: 3.1.0
48
49
  required_rubygems_version: !ruby/object:Gem::Requirement
49
50
  requirements:
50
51
  - - ">="