diff --git a/CHANGES.md b/CHANGES.md index 53c4cff..50db8dc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,11 @@ # woad.Ruby - Changes +## 0.0.1 - 15th August 2026 + +* SGR colour and reset codes (`RESET`, `FG_*`, `BG_*`, including bright variants); + + ## 0.0.0 - 15th August 2026 * initial project scaffolding; diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..1fdab37 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,9 @@ +# woad.Ruby - News + +| Date | News Item | +| ---------------- | -------------------------------------------------------------------------------------- | +| 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) | + + + diff --git a/README.md b/README.md index ef049c9..1225abc 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,14 @@ Use via **require**, as in: ```Ruby require 'woad' + +puts "#{Woad::FG_GREEN}ok#{Woad::RESET}" ``` ## Components -**woad.Ruby** currently ships the **`Woad`** root module and version metadata (`require 'woad'`). Colour codes, TTY/stream gating, and Windows virtual-terminal opt-in are not implemented in this 0.0.0 skeleton. +**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. ## Project Information @@ -79,6 +81,7 @@ Defect reports, feature requests, and pull requests are welcome on https://githu ### Related projects +* [**woad**](https://github.com/synesissoftware/woad/) * [**woad.Python**](https://github.com/synesissoftware/woad.Python/) * [**woad.Rust**](https://github.com/synesissoftware/woad.Rust/) diff --git a/TODO.md b/TODO.md index fd66ada..684f018 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ ## Functional improvements -* [ ] SGR colour and reset codes; +* [x] ~~~SGR colour and reset codes~~~ ✅; * [ ] TTY-conditional colour codes (process and per-stream); * [ ] Windows virtual-terminal gating (OS build + `GetConsoleMode`); diff --git a/lib/woad.rb b/lib/woad.rb index be06ee1..a8a45c6 100644 --- a/lib/woad.rb +++ b/lib/woad.rb @@ -50,6 +50,53 @@ ## Root module for *woad* module Woad + # Reset + + RESET = "\e[0m" + + # Foreground (standard) + + FG_BLACK = "\e[30m" + FG_RED = "\e[31m" + FG_GREEN = "\e[32m" + FG_YELLOW = "\e[33m" + FG_BLUE = "\e[34m" + FG_MAGENTA = "\e[35m" + FG_CYAN = "\e[36m" + FG_WHITE = "\e[37m" + + # Foreground (bright) + + FG_BRIGHT_BLACK = "\e[90m" + FG_BRIGHT_RED = "\e[91m" + FG_BRIGHT_GREEN = "\e[92m" + FG_BRIGHT_YELLOW = "\e[93m" + FG_BRIGHT_BLUE = "\e[94m" + FG_BRIGHT_MAGENTA = "\e[95m" + FG_BRIGHT_CYAN = "\e[96m" + FG_BRIGHT_WHITE = "\e[97m" + + # Background (standard) + + BG_BLACK = "\e[40m" + BG_RED = "\e[41m" + BG_GREEN = "\e[42m" + BG_YELLOW = "\e[43m" + BG_BLUE = "\e[44m" + BG_MAGENTA = "\e[45m" + BG_CYAN = "\e[46m" + BG_WHITE = "\e[47m" + + # Background (bright) + + BG_BRIGHT_BLACK = "\e[100m" + BG_BRIGHT_RED = "\e[101m" + BG_BRIGHT_GREEN = "\e[102m" + BG_BRIGHT_YELLOW = "\e[103m" + BG_BRIGHT_BLUE = "\e[104m" + BG_BRIGHT_MAGENTA = "\e[105m" + BG_BRIGHT_CYAN = "\e[106m" + BG_BRIGHT_WHITE = "\e[107m" end # module Woad diff --git a/lib/woad/version.rb b/lib/woad/version.rb index b33d353..7e56c82 100644 --- a/lib/woad/version.rb +++ b/lib/woad/version.rb @@ -50,7 +50,7 @@ module Woad # Current version of the woad.Ruby library - VERSION = '0.0.0' + VERSION = '0.0.1' private # @!visibility private diff --git a/test/unit/tc_codes.rb b/test/unit/tc_codes.rb new file mode 100644 index 0000000..39a1006 --- /dev/null +++ b/test/unit/tc_codes.rb @@ -0,0 +1,42 @@ +#! /usr/bin/env ruby + +$:.unshift File.join(File.dirname(__FILE__), '../../lib') + + +require 'woad' + +require 'test/unit' + + +class Test_codes < Test::Unit::TestCase + + def test_RESET + + assert_equal "\e[0m", Woad::RESET + end + + def test_FG_RED + + assert_equal "\e[31m", Woad::FG_RED + end + + def test_BG_BLUE + + assert_equal "\e[44m", Woad::BG_BLUE + end + + def test_codes_are_csi_sgr + + [ + Woad::RESET, + Woad::FG_BLACK, + Woad::FG_BRIGHT_WHITE, + Woad::BG_BLACK, + Woad::BG_BRIGHT_WHITE, + ].each do |code| + + assert code.start_with?("\e[") + assert code.end_with?('m') + end + end +end diff --git a/woad.gemspec b/woad.gemspec index eb09897..30d0f6a 100644 --- a/woad.gemspec +++ b/woad.gemspec @@ -47,7 +47,7 @@ END_DESC 'source_code_uri' => 'https://github.com/synesissoftware/woad.Ruby', } - spec.files = Dir[ 'Rakefile', '{bin,examples,lib,man,spec,test}/**/*', 'AUTHORS.md', 'CHANGES.md', 'LICENSE*', 'README*', 'TODO.md' ] + spec.files = Dir[ 'Rakefile', '{bin,examples,lib,man,spec,test}/**/*', 'AUTHORS.md', 'CHANGES.md', 'LICENSE*', 'NEWS.md', 'README*', 'TODO.md' ] end