clack 0.4.3 → 0.4.4

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: 1a59e5250ad3fb130ffda74b6fdfa5bda7bb4f57062cd6305c5c07f0af7b82ee
4
- data.tar.gz: 8fb2da61ab0120a8f95189c9112463e742d87a7a915a30d9c5ae7d192c90475b
3
+ metadata.gz: b5a8d3270e58cb1ad88664e73215c2ea5217211829680707d7616714ba93c926
4
+ data.tar.gz: c8f58966b18a015c26b7669ebd495c0e7ba75d830088ad3135a0971dd03bc874
5
5
  SHA512:
6
- metadata.gz: f64a271d61f1e0b93938b418d2907a173cde44a901a98ba1f691b3c45c84e97ef8096e6b1a1b6e7b94470287920340f75df65ec62a213b661707ab935f266ead
7
- data.tar.gz: 6bf0a82964715fa130c64f15dc974a373aa00e996d285e19cf0518175b9916ff042b2fe7a042e1ea3d5720d3dee20c1fdbd914d5a77fd9f5a1f428f24622f7ee
6
+ metadata.gz: f3dbfd192f557ee0cd476be3ed80f54a57273e786d9120e3372c85527582ad8a30994b4202c83c309135383e6bedaaf275e756961912420961c09a24e53576e2
7
+ data.tar.gz: a692229800f14a3160aee3eca80f6c12b296c288e27dbf57b307b509090fdf0c72ca4e3712213f9515427ed0a48c70ee73534f85db887bb02ea1bfb9f0cf0177
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.4] - 2026-02-21
4
+
5
+ ### Fixed
6
+ - INT handler is now exception-safe (catches IOError/SystemCallError when output is unavailable)
7
+
8
+ ### Added
9
+ - SIGTERM handler restores cursor on graceful kill, matching INT handler behavior
10
+ - `Cursor.enabled?` now respects `FORCE_COLOR` environment variable, consistent with Colors module
11
+ - `Spinner#message` returns `self` for method chaining
12
+
13
+ ### Changed
14
+ - `Task` and `TaskResult` now use `Data.define` instead of `Struct.new` (Ruby 3.2+ idiom)
15
+
3
16
  ## [0.4.3] - 2026-02-21
4
17
 
5
18
  ### Fixed
@@ -14,6 +14,7 @@ module Clack
14
14
  return @enabled unless @enabled.nil?
15
15
 
16
16
  # Default: check if output supports ANSI escape sequences
17
+ return true if ENV["FORCE_COLOR"] && ENV["FORCE_COLOR"] != "0"
17
18
  $stdout.tty? && ENV["TERM"] != "dumb" && !ENV["NO_COLOR"]
18
19
  end
19
20
 
@@ -110,6 +110,7 @@ module Clack
110
110
  # @param msg [String] new message to display
111
111
  def message(msg)
112
112
  @mutex.synchronize { @message = remove_trailing_dots(msg) }
113
+ self
113
114
  end
114
115
 
115
116
  # Clear the spinner without showing a final message.
@@ -51,7 +51,7 @@ module Clack
51
51
  # @return [Proc] the task to execute
52
52
  # @!attribute [r] enabled
53
53
  # @return [Boolean] whether the task should run (default: true)
54
- Task = Struct.new(:title, :task, :enabled, keyword_init: true)
54
+ Task = Data.define(:title, :task, :enabled)
55
55
 
56
56
  # Result of a completed task, including status and any error.
57
57
  #
@@ -61,7 +61,7 @@ module Clack
61
61
  # @return [Symbol] :success or :error
62
62
  # @!attribute [r] error
63
63
  # @return [String, nil] error message if failed
64
- TaskResult = Struct.new(:title, :status, :error, keyword_init: true)
64
+ TaskResult = Data.define(:title, :status, :error)
65
65
 
66
66
  # @param tasks [Array<Hash>] tasks with :title, :task, and optional :enabled keys
67
67
  # @param output [IO] output stream (default: $stdout)
data/lib/clack/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Clack
4
4
  # Current gem version.
5
- VERSION = "0.4.3"
5
+ VERSION = "0.4.4"
6
6
  end
data/lib/clack.rb CHANGED
@@ -515,13 +515,32 @@ end
515
515
 
516
516
  # Chain INT handler to restore cursor before passing to previous handler
517
517
  previous_int_handler = trap("INT") do
518
- print "\e[?25h"
518
+ begin
519
+ print "\e[?25h"
520
+ rescue IOError, SystemCallError
521
+ # Output unavailable — nothing we can do
522
+ end
519
523
  case previous_int_handler
520
- when Proc then previous_int_handler.call
524
+ when Proc
525
+ begin
526
+ previous_int_handler.call
527
+ rescue
528
+ exit(130)
529
+ end
521
530
  when "DEFAULT", "SYSTEM_DEFAULT" then exit(130)
522
531
  else exit(130)
523
532
  end
524
533
  end
525
534
 
535
+ # Handle SIGTERM similarly to INT — restore cursor on graceful kill
536
+ trap("TERM") do
537
+ begin
538
+ print "\e[?25h"
539
+ rescue IOError, SystemCallError
540
+ # Output unavailable
541
+ end
542
+ exit(143)
543
+ end
544
+
526
545
  # Set up SIGWINCH handler for terminal resize
527
546
  Clack::Core::Prompt.setup_signal_handler
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Whittaker