rspec-osc7501 0.1.2 → 0.1.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: 5768212549d6cfe8f1db7e61e6e9ccb8b930c51536f00c3dd25c1aa7788d11fc
4
- data.tar.gz: a93974d3e6cc872aca1845d9590e1945773d29020c3774277ba5023175c1951f
3
+ metadata.gz: 79ad566e60d534a4c2ed14bbdf177c356948b8c55424d8be4463121b7bd6c82f
4
+ data.tar.gz: 588d8086263c7e701cb3328117f76aa07fdaa3a3d81504b18d9e1ae81fac39bc
5
5
  SHA512:
6
- metadata.gz: 8193fb2359fc8227db3646ebe4d3b8e20810bf3ba3f8adf379fb2dd634a6ecea6729ed7dbc49c7e4772a377175760a61169a1718516c603f3f83c87da6dc8393
7
- data.tar.gz: f484ce546596745aff7671d4dd474405197fbc36d0bfaaefe0fa09f30f8bcfff989c7216881b91c89f6c0f564f7c3e053a74bf82713c73882ec2c00ef9737605
6
+ metadata.gz: 88adf7e04930b2659e90dd1a46dbb81234372ee4b1b1afc4bad96053e5e7cf0a322de239b6af34a9294472c4ff536733fe4ffa3c7d2d7e0e51d323ca022ce3d3
7
+ data.tar.gz: 5d98d13922f3f2a755bffc6a9bf0fb028e4877e33c8b7693ba0b92f2f703efe8207059dc2bbe1726efcd0d5efa4b8c1e8443a73c5e768bb0dd57c652087d58bd
data/ACCESSIBILITY.md CHANGED
@@ -20,7 +20,7 @@ with `TERM=dumb`. `RSPEC_OSC7501=force` overrides those defaults.
20
20
 
21
21
  ## Environments and limits
22
22
 
23
- The gem supports MRI Ruby 3.3 or newer and RSpec Core 3.12 through 3.x.
23
+ The gem requires MRI Ruby 2.1 or newer and RSpec Core 3.6 or newer.
24
24
  Terminal status requires an OSC 7501-capable terminal. The formatter checks
25
25
  for a TTY and honors `TERM=dumb` but does not detect OSC support.
26
26
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.4 - 2026-11-11
6
+
7
+ - Allow newer RSpec versions and test RSpec 4 ([a3f8f5d](https://github.com/cosgroveb/rspec-osc7501/commit/a3f8f5decaf8d27328dd9dcc14536b8b8f4a35cb))
8
+ - Configure local Ruby and OSC spec reporting ([495f6be](https://github.com/cosgroveb/rspec-osc7501/commit/495f6be57799835da5ceddddd23e44a1cee4ca9d))
9
+ - Add managed RSpec child reporting \(\#13\) ([7e6d4c1](https://github.com/cosgroveb/rspec-osc7501/commit/7e6d4c15d8e210da0ff9cf90ecf05248d1863b5e))
10
+
11
+ ## 0.1.3 - 2026-11-10
12
+
13
+ - Support Ruby 2.1 and RSpec 3.6 ([5afb73d](https://github.com/cosgroveb/rspec-osc7501/commit/5afb73d1ededebcafbcb81096e6bb024f791a46c))
14
+ - Require concise PR descriptions ([feea21a](https://github.com/cosgroveb/rspec-osc7501/commit/feea21a985b7c59e1e5a1ee34b546ba58f049c69))
15
+
5
16
  ## 0.1.2 - 2026-11-09
6
17
 
7
18
  - Bump actions/checkout from 4.4.0 to 7.0.1 ([c19db3a](https://github.com/cosgroveb/rspec-osc7501/commit/c19db3a1a8c5bb41ab4db2eb0bc8740ce0a66bd0))
data/CONTRIBUTING.md CHANGED
@@ -9,7 +9,7 @@ and reports. State what you tested and what remains uncertain. Be prepared to
9
9
  explain your choices and address feedback. When using an agent to help answer
10
10
  a reviewer, check the answer and send only what is relevant.
11
11
 
12
- Use MRI Ruby 3.3 or newer. Install actionlint 1.7.12 on your PATH, then run all checks:
12
+ Use MRI Ruby 3.3 or newer for development tooling. Install actionlint 1.7.12 on your PATH, then run all checks:
13
13
 
14
14
  ```sh
15
15
  bundle install
@@ -18,8 +18,8 @@ bundle exec rake
18
18
 
19
19
  The default task runs RuboCop with rubocop-rspec, bundler-audit, actionlint,
20
20
  specs, installed-gem smoke tests and RDoc. Run `bundle exec rake lint`, `audit`, `workflows`,
21
- or `spec` for individual checks. Keep RuboCop's default rules and fix violations
22
- without adding exclusions or a TODO baseline. Dependency auditing checks the
21
+ or `spec` for individual checks. Keep RuboCop's default rules, except the scoped Ruby 2.1 compatibility
22
+ exclusions in `.rubocop.yml`. Do not add a TODO baseline. Dependency auditing checks the
23
23
  lockfile generated by `bundle install`. Keep that lockfile out of commits.
24
24
 
25
25
  Specs run in random order and report their seed. Reproduce an ordering failure
@@ -28,8 +28,8 @@ with `bundle exec rspec --seed <seed>` and narrow it with
28
28
  defined order because their interrupt and fail-fast cases depend on sequence.
29
29
 
30
30
  Keep runtime dependencies limited to `rspec-core`. Cover formatter behavior with
31
- specs and lifecycle changes with real RSpec subprocesses. Check RSpec 3.12 and
32
- 3.13 when changing early-stop detection.
31
+ specs and lifecycle changes with real RSpec subprocesses. Check RSpec 3.6 through
32
+ 3.13 and the RSpec 4 preview when changing early-stop detection.
33
33
 
34
34
  Build the gem and documentation:
35
35
 
@@ -44,6 +44,36 @@ rendered documentation. Keep generated files out of commits.
44
44
  The smoke task builds and installs the gem in a temporary directory, then checks
45
45
  passing and failing suites without loading the checkout's library.
46
46
 
47
+ ## Runtime compatibility
48
+
49
+ The gem requires MRI Ruby 2.1 or newer and RSpec Core 3.6 or newer.
50
+ Use `Gemfile.compat` to test the formatter without modern lint, release or RDoc
51
+ dependencies. On Ruby 2.1, install Bundler 1.17.3 first. Set the RSpec version
52
+ before resolving dependencies:
53
+
54
+ ```sh
55
+ export BUNDLE_GEMFILE=Gemfile.compat
56
+ export RSPEC_MINOR=3.6
57
+ export RSPEC_CORE_VERSION=3.6.0
58
+ bundle install
59
+ bundle exec rspec spec/rspec
60
+ bundle exec gem build rspec-osc7501.gemspec
61
+ bundle exec ruby script/smoke.rb rspec-osc7501-*.gem
62
+ ```
63
+
64
+ Remove `Gemfile.compat.lock` before changing RSpec versions. Keep it out of commits.
65
+ The compatibility bundle pins diff-lcs 1.3 so test dependencies install on Ruby 2.1.
66
+ CI checks the oldest Ruby against both RSpec endpoints, the oldest RSpec on modern
67
+ Ruby, and the Debian Bullseye and Bookworm version families. These jobs run the
68
+ formatter suite and installed-gem smoke checks. Modern jobs also test release
69
+ automation, lint and documentation.
70
+ CI also checks RSpec 4.0.0.beta1 on Ruby 4.0.
71
+
72
+ Compatibility checks use available patch releases within each Ruby series.
73
+ Supporting an older runtime does not extend its upstream security maintenance.
74
+ Unset `BUNDLE_GEMFILE`, `RSPEC_MINOR`, `RSPEC_CORE_VERSION` and `RSPEC_VERSION`
75
+ before returning to the modern development bundle.
76
+
47
77
  Update usage or behavior documentation for user-visible changes. Write commit
48
78
  subjects that describe the change, because release notes use those subjects.
49
79
  Do not maintain `Unreleased` entries by hand. Preserve the Apache-2.0 license text.
data/README.md CHANGED
@@ -4,7 +4,7 @@ Report RSpec suite activity, progress and results to terminals that support
4
4
  [OSC 7501](https://www.superlogical.com/rex/docs/build/program-status).
5
5
  Use the formatter alongside RSpec's progress or documentation formatter.
6
6
 
7
- Requires MRI Ruby 3.3 or newer and `rspec-core >= 3.12, < 4`.
7
+ Requires MRI Ruby 2.1 or newer and `rspec-core >= 3.6`.
8
8
 
9
9
  ## Install
10
10
 
data/doc/behavior.rdoc CHANGED
@@ -22,8 +22,25 @@ Settings apply when RSpec constructs the formatter.
22
22
 
23
23
  Other mode values raise ArgumentError. A supporting terminal determines how to
24
24
  display status. The formatter sends no capability query and reads no stdin.
25
- Use one reporting RSpec process per terminal. Concurrent processes replace the
26
- same root status record, without worker aggregation.
25
+ Without a child ID, concurrent processes replace the same root status record.
26
+ Managed invocations use separate named records without worker aggregation.
27
+
28
+ == Managed child context
29
+
30
+ <tt>RSPEC_OSC7501_ID</tt> selects a named record. Omit it for standalone root
31
+ behavior. IDs contain one to eight slash-separated ASCII segments using
32
+ <tt>A-Z a-z 0-9 _ . + -</tt>. Each segment allows 1 to 32 bytes and the whole ID
33
+ allows at most 128 bytes. An empty or invalid ID silences OSC output rather than
34
+ writing to the root record. It leaves ordinary output and exit status unchanged.
35
+
36
+ The optional <tt>rspec/osc7501/managed</tt> preload selects OSC only with valid
37
+ context and without <tt>RSPEC_OSC7501=off</tt>. It waits for RSpec's configured
38
+ formatters, preserves its default formatter, and adds OSC only when none exists.
39
+ An existing OSC selection keeps its output stream. The preload isolates RSpec's
40
+ private formatter-loader seam to the configured instance.
41
+
42
+ Managed child records remain after completion. Parent tools report their own
43
+ outcomes. A successful suite summary does not establish later process success.
27
44
 
28
45
  == Progress and outcomes
29
46
 
@@ -70,7 +87,7 @@ exit hook.
70
87
 
71
88
  == Wire format
72
89
 
73
- Each frame addresses the root record, repeats <tt>app=rspec</tt>, title, and
90
+ Each frame addresses the root record unless a valid child ID is supplied, repeats <tt>app=rspec</tt>, title, and
74
91
  message, and ends with ST (ESC followed by a backslash). The formatter writes each
75
92
  frame in one call and sends no clear-on-close record.
76
93
 
@@ -90,5 +107,8 @@ instance. Other exceptions propagate.
90
107
 
91
108
  == Compatibility
92
109
 
93
- The gem requires Ruby >= 3.3 and <tt>rspec-core</tt> >= 3.12, < 4. MRI is the
94
- supported Ruby engine. Other engines and RSpec 4 are unverified.
110
+ The gem requires Ruby >= 2.1 and <tt>rspec-core</tt> >= 3.6. MRI is the
111
+ supported Ruby engine. CI also checks RSpec 4.0.0.beta1 on Ruby 4.0.
112
+ Other engines are unverified. Runtime
113
+ compatibility does not extend upstream security maintenance for older Ruby versions.
114
+ Development tools use modern Ruby, as described in CONTRIBUTING.md.
data/doc/usage.rdoc CHANGED
@@ -52,3 +52,19 @@ is <tt>RSpec</tt>.
52
52
 
53
53
  Set <tt>RSPEC_OSC7501=off</tt> to disable frames without changing the formatter
54
54
  configuration. See {Behavior}[rdoc-ref:doc/behavior.rdoc] for settings and limits.
55
+
56
+ == Run through Rake (optional)
57
+
58
+ Install <tt>rake-osc7501</tt> alongside this gem and load the RSpec task class
59
+ before the integration in your Rakefile:
60
+
61
+ require 'rspec/core/rake_task'
62
+ require 'rake/osc7501'
63
+ RSpec::Core::RakeTask.new(:spec)
64
+
65
+ Run <tt>bundle exec rake spec</tt>. Rake assigns a child record and preloads
66
+ <tt>rspec/osc7501/managed</tt>. Existing formatter choices and their destinations
67
+ remain intact. Without an explicit formatter, ordinary progress remains visible.
68
+ Use <tt>RAKE_OSC7501=off</tt> to disable the parent's automatic activation or
69
+ <tt>RSPEC_OSC7501=off</tt> to silence the child. Child results remain after Rake
70
+ finishes, including a failed child tolerated with <tt>fail_on_error = false</tt>.
@@ -16,7 +16,7 @@ module RSpec
16
16
  # The optional +clock+ callable returns monotonic seconds for throttling.
17
17
  def initialize(output, clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) })
18
18
  @writer = Writer.new(output, mode: ENV.fetch('RSPEC_OSC7501', 'auto'),
19
- title: ENV.fetch('RSPEC_OSC7501_TITLE', 'RSpec'))
19
+ title: ENV.fetch('RSPEC_OSC7501_TITLE', 'RSpec'), id: ENV['RSPEC_OSC7501_ID'])
20
20
  @clock = clock
21
21
  @started = false
22
22
  @summarized = false
@@ -89,8 +89,8 @@ module RSpec
89
89
  return if now - @last_update < 0.1
90
90
 
91
91
  message = "#{@completed}/#{@total} examples"
92
- message += ", #{@failed} failures" if @failed.positive?
93
- message += ", #{@pending} pending" if @pending.positive?
92
+ message += ", #{@failed} failures" if @failed > 0
93
+ message += ", #{@pending} pending" if @pending > 0
94
94
  message += ": #{@current}" if @current
95
95
  @writer.emit(state: 'working', msg: message, progress: progress)
96
96
  @last_update = now
@@ -99,20 +99,20 @@ module RSpec
99
99
  def progress
100
100
  return if @total.zero?
101
101
 
102
- ((@completed * 100) / @total).clamp(0, 100)
102
+ [[(@completed * 100) / @total, 0].max, 100].min
103
103
  end
104
104
 
105
105
  def final_state(summary, active_exception)
106
106
  return 'idle' if active_exception.is_a?(Interrupt)
107
107
  return exit_state(summary, active_exception) if active_exception.is_a?(SystemExit)
108
- return 'error' if active_exception || summary.errors_outside_of_examples_count.positive?
108
+ return 'error' if active_exception || summary.errors_outside_of_examples_count > 0
109
109
  return stopped_state(summary) if early_stop?
110
110
 
111
111
  unsuccessful_summary?(summary) ? 'error' : 'done'
112
112
  end
113
113
 
114
114
  def exit_state(summary, exception)
115
- failed = summary.failure_count.positive? || summary.errors_outside_of_examples_count.positive?
115
+ failed = summary.failure_count > 0 || summary.errors_outside_of_examples_count > 0
116
116
  exception.status.zero? && !failed ? 'idle' : 'error'
117
117
  end
118
118
 
@@ -121,10 +121,10 @@ module RSpec
121
121
  end
122
122
 
123
123
  def unsuccessful_summary?(summary)
124
- summary.failure_count.positive? || (summary.example_count.zero? && RSpec.configuration.fail_if_no_examples)
124
+ summary.failure_count > 0 || (summary.example_count.zero? && RSpec.configuration.fail_if_no_examples)
125
125
  end
126
126
 
127
- # RSpec has no public early-stop event in 3.12 or 3.13.
127
+ # RSpec has no public early-stop event in supported 3.x versions.
128
128
  def early_stop?
129
129
  RSpec.world.wants_to_quit
130
130
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../osc7501'
4
+
5
+ module RSpec
6
+ module OSC7501
7
+ # Selects an additive formatter only for a managed child invocation.
8
+ module Managed
9
+ # Isolate RSpec's private formatter-loader seam to this configuration.
10
+ module Loader # :nodoc: all
11
+ def setup_default(output_stream, deprecation_stream)
12
+ super
13
+ add Formatter, output_stream unless formatters.any? { |formatter| formatter.is_a?(Formatter) }
14
+ end
15
+ end
16
+
17
+ def self.install!(configuration = RSpec.configuration)
18
+ return false unless Writer.valid_id?(ENV['RSPEC_OSC7501_ID'])
19
+ return false if ENV['RSPEC_OSC7501'] == 'off'
20
+
21
+ loader = configuration.send(:formatter_loader)
22
+ return false if loader.is_a?(Loader)
23
+
24
+ loader.singleton_class.prepend(Loader)
25
+ true
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ RSpec::OSC7501::Managed.install!
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module OSC7501
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
@@ -3,11 +3,18 @@
3
3
  module RSpec
4
4
  module OSC7501
5
5
  class Writer # :nodoc: all
6
- def initialize(output, mode:, title:)
6
+ def self.valid_id?(id)
7
+ id.is_a?(String) && id.ascii_only? && id.bytesize <= 128 &&
8
+ !!(id =~ %r{\A[A-Za-z0-9_.+-]{1,32}(?:/[A-Za-z0-9_.+-]{1,32}){0,7}\z})
9
+ end
10
+
11
+ def initialize(output, mode:, title:, id: nil)
7
12
  raise ArgumentError, 'RSPEC_OSC7501 must be auto, off, or force' unless %w[auto off force].include?(mode)
8
13
 
9
14
  @output = output
10
- @enabled = mode == 'force' || (mode == 'auto' && automatic_output?)
15
+ @id = id
16
+ @enabled = (id.nil? || self.class.valid_id?(id)) &&
17
+ output_enabled?(mode)
11
18
  @title = encode(title, 192) if @enabled
12
19
  rescue IOError, SystemCallError
13
20
  @enabled = false
@@ -17,7 +24,8 @@ module RSpec
17
24
  return unless @enabled
18
25
 
19
26
  fields = ['app=rspec', "title=#{@title}", "state=#{state}", "msg=#{encode(msg, 2048)}"]
20
- fields << "progress=#{progress.to_i.clamp(0, 100)}" if state == 'working' && !progress.nil?
27
+ fields << "id=#{@id}" if @id
28
+ fields << "progress=#{[[progress.to_i, 0].max, 100].min}" if state == 'working' && !progress.nil?
21
29
  @output.write("\e]7501;#{fields.join(':')}\e\\")
22
30
  @output.flush if @output.respond_to?(:flush)
23
31
  rescue IOError, SystemCallError
@@ -26,6 +34,10 @@ module RSpec
26
34
 
27
35
  private
28
36
 
37
+ def output_enabled?(mode)
38
+ mode == 'force' || (mode == 'auto' && automatic_output?)
39
+ end
40
+
29
41
  def automatic_output?
30
42
  ENV['TERM'] != 'dumb' && @output.respond_to?(:tty?) && @output.tty?
31
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-osc7501
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cosgrove
@@ -15,20 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '3.12'
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '4'
18
+ version: '3.6'
22
19
  type: :runtime
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
25
22
  requirements:
26
23
  - - ">="
27
24
  - !ruby/object:Gem::Version
28
- version: '3.12'
29
- - - "<"
30
- - !ruby/object:Gem::Version
31
- version: '4'
25
+ version: '3.6'
32
26
  description: Reports RSpec suite progress and outcomes through OSC 7501.
33
27
  email:
34
28
  - cosgroveb@users.noreply.github.com
@@ -47,6 +41,7 @@ files:
47
41
  - doc/usage.rdoc
48
42
  - lib/rspec/osc7501.rb
49
43
  - lib/rspec/osc7501/formatter.rb
44
+ - lib/rspec/osc7501/managed.rb
50
45
  - lib/rspec/osc7501/version.rb
51
46
  - lib/rspec/osc7501/writer.rb
52
47
  homepage: https://github.com/cosgroveb/rspec-osc7501
@@ -63,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
58
  requirements:
64
59
  - - ">="
65
60
  - !ruby/object:Gem::Version
66
- version: '3.3'
61
+ version: '2.1'
67
62
  required_rubygems_version: !ruby/object:Gem::Requirement
68
63
  requirements:
69
64
  - - ">="