Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#
# Created: 15th August 2026
# Updated: 28th August 2026
# Updated: 16th November 2026
#

name: Ruby
Expand Down Expand Up @@ -58,8 +58,9 @@ jobs:
ruby-version: '2.5'
- os: ubuntu-latest
ruby-version: '2.4'
- os: ubuntu-latest
ruby-version: '2.0'
# 2.0-2.2 have no ruby-builder tarball for ubuntu-26.04
# (ubuntu-latest). The gem still claims Ruby 2.0; this cell cannot
# install it.
- os: windows-latest
ruby-version: mingw

Expand Down
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# woad.Ruby - Changes <!-- omit in toc -->


## 0.1.0-alpha1 - 16th November 2026

* added `BLINKING` and `BOLD`, byte-for-byte with **woad** **0.3.0**;
* added cached `colour_policy`, `refresh`, `supports_colour`, and `seq_for` for the portable colour contract (Unix attachment and `TERM=dumb`; no console probe);
* added **test/component/tc_colour_policy.rb** (decision rows 1-22) and **examples/conditional**;
* left Windows virtual-terminal mode and mintty PTY recognition for a later alpha;
* moved the fixed SGR sequences into **Woad::Sequences**, mixed into **Woad**;
* documented the colour environment variables and their accepted forms in **README.md**;


## 0.0.4 - 30th August 2026

* added shared **.vimrc** editor configuration;
Expand Down
1 change: 1 addition & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

|Name|Source & Description|Summary|
|---|---|---|
|**conditional**|[examples/conditional.rb](./examples/conditional.rb)<br/>[examples/conditional.md](./examples/conditional.md)|Prints a sequence only when the writer supports colour|
|**print_status**|[examples/print_status.rb](./examples/print_status.rb)<br/>[examples/print_status.md](./examples/print_status.md)|Prints sample status words with **woad** SGR colour constants|


Expand Down
16 changes: 9 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# woad.Ruby - News <!-- omit in toc -->

| Date | News Item |
| ---------------- | -------------------------------------------------------------------------------------- |
| 30th August 2026 | [**woad.Ruby** 0.0.4](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.4) |
| 28th August 2026 | [**woad.Ruby** 0.0.3](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.3) |
| 20th August 2026 | [**woad.Ruby** 0.0.2](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.2) |
| 15th August 2026 | [**woad.Ruby** 0.0.1](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.1) |
| 15th August 2026 | [**woad.Ruby** 0.0.0](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.0) |

| Date | News Item | Details |
| ------------------- | ------------------------- | -------------------------------------------------------------------- |
| 16th November 2026 | [**woad.Ruby** 0.1.0-alpha1](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.1.0-alpha1) | portable colour policy; `BOLD` and `BLINKING`; conditional `seq_for` |
| 30th August 2026 | [**woad.Ruby** 0.0.4](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.4) | shared **.vimrc**; dropped an obsolete CI branch |
| 28th August 2026 | [**woad.Ruby** 0.0.3](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.3) | Actions checkout **v7**; Ruby 2.0+ requirement |
| 20th August 2026 | [**woad.Ruby** 0.0.2](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.2) | **examples/print_status**; packaging and **README.md** |
| 15th August 2026 | [**woad.Ruby** 0.0.1](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.1) | fixed SGR colour and reset sequences |
| 15th August 2026 | [**woad.Ruby** 0.0.0](https://github.com/synesissoftware/woad.Ruby/releases/tag/0.0.0) | initial scaffolding; Ruby 2.0+ |


<!-- ########################### end of file ########################### -->
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ Minimal ANSI terminal colour codes, for Ruby
## Table of Contents <!-- omit in toc -->

- [Introduction](#introduction)
- [Developer Experience](#developer-experience)
- [Installation](#installation)
- [Components](#components)
- [Environment](#environment)
- [Examples](#examples)
- [Project Information](#project-information)
- [Where to get help](#where-to-get-help)
Expand All @@ -38,6 +40,30 @@ Minimal ANSI terminal colour codes, for Ruby
It has **no dependencies** on any other non-standard library.


## Developer Experience

**Ruby 2.0+** is already enough. There are no gems to install beyond **woad** itself.

```
gem install woad
```

The smallest useful call prints a sequence only when the writer supports colour:

```Ruby
require 'woad'

green = Woad.seq_for($stdout, Woad::FG_GREEN)
reset = Woad.seq_for($stdout, Woad::RESET)

puts "#{green}ok#{reset}"
```

That is [examples/conditional.rb](./examples/conditional.rb). Fixed sequences (`BOLD`, `BLINKING`, `FG_*`, `BG_*`) always contain the SGR bytes. `colour_policy`, `supports_colour`, and `seq_for` apply the cached environment policy. `refresh` drops that cache.

From a checkout, `bundle exec rake test` runs the unit and component suites. Installation detail is in [INSTALL.md](./INSTALL.md).


## Installation

Install via **gem** as in:
Expand All @@ -59,7 +85,25 @@ puts "#{Woad::FG_GREEN}ok#{Woad::RESET}"

## Components

**woad.Ruby** ships SGR string constants (`RESET`, `FG_*`, `BG_*`, including bright variants). TTY/stream gating and Windows virtual-terminal opt-in are not implemented yet.
**woad.Ruby** ships fixed SGR sequences (`BLINKING`, `BOLD`, `RESET`, `FG_*`, `BG_*`, including bright variants) and the portable colour policy: `colour_policy`, `refresh`, `supports_colour`, and `seq_for`. On Unix a terminal supports colour when the policy is automatic and `TERM` is not `dumb`. Windows virtual-terminal mode and mintty PTY recognition are not implemented.


## Environment

`Woad.colour_policy` returns `COLOUR_POLICY_AUTO` (0), `COLOUR_POLICY_FORCE` (1), or `COLOUR_POLICY_INHIBIT` (2). The result is cached until `Woad.refresh` is invoked.

A variable that is unset or empty is absent. Values are not trimmed. The first present variable in this order wins:

1. Non-empty `WOAD_COLOUR`, otherwise non-empty `WOAD_COLOR`. Compared case-insensitively. Truey forces: `1`, `always`, `force`, `on`, `true`, `yes`. Falsey inhibits: `0`, `false`, `never`, `no`, `none`, `off`. Anything else, including `auto`, selects auto and does not fall through;
2. Non-empty `NO_COLOR` inhibits, whatever its text is;
3. Non-empty `CLICOLOR_FORCE` other than the exact bytes `0` forces. Exact `0` does not force and does not inhibit;
4. Non-empty `FORCE_COLOR` other than exact `0` or `false` (any capitalisation) forces. Exact `0` and `false` do not force and do not inhibit;
5. `CLICOLOR` equal to the exact bytes `0` inhibits. Any other value is ignored;
6. Otherwise auto.

`TERM` equal to `dumb`, in any capitalisation, is cached beside the policy. It is not a policy value. It suppresses colour only when the policy is auto. `force` ignores the terminal and `TERM`. `inhibit` never emits colour.

On Unix, auto plus a terminal plus a `TERM` that is not `dumb` means colour. There is no console probe. `WOAD_SET_CONSOLE_MODE` is not read in this alpha.


## Examples
Expand Down Expand Up @@ -90,7 +134,7 @@ Libraries upon which **woad.Ruby** depends:

##### Runtime Dependencies (aka "Normal Dependencies")

* \<none>;
* \<none>. Windows virtual-terminal mode and mintty PTY recognition are not implemented, so this gem does not bind a console API;


##### Development Dependencies
Expand Down
5 changes: 3 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
## Functional improvements

* [x] ~~~SGR colour and reset codes~~~ ✅;
* [ ] TTY-conditional colour codes (process and per-stream);
* [ ] Windows virtual-terminal gating (OS build + `GetConsoleMode`);
* [x] ~~~portable colour policy (`colour_policy`, `refresh`, `supports_colour`, `seq_for`), including `BOLD` and `BLINKING`~~~ - ✅;
* [ ] Windows virtual-terminal gating (OS build + `GetConsoleMode` + `WOAD_SET_CONSOLE_MODE`);
* [ ] mintty / MSYS2 / Cygwin PTY recognition;


## Performance improvements
Expand Down
37 changes: 37 additions & 0 deletions examples/conditional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# woad.Ruby - Example - **conditional**


## Summary

Prints a status word with an SGR sequence only when standard output supports colour.


## Source

```ruby

#! /usr/bin/env ruby

# examples/conditional.rb

require 'woad'

green = Woad.seq_for($stdout, Woad::FG_GREEN)
reset = Woad.seq_for($stdout, Woad::RESET)

puts "#{green}ok#{reset}"
```

`seq_for` returns the sequence when the writer supports colour, and `""` when it does not. A pipe, `TERM=dumb` under the automatic policy, and an inhibit policy all print `ok` with no escape sequences.


## Usage

When run, this produces the following output (colours omitted here):

```
ok
```


<!-- ########################### end of file ########################### -->
12 changes: 12 additions & 0 deletions examples/conditional.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env ruby

# examples/conditional.rb


require 'woad'


green = Woad.seq_for($stdout, Woad::FG_GREEN)
reset = Woad.seq_for($stdout, Woad::RESET)

puts "#{green}ok#{reset}"
Empty file modified examples/print_status.rb
100644 → 100755
Empty file.
Loading
Loading