philiprehberger-progress 0.3.0 → 0.4.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: f8cedfd9240c3ab6dd70848fbc63dca19ca4e3eea6d13ccada9e1663c73ca75d
4
- data.tar.gz: 3a81c872fc39dc070eaa68e0393c0e65d9878f7d54b01bd3ec9af557a40b92e2
3
+ metadata.gz: 9d1ecb051d55213a818343c3133c067129bf55e65b6677a2efb9be49c249ab5b
4
+ data.tar.gz: '0039452f607ef4f9fe1f1a1098b31039c6ea7ecbc9c0618c8f8fba78b5464763'
5
5
  SHA512:
6
- metadata.gz: 309c39e3e947e5dc7c9465cd4f1a1feff1fa9ec38221a11325243202c8f9e6326f1e60b458138b9d7fb2ec50ddd5b98cdf7425227d4a913b0dda464a3fd3d137
7
- data.tar.gz: 985d65af32ab52d1310b2f01e24b7024a1595e1357a1f09c074ad9bc636ffb0445a33b00fc5a943472955cf5c0d663df516905cb67140db80734ed6af218300e
6
+ metadata.gz: da6edc69bcc8dc77d091ba848dae89fb8f8e5054ceb1f9c6991537e85554b8a3bbde4cef23b94089d0c6194827ae6c13e3a7cb02f875d9d7ca9e3960519d7023
7
+ data.tar.gz: 5692a7b42fb906e3234117a3a96ca0ad2c1af88d558bc41e7a787cd8c1cc954a5c317613b91ff8d913b27b87263ea279d8bf497b19f17886cf57c8141578b6f8
data/CHANGELOG.md CHANGED
@@ -2,11 +2,21 @@
2
2
 
3
3
  All notable changes to this gem will be documented in this file.
4
4
 
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.0] - 2026-04-09
11
+
12
+ ### Added
13
+ - `Bar#set(n)` to set absolute progress position
14
+ - `Bar#reset` to restart the bar from 0, preserving configuration
15
+ - `Spinner#message=` to update the spinner message dynamically
16
+
17
+ ### Changed
18
+ - Standardize CHANGELOG header format to match template
19
+
10
20
  ## [0.3.0] - 2026-04-09
11
21
 
12
22
  ### Added
@@ -92,17 +102,3 @@ and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
92
102
  - `Progress.spin` convenience method with block support
93
103
  - `Progress.each` for iterating enumerables with progress display
94
104
  - 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
@@ -123,6 +123,8 @@ multi.finished? # => true
123
123
  |--------|-------------|
124
124
  | `.new(total:, width: 30, output: $stderr)` | Create a progress bar |
125
125
  | `#advance(n = 1)` | Advance by `n` items |
126
+ | `#set(n)` | Set absolute progress position (clamped to 0..total) |
127
+ | `#reset` | Reset to 0, clear finished state, restart timer |
126
128
  | `#finish` | Mark as complete |
127
129
  | `#finished?` | Whether the bar is finished |
128
130
  | `#percentage` | Current percentage (0.0 to 100.0) |
@@ -136,6 +138,7 @@ multi.finished? # => true
136
138
  | Method | Description |
137
139
  |--------|-------------|
138
140
  | `.new(message:, output: $stderr)` | Create a spinner |
141
+ | `#message=` | Update the spinner message dynamically |
139
142
  | `#spin` | Advance to the next frame |
140
143
  | `#auto_spin(interval: 0.1)` | Start background thread animation |
141
144
  | `#stop(final_message = 'done')` | Stop with a message (joins background thread) |
@@ -25,6 +25,28 @@ module Philiprehberger
25
25
  self
26
26
  end
27
27
 
28
+ # Set absolute progress position.
29
+ #
30
+ # @param n [Integer] the new current value (clamped to 0..total)
31
+ # @return [self]
32
+ def set(n)
33
+ return self if @finished
34
+
35
+ @current = [[n, 0].max, @total].min
36
+ render_to_output
37
+ self
38
+ end
39
+
40
+ # Reset the bar to 0, preserving total and width. Restarts the timer.
41
+ #
42
+ # @return [self]
43
+ def reset
44
+ @current = 0
45
+ @finished = false
46
+ @start_time = now
47
+ self
48
+ end
49
+
28
50
  def finish
29
51
  @current = @total
30
52
  @finished = true
@@ -6,7 +6,7 @@ module Philiprehberger
6
6
  FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807",
7
7
  "\u280F"].freeze
8
8
 
9
- attr_reader :message
9
+ attr_accessor :message
10
10
 
11
11
  def initialize(message:, output: $stderr)
12
12
  @message = message
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module Progress
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-progress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger