rspec-osc7501 0.1.1 → 0.1.3

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: c98998ec22422da0c3b18c0e1718b0f3fb8eb572d8e11c14f02848c1761d4a08
4
- data.tar.gz: ec72f528a52941deacc832e7e1036b079aa4ffce792092af0840d01d9e01e154
3
+ metadata.gz: dd41d289a0bf23e97697865b61a02cbab47a71deac877207f2299897f952277a
4
+ data.tar.gz: 23f1e885b80df344e008650a4f7d65d65fd64c596167245fa6ca6c2ad5dd7012
5
5
  SHA512:
6
- metadata.gz: 2de8d63a1811c22b49e379ff10ad2e270ee45f9d6b71567a80c1a4f3a194558f3eda12e85cba8993df4e37068067647a48d41b77bbffacb41758474cc8ded60b
7
- data.tar.gz: 9ddaf26a6534c8a8f38d65b9bc4af8f507ed67ecf81ab9fe30a2e8ee56518d231c53a3b71562637cf8a7e5e2f9b2e7b7082158a037f89ef3d379b235e5f1fd5c
6
+ metadata.gz: f65c332e6b8124872674ee477733e7243b777f4a80b642ecac99bbed183e15a9a8a15a8a8a40f1c7652cc1ec7f1bf7acc61871a4af8e85d2bbcc82b82c4a1771
7
+ data.tar.gz: ff9ca548aa836cdf585d1ef2d931b8a3e980f90b6b951f9bef4d57286fef76ad887aad2bf7f30d59976637b5d42e3465cd61ba9ce8a768b53036678849549c64
data/ACCESSIBILITY.md ADDED
@@ -0,0 +1,36 @@
1
+ # Accessibility
2
+
3
+ Read test results without relying on terminal status indicators. Use
4
+ rspec-osc7501 alongside an RSpec text formatter so failures and
5
+ the suite summary remain available as text.
6
+
7
+ ## Plain text output
8
+
9
+ Run this for example descriptions and results without color or terminal status:
10
+
11
+ ```sh
12
+ RSPEC_OSC7501=off bundle exec rspec --format documentation --no-color
13
+ ```
14
+
15
+ `--no-color` disables RSpec's text colors. `RSPEC_OSC7501=off` disables this
16
+ gem's status records, even when your RSpec configuration selects the formatter.
17
+
18
+ By default, the formatter sends no status records to pipes, files, or terminals
19
+ with `TERM=dumb`. `RSPEC_OSC7501=force` overrides those defaults.
20
+
21
+ ## Environments and limits
22
+
23
+ The gem supports MRI Ruby 3.3 or newer and RSpec Core 3.12 through 3.x.
24
+ Terminal status requires an OSC 7501-capable terminal. The formatter checks
25
+ for a TTY and honors `TERM=dumb` but does not detect OSC support.
26
+
27
+ Your terminal controls how it displays or announces status. I have not tested
28
+ the status display with screen readers. The command above gives you plain text,
29
+ but your screen reader may need other settings.
30
+
31
+ ## Report a barrier
32
+
33
+ Open an [issue](https://github.com/cosgroveb/rspec-osc7501/issues) describing what
34
+ you tried, what prevented you from using it, and what would help. Include your
35
+ terminal, operating system, and assistive technology versions when relevant.
36
+ You do not need to disclose a disability or other medical information.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.3 - 2026-11-10
6
+
7
+ - Support Ruby 2.1 and RSpec 3.6 ([5afb73d](https://github.com/cosgroveb/rspec-osc7501/commit/5afb73d1ededebcafbcb81096e6bb024f791a46c))
8
+ - Require concise PR descriptions ([feea21a](https://github.com/cosgroveb/rspec-osc7501/commit/feea21a985b7c59e1e5a1ee34b546ba58f049c69))
9
+
10
+ ## 0.1.2 - 2026-11-09
11
+
12
+ - Bump actions/checkout from 4.4.0 to 7.0.1 ([c19db3a](https://github.com/cosgroveb/rspec-osc7501/commit/c19db3a1a8c5bb41ab4db2eb0bc8740ce0a66bd0))
13
+ - Enforce Ruby and workflow quality checks ([c0e9320](https://github.com/cosgroveb/rspec-osc7501/commit/c0e9320b9fc75dd03929fd5c2d5f2726b8ad22b3))
14
+ - Exercise sanitizer boundaries and installed gems ([b45d454](https://github.com/cosgroveb/rspec-osc7501/commit/b45d454be50ab1ad50bef32c3079b56a4f6dfcd6))
15
+ - Allow releases through protected main ([89c96ea](https://github.com/cosgroveb/rspec-osc7501/commit/89c96ea8632d68e6f4d3606cd89bff502dab0d11))
16
+ - Randomize specs and await release visibility ([09bf9ca](https://github.com/cosgroveb/rspec-osc7501/commit/09bf9ca29d03f9e40fa853952b804e1353384ea1))
17
+ - Simplify release polling and its tests ([db1c2a9](https://github.com/cosgroveb/rspec-osc7501/commit/db1c2a9eb2210890c628c6bf5a0e069f12cabdea))
18
+ - Add community policies and contribution templates ([950295c](https://github.com/cosgroveb/rspec-osc7501/commit/950295cf24395f8883d43c9b30f977f579116da1))
19
+ - Clarify responsibility for AI-assisted work ([7d7f1b9](https://github.com/cosgroveb/rspec-osc7501/commit/7d7f1b93df6e13f70e764ce80041e802431fc739))
20
+ - Clarify accessibility controls and limits ([e5f34c1](https://github.com/cosgroveb/rspec-osc7501/commit/e5f34c10a7f326dbc972c170b477a0265ec7cea2))
21
+ - Clarify docs and merge preferences ([81256da](https://github.com/cosgroveb/rspec-osc7501/commit/81256daa9297c3bb29037c1d8ca01ed0f2d42f13))
22
+ - Honor dumb terminals in automatic status mode ([f45a078](https://github.com/cosgroveb/rspec-osc7501/commit/f45a078583a00756089fee59caebae1531c9f305))
23
+ - Clarify release and formatter documentation ([3d13c4b](https://github.com/cosgroveb/rspec-osc7501/commit/3d13c4ba8fe90aa5bf358b906f8108d5d3a93914))
24
+
5
25
  ## 0.1.1 - 2026-11-08
6
26
 
7
27
  - Fix formatter outcomes and stream handling ([3454f8a](https://github.com/cosgroveb/rspec-osc7501/commit/3454f8a63e05e8955ac42038d494d90cfaec9429))
@@ -0,0 +1,68 @@
1
+ # Code of conduct
2
+
3
+ Everyone who participates in good faith is welcome in rspec-osc7501. Treat
4
+ people with respect, regardless of race, ethnicity, caste, color, age, physical
5
+ characteristics, neurodiversity, disability, sex, gender identity or expression,
6
+ sexual orientation, language, philosophy, religion, national or social origin,
7
+ income, education, or other status.
8
+
9
+ ## Working together
10
+
11
+ Respect the project's purpose and other people's time. Discuss ideas without
12
+ attacking people. Make room for different viewpoints and experiences. Give and
13
+ accept constructive feedback. Account for differences in language, culture,
14
+ and communication when interpreting what someone says.
15
+
16
+ Take responsibility for what you submit, including code, reports, and comments
17
+ produced with AI assistance. Review it before sharing, make sure you understand
18
+ it, and respond to questions and corrections. Respect the time others spend
19
+ reviewing your work. Take responsibility for repairing harm you cause.
20
+
21
+ Do not:
22
+
23
+ - Harass people, ignore a request to stop, or violate stated boundaries.
24
+ - Make personal attacks, discriminate, or stereotype people by identity.
25
+ - Make unwanted sexual comments or advances.
26
+ - Share or use someone's private information without permission.
27
+ - Threaten, encourage, or cause violence or other harm.
28
+ - Impersonate someone or evade moderation with another identity.
29
+ - Contribute someone else's work without credit.
30
+ - Post unrelated advertising or present harmful content without appropriate
31
+ context and care.
32
+
33
+ Threatening or encouraging these behaviors also violates this policy. Other
34
+ behavior that threatens the community's well-being may warrant moderation.
35
+ Disagreement alone is not a conduct violation.
36
+
37
+ ## Reporting and enforcement
38
+
39
+ Report concerns privately to Brian Cosgrove at
40
+ [cosgroveb@gmail.com](mailto:cosgroveb@gmail.com). Include what happened and any
41
+ relevant links or messages. Do not post private reports in public issues.
42
+
43
+ I review and investigate reports, hear from the people involved as needed, and
44
+ prioritize safety and confidentiality. I share report details only as needed
45
+ to investigate and respond. I handle enforcement privately and discuss any
46
+ public resolution with the people involved. I respond as availability permits,
47
+ without a guaranteed deadline.
48
+
49
+ Depending on severity and repetition, I may issue a warning, remove content,
50
+ restrict participation, or impose a temporary or permanent ban. Serious
51
+ violations may lead to an immediate ban. Where continued participation is
52
+ appropriate, I explain what needs to change and any conditions for returning.
53
+ These rules apply to maintainers as well as other participants.
54
+
55
+ ## Scope
56
+
57
+ This policy covers project spaces and anyone officially representing the
58
+ project elsewhere, including through project accounts or at events.
59
+
60
+ ## Attribution
61
+
62
+ Adapted from [Contributor Covenant 3.0](https://www.contributor-covenant.org/version/3/0/code_of_conduct/),
63
+ stewarded by the Organization for Ethical Source. This adaptation shortens the
64
+ wording and uses a maintainer-led reporting and enforcement process.
65
+
66
+ This document is licensed under
67
+ [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).
68
+ The software remains licensed under [Apache License 2.0](LICENSE).
data/CONTRIBUTING.md CHANGED
@@ -1,25 +1,77 @@
1
1
  # Contributing
2
2
 
3
- Use MRI Ruby 3.3 or newer. Install dependencies and run specs:
3
+ Follow the [code of conduct](CODE_OF_CONDUCT.md). Report vulnerabilities through
4
+ the private channel in [SECURITY.md](SECURITY.md).
5
+
6
+ AI-assisted contributions are welcome. Before requesting review, understand
7
+ the changes, run relevant checks, and verify claims in code, documentation,
8
+ and reports. State what you tested and what remains uncertain. Be prepared to
9
+ explain your choices and address feedback. When using an agent to help answer
10
+ a reviewer, check the answer and send only what is relevant.
11
+
12
+ Use MRI Ruby 3.3 or newer for development tooling. Install actionlint 1.7.12 on your PATH, then run all checks:
4
13
 
5
14
  ```sh
6
15
  bundle install
7
- bundle exec rake spec
16
+ bundle exec rake
8
17
  ```
9
18
 
19
+ The default task runs RuboCop with rubocop-rspec, bundler-audit, actionlint,
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, except the scoped Ruby 2.1 compatibility
22
+ exclusions in `.rubocop.yml`. Do not add a TODO baseline. Dependency auditing checks the
23
+ lockfile generated by `bundle install`. Keep that lockfile out of commits.
24
+
25
+ Specs run in random order and report their seed. Reproduce an ordering failure
26
+ with `bundle exec rspec --seed <seed>` and narrow it with
27
+ `bundle exec rspec --seed <seed> --bisect`. Generated subprocess fixtures keep a
28
+ defined order because their interrupt and fail-fast cases depend on sequence.
29
+
10
30
  Keep runtime dependencies limited to `rspec-core`. Cover formatter behavior with
11
- specs and lifecycle changes with real RSpec subprocesses. Check RSpec 3.12 and
31
+ specs and lifecycle changes with real RSpec subprocesses. Check RSpec 3.6 through
12
32
  3.13 when changing early-stop detection.
13
33
 
14
34
  Build the gem and documentation:
15
35
 
16
36
  ```sh
17
37
  bundle exec rake package
38
+ bundle exec rake smoke
18
39
  bundle exec rake rdoc
19
40
  ```
20
41
 
21
42
  The package is `pkg/rspec-osc7501-<version>.gem`. Open `tmp/rdoc/index.html` to check
22
43
  rendered documentation. Keep generated files out of commits.
44
+ The smoke task builds and installs the gem in a temporary directory, then checks
45
+ passing and failing suites without loading the checkout's library.
46
+
47
+ ## Runtime compatibility
48
+
49
+ The gem supports MRI Ruby 2.1 or newer and RSpec Core 3.6 through 3.x.
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
+
71
+ Compatibility checks use available patch releases within each Ruby series.
72
+ Supporting an older runtime does not extend its upstream security maintenance.
73
+ Unset `BUNDLE_GEMFILE`, `RSPEC_MINOR` and `RSPEC_CORE_VERSION` before returning to
74
+ the modern development bundle.
23
75
 
24
76
  Update usage or behavior documentation for user-visible changes. Write commit
25
77
  subjects that describe the change, because release notes use those subjects.
@@ -27,10 +79,11 @@ Do not maintain `Unreleased` entries by hand. Preserve the Apache-2.0 license te
27
79
 
28
80
  ## Release
29
81
 
30
- Release the reviewed commits on remote `main` with an explicit stable version:
82
+ Release the reviewed commits on remote `main`. Replace `NEW_VERSION` with a
83
+ stable version greater than the current release:
31
84
 
32
85
  ```sh
33
- gh workflow run release.yml --ref main -f version=0.1.1
86
+ gh workflow run release.yml --ref main -f version=NEW_VERSION
34
87
  ```
35
88
 
36
89
  The workflow captures `main`, updates `VERSION`, and generates CHANGELOG bullets
@@ -44,6 +97,10 @@ it and its tag together. If `main` advances during testing, the workflow stops.
44
97
  After the push, it publishes to RubyGems, then creates the GitHub Release. No
45
98
  intermediate approval is required.
46
99
 
100
+ If a release fails, inspect its logs and rerun the same version. If its tag
101
+ already exists, the workflow tests and resumes that tagged release instead of
102
+ releasing newer commits on `main`.
103
+
47
104
  ### One-time publishing setup
48
105
 
49
106
  On the gem's RubyGems page, configure a Trusted Publisher with owner `cosgroveb`,
@@ -52,24 +109,10 @@ blank. The workflow uses short-lived OIDC credentials, with no RubyGems token
52
109
  stored in GitHub secrets. Repository Actions permissions must permit the
53
110
  workflow's `contents: write` and `id-token: write` requests.
54
111
 
55
- ### Failed releases
56
-
57
- Inspect the run and its publication summary:
58
-
59
- ```sh
60
- gh run list --workflow release.yml
61
- gh run view <run-id> --log-failed
62
- ```
63
-
64
- RubyGems publication is the release. A later GitHub Release failure leaves the
65
- workflow failed but does not undo the published gem. Rerun the same version to
66
- finish missing steps:
67
-
68
- ```sh
69
- gh workflow run release.yml --ref main -f version=0.1.1
70
- ```
71
-
72
- When the tag exists, the workflow uses that exact commit and recorded notes,
73
- verifies matching publications, and skips completed steps. It does not move
74
- tags, replace published gems, or retry automatically. If the retry fails,
75
- inspect the logs before trying again.
112
+ Store a dedicated write-enabled repository deploy key as the Actions secret
113
+ `RELEASE_DEPLOY_KEY`. Only the publish job uses it to push the tested commit
114
+ and tag. Require PRs and CI checks in a separate ruleset with deploy-key bypass,
115
+ and keep deletion and force-push protection in a ruleset without bypasses.
116
+ GitHub applies this bypass to all repository deploy keys, so additional write
117
+ deploy keys would receive the same access. GitHub API calls still use the
118
+ workflow token, and RubyGems still uses OIDC.
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  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
- Use the formatter alongside RSpec’s progress or documentation formatter.
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, < 4`.
8
8
 
9
9
  ## Install
10
10
 
@@ -28,7 +28,7 @@ bundle exec rspec --require rspec/osc7501 \
28
28
  --format progress --format RSpec::OSC7501::Formatter
29
29
  ```
30
30
 
31
- Keep `--format progress` to retain RSpec’s dots, failures and summary. The OSC
31
+ Keep `--format progress` to see RSpec's dots, failures and summary. The OSC
32
32
  formatter reports completed examples and the final suite result through terminal
33
33
  status records. Requiring `rspec/osc7501` registers the formatter without selecting
34
34
  it.
@@ -48,8 +48,8 @@ with a `state=done` or `state=error` record.
48
48
 
49
49
  | Environment variable | Values | Default |
50
50
  | --- | --- | --- |
51
- | `RSPEC_OSC7501` | `auto` emits to a TTY, `off` disables output, `force` permits redirected output | `auto` |
52
- | `RSPEC_OSC7501_TITLE` | Title for the suite’s status records | `RSpec` |
51
+ | `RSPEC_OSC7501` | `auto` emits to a TTY unless `TERM=dumb`, `off` disables output, `force` overrides both checks | `auto` |
52
+ | `RSPEC_OSC7501_TITLE` | Title for the suite's status records | `RSpec` |
53
53
 
54
54
  The formatter uses the output stream RSpec assigns, including `--out`. Default
55
55
  mode emits nothing to redirected streams. Use one reporting RSpec process per
@@ -64,6 +64,9 @@ that bypasses formatter callbacks can leave the last status in place. See
64
64
  - [Usage recipes](doc/usage.rdoc): persistent configuration and output routing.
65
65
  - [Behavior and reference](doc/behavior.rdoc): progress, terminal states and limits.
66
66
  - [Contributing](CONTRIBUTING.md): development and verification commands.
67
+ - [Accessibility](ACCESSIBILITY.md): text output and reporting barriers.
68
+ - [Security policy](SECURITY.md): supported releases and private reporting.
69
+ - [Code of conduct](CODE_OF_CONDUCT.md): participation and conduct reports.
67
70
  - [Changelog](CHANGELOG.md).
68
71
 
69
72
  Licensed under [Apache License 2.0](LICENSE).
data/SECURITY.md ADDED
@@ -0,0 +1,22 @@
1
+ # Security policy
2
+
3
+ ## Supported versions
4
+
5
+ I provide security fixes for the latest released version of rspec-osc7501.
6
+ Upgrade to the latest release before checking whether a problem still occurs.
7
+ Older releases do not receive security backports.
8
+
9
+ ## Report a vulnerability
10
+
11
+ Use [GitHub private vulnerability reporting](https://github.com/cosgroveb/rspec-osc7501/security/advisories/new).
12
+ Do not disclose vulnerabilities in public issues or pull requests.
13
+
14
+ Include the affected gem, Ruby, and RSpec versions, steps or a small example
15
+ that reproduces the problem, and the impact. Include terminal and tmux versions
16
+ when relevant. Remove credentials and unrelated private data from examples.
17
+
18
+ I review reports and coordinate a fix and public disclosure with the reporter.
19
+ Please keep details private while we work out disclosure. I cannot guarantee
20
+ response or fix deadlines.
21
+
22
+ For ordinary bugs, use the [issue tracker](https://github.com/cosgroveb/rspec-osc7501/issues).
data/doc/behavior.rdoc CHANGED
@@ -11,12 +11,12 @@ that stream open and flushes each frame when the stream supports flushing.
11
11
  Settings apply when RSpec constructs the formatter.
12
12
 
13
13
  [<tt>RSPEC_OSC7501=auto</tt>]
14
- Emit to a TTY. Streams without <tt>tty?</tt> remain silent.
14
+ Emit to a TTY unless <tt>TERM=dumb</tt>. Streams without <tt>tty?</tt> remain silent.
15
15
  This is the default, including an unset variable.
16
16
  [<tt>RSPEC_OSC7501=off</tt>]
17
17
  Emit no frames.
18
18
  [<tt>RSPEC_OSC7501=force</tt>]
19
- Emit to the selected stream even if it is not a TTY.
19
+ Emit to the selected stream even if it is not a TTY or <tt>TERM=dumb</tt>.
20
20
  [<tt>RSPEC_OSC7501_TITLE</tt>]
21
21
  Set a stable suite title. Default: <tt>RSpec</tt>.
22
22
 
@@ -32,8 +32,8 @@ description and completed, failed, and pending counts. Progress divides complete
32
32
  results by the initial example count and stays within 0 to 100. Pending examples
33
33
  count as completed. Zero-example runs omit progress.
34
34
 
35
- Intermediate updates occur at most once per 100 ms. Initial and final updates
36
- bypass throttling. A dry run identifies itself in its messages.
35
+ The formatter sends intermediate updates at most once per 100 ms and initial
36
+ and final updates without throttling. A dry run identifies itself in its messages.
37
37
 
38
38
  The final frame includes RSpec's summary counts and duration, with no progress:
39
39
 
@@ -44,8 +44,9 @@ The final frame includes RSpec's summary counts and duration, with no progress:
44
44
  exception ended the run. An empty suite with <tt>fail_if_no_examples</tt> also
45
45
  reports error.
46
46
  [<tt>idle</tt>]
47
- Interrupt, a successful early SystemExit, or an otherwise unexplained early-stop
48
- request ended the run.
47
+ An active Interrupt reports idle even with recorded failures. A zero-status
48
+ SystemExit reports idle only without failures or outside-example errors.
49
+ An otherwise unexplained early-stop request also reports idle.
49
50
 
50
51
  The formatter reads RSpec's private early-stop flag at summary time. A reached
51
52
  fail-fast threshold or outside-example error takes precedence over that flag.
@@ -89,5 +90,7 @@ instance. Other exceptions propagate.
89
90
 
90
91
  == Compatibility
91
92
 
92
- The gem requires Ruby >= 3.3 and <tt>rspec-core</tt> >= 3.12, < 4. MRI is the
93
- supported Ruby engine. Other engines and RSpec 4 are unverified.
93
+ The gem requires Ruby >= 2.1 and <tt>rspec-core</tt> >= 3.6, < 4. MRI is the
94
+ supported Ruby engine. Other engines and RSpec 4 are unverified. Runtime
95
+ compatibility does not extend upstream security maintenance for older Ruby versions.
96
+ Development tools use modern Ruby, as described in CONTRIBUTING.md.
data/doc/usage.rdoc CHANGED
@@ -12,8 +12,8 @@ Add these options to your project's <tt>.rspec</tt>:
12
12
  --format RSpec::OSC7501::Formatter
13
13
 
14
14
  Run <tt>bundle exec rspec</tt>. RSpec prints ordinary progress and sends status
15
- frames to the formatter's TTY output. A terminal with OSC 7501 support can show
16
- the suite status.
15
+ frames to the formatter's TTY output unless <tt>TERM=dumb</tt>. A terminal with
16
+ OSC 7501 support can show the suite status.
17
17
 
18
18
  == Keep JSON separate
19
19
 
@@ -50,5 +50,5 @@ is <tt>RSpec</tt>.
50
50
 
51
51
  == Disable status
52
52
 
53
- Set <tt>RSPEC_OSC7501=off</tt> to disable frames while retaining the formatter
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.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'English'
4
+
3
5
  module RSpec
4
6
  # Reports RSpec suite status through OSC 7501 terminal records.
5
7
  module OSC7501
@@ -7,14 +9,14 @@ module RSpec
7
9
  # Select alongside an ordinary formatter to retain RSpec's text output.
8
10
  class Formatter
9
11
  RSpec::Core::Formatters.register self, :start, :example_started, :example_passed,
10
- :example_failed, :example_pending, :dump_summary, :close
12
+ :example_failed, :example_pending, :dump_summary, :close
11
13
 
12
14
  # Writes status to RSpec's +output+ stream without closing it.
13
15
  # Reads RSPEC_OSC7501 and RSPEC_OSC7501_TITLE at construction.
14
16
  # The optional +clock+ callable returns monotonic seconds for throttling.
15
17
  def initialize(output, clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) })
16
- @writer = Writer.new(output, mode: ENV.fetch("RSPEC_OSC7501", "auto"),
17
- title: ENV.fetch("RSPEC_OSC7501_TITLE", "RSpec"))
18
+ @writer = Writer.new(output, mode: ENV.fetch('RSPEC_OSC7501', 'auto'),
19
+ title: ENV.fetch('RSPEC_OSC7501_TITLE', 'RSpec'))
18
20
  @clock = clock
19
21
  @started = false
20
22
  @summarized = false
@@ -22,15 +24,15 @@ module RSpec
22
24
 
23
25
  # Starts suite progress from the example count in +notification+.
24
26
  def start(notification)
25
- @inherited_exception = $!
27
+ @inherited_exception = $ERROR_INFO
26
28
  @started = true
27
29
  @total = notification.count
28
30
  @completed = @failed = @pending = 0
29
31
  @current = nil
30
32
  @last_update = @clock.call
31
33
  message = "Running #{@total} examples"
32
- message += " (dry run)" if RSpec.configuration.dry_run
33
- @writer.emit(state: "working", msg: message, progress: progress)
34
+ message += ' (dry run)' if RSpec.configuration.dry_run
35
+ @writer.emit(state: 'working', msg: message, progress: progress)
34
36
  end
35
37
 
36
38
  # Sets the current example description and attempts a throttled update.
@@ -62,13 +64,13 @@ module RSpec
62
64
  # Emits the final state, counts, and duration from RSpec's summary.
63
65
  # Final output bypasses throttling and omits progress.
64
66
  def dump_summary(notification)
65
- active_exception = $!
67
+ active_exception = $ERROR_INFO
66
68
  active_exception = nil if active_exception.equal?(@inherited_exception)
67
69
  @summarized = true
68
70
  state = final_state(notification, active_exception)
69
- outcome = { "done" => "Completed", "error" => "Failed", "idle" => "Stopped" }.fetch(state)
71
+ outcome = { 'done' => 'Completed', 'error' => 'Failed', 'idle' => 'Stopped' }.fetch(state)
70
72
  message = "#{outcome}: #{notification.totals_line} in #{notification.formatted_duration}"
71
- message += " (dry run)" if RSpec.configuration.dry_run
73
+ message += ' (dry run)' if RSpec.configuration.dry_run
72
74
  @writer.emit(state: state, msg: message)
73
75
  end
74
76
 
@@ -77,7 +79,7 @@ module RSpec
77
79
  return if @summarized || !@started || @closed
78
80
 
79
81
  @closed = true
80
- @writer.emit(state: "error", msg: "Incomplete: #{@completed}/#{@total} examples")
82
+ @writer.emit(state: 'error', msg: "Incomplete: #{@completed}/#{@total} examples")
81
83
  end
82
84
 
83
85
  private
@@ -87,38 +89,42 @@ module RSpec
87
89
  return if now - @last_update < 0.1
88
90
 
89
91
  message = "#{@completed}/#{@total} examples"
90
- message += ", #{@failed} failures" if @failed.positive?
91
- message += ", #{@pending} pending" if @pending.positive?
92
+ message += ", #{@failed} failures" if @failed > 0
93
+ message += ", #{@pending} pending" if @pending > 0
92
94
  message += ": #{@current}" if @current
93
- @writer.emit(state: "working", msg: message, progress: progress)
95
+ @writer.emit(state: 'working', msg: message, progress: progress)
94
96
  @last_update = now
95
97
  end
96
98
 
97
99
  def progress
98
100
  return if @total.zero?
99
101
 
100
- ((@completed * 100) / @total).clamp(0, 100)
102
+ [[(@completed * 100) / @total, 0].max, 100].min
101
103
  end
102
104
 
103
105
  def final_state(summary, active_exception)
104
- return "idle" if active_exception.is_a?(Interrupt)
105
- if active_exception.is_a?(SystemExit)
106
- return "error" if active_exception.status != 0 || summary.failure_count.positive? || summary.errors_outside_of_examples_count.positive?
106
+ return 'idle' if active_exception.is_a?(Interrupt)
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 > 0
109
+ return stopped_state(summary) if early_stop?
107
110
 
108
- return "idle"
109
- end
110
- return "error" if active_exception || summary.errors_outside_of_examples_count.positive?
111
- if early_stop?
112
- return "error" if fail_fast_reached?(summary.failure_count)
111
+ unsuccessful_summary?(summary) ? 'error' : 'done'
112
+ end
113
113
 
114
- return "idle"
115
- end
116
- return "error" if summary.failure_count.positive? || (summary.example_count.zero? && RSpec.configuration.fail_if_no_examples)
114
+ def exit_state(summary, exception)
115
+ failed = summary.failure_count > 0 || summary.errors_outside_of_examples_count > 0
116
+ exception.status.zero? && !failed ? 'idle' : 'error'
117
+ end
118
+
119
+ def stopped_state(summary)
120
+ fail_fast_reached?(summary.failure_count) ? 'error' : 'idle'
121
+ end
117
122
 
118
- "done"
123
+ def unsuccessful_summary?(summary)
124
+ summary.failure_count > 0 || (summary.example_count.zero? && RSpec.configuration.fail_if_no_examples)
119
125
  end
120
126
 
121
- # 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.
122
128
  def early_stop?
123
129
  RSpec.world.wants_to_quit
124
130
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module OSC7501
5
- VERSION = "0.1.1"
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
@@ -4,10 +4,10 @@ module RSpec
4
4
  module OSC7501
5
5
  class Writer # :nodoc: all
6
6
  def initialize(output, mode:, title:)
7
- raise ArgumentError, "RSPEC_OSC7501 must be auto, off, or force" unless %w[auto off force].include?(mode)
7
+ raise ArgumentError, 'RSPEC_OSC7501 must be auto, off, or force' unless %w[auto off force].include?(mode)
8
8
 
9
9
  @output = output
10
- @enabled = mode == "force" || (mode == "auto" && output.respond_to?(:tty?) && output.tty?)
10
+ @enabled = mode == 'force' || (mode == 'auto' && automatic_output?)
11
11
  @title = encode(title, 192) if @enabled
12
12
  rescue IOError, SystemCallError
13
13
  @enabled = false
@@ -16,8 +16,8 @@ module RSpec
16
16
  def emit(state:, msg:, progress: nil)
17
17
  return unless @enabled
18
18
 
19
- 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?
19
+ fields = ['app=rspec', "title=#{@title}", "state=#{state}", "msg=#{encode(msg, 2048)}"]
20
+ fields << "progress=#{[[progress.to_i, 0].max, 100].min}" if state == 'working' && !progress.nil?
21
21
  @output.write("\e]7501;#{fields.join(':')}\e\\")
22
22
  @output.flush if @output.respond_to?(:flush)
23
23
  rescue IOError, SystemCallError
@@ -26,15 +26,19 @@ module RSpec
26
26
 
27
27
  private
28
28
 
29
+ def automatic_output?
30
+ ENV['TERM'] != 'dumb' && @output.respond_to?(:tty?) && @output.tty?
31
+ end
32
+
29
33
  def encode(text, byte_limit)
30
34
  input = text.to_s.byteslice(0, sanitization_byte_limit(byte_limit))
31
- clean = input.encode("UTF-8", invalid: :replace, undef: :replace).gsub(/[\u0000-\u001F\u007F-\u009F]/, "")
35
+ clean = input.encode('UTF-8', invalid: :replace, undef: :replace).gsub(/[\u0000-\u001F\u007F-\u009F]/, '')
32
36
  bytes = 0
33
37
  bounded = clean.each_char.take_while do |char|
34
38
  bytes += char.bytesize
35
39
  bytes <= byte_limit
36
40
  end.join
37
- [bounded].pack("m0")
41
+ [bounded].pack('m0')
38
42
  end
39
43
 
40
44
  # Bound sanitization work with 50% headroom for stripped controls.
data/lib/rspec/osc7501.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rspec/core"
4
- require_relative "osc7501/version"
5
- require_relative "osc7501/writer"
6
- require_relative "osc7501/formatter"
3
+ require 'rspec/core'
4
+ require_relative 'osc7501/version'
5
+ require_relative 'osc7501/writer'
6
+ require_relative 'osc7501/formatter'
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.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cosgrove
@@ -15,7 +15,7 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '3.12'
18
+ version: '3.6'
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '4'
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '3.12'
28
+ version: '3.6'
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: '4'
@@ -36,10 +36,13 @@ executables: []
36
36
  extensions: []
37
37
  extra_rdoc_files: []
38
38
  files:
39
+ - ACCESSIBILITY.md
39
40
  - CHANGELOG.md
41
+ - CODE_OF_CONDUCT.md
40
42
  - CONTRIBUTING.md
41
43
  - LICENSE
42
44
  - README.md
45
+ - SECURITY.md
43
46
  - doc/behavior.rdoc
44
47
  - doc/usage.rdoc
45
48
  - lib/rspec/osc7501.rb
@@ -60,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
63
  requirements:
61
64
  - - ">="
62
65
  - !ruby/object:Gem::Version
63
- version: '3.3'
66
+ version: '2.1'
64
67
  required_rubygems_version: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - ">="