diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8d78c5d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,64 @@ +root = true + +# Language indent/EOL/charset overlap with .vscode/settings.json. +# Rulers, renderWhitespace, detectIndentation, mergeEditor, and +# cmake.configureOnOpen cannot be expressed here — they stay in settings.json. + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true + +# [bat] +[*.{bat,cmd}] +end_of_line = crlf +indent_size = 4 +indent_style = space + +# [c] +[*.{c,h}] +indent_size = 4 +indent_style = space + +# [cmake] +[{CMakeLists.txt,*.cmake}] +indent_size = 4 +indent_style = tab + +# [cpp] +[*.{cpp,cxx,hpp,hxx}] +indent_size = 4 +indent_style = space + +# [json] +[*.json] +indent_size = 2 +indent_style = space + +# [markdown] +[*.md] +indent_size = 2 +indent_style = space +trim_trailing_whitespace = false + +# [ruby] +[*.{gemspec,rb}] +indent_size = 2 +indent_style = space + +[{Gemfile,Rakefile}] +indent_size = 2 +indent_style = space + +# [shellscript] +[*.{bash,sh,zsh}] +indent_size = 2 +indent_style = space + +# [yaml] +[*.{yaml,yml}] +indent_size = 2 +indent_style = space diff --git a/.gitattributes b/.gitattributes index e69de29..2c70232 100644 --- a/.gitattributes +++ b/.gitattributes @@ -0,0 +1,75 @@ +# .gitattributes — Ruby (GitHub-hosted) +# +# Sources: GitHub Docs (line endings), git-scm gitattributes (diff=ruby), +# gitattributes/gitattributes Common.gitattributes + Web (*.rb), +# github-linguist overrides. + +# Default: detect text, normalize to LF in the repository +* text=auto + +# --- Source --- +*.gemspec text eol=lf diff=ruby +*.rake text eol=lf diff=ruby +*.rb text eol=lf diff=ruby +*.ru text eol=lf diff=ruby +Gemfile text eol=lf diff=ruby +Rakefile text eol=lf diff=ruby +Capfile text eol=lf diff=ruby +Guardfile text eol=lf diff=ruby +*.erb text +*.haml text +*.slim text + +# --- Lock / config --- +Gemfile.lock text +*.gemspec.lock text -diff +*.yml text +*.yaml text +*.toml text +*.json text + +# --- Scripts --- +*.bash text eol=lf +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf +*.sh text eol=lf +*.zsh text eol=lf + +# --- Docs / meta --- +*.adoc text +*.markdown text diff=markdown +*.md text diff=markdown +*.txt text +AUTHORS text +CHANGELOG text +CHANGES text +CONTRIBUTING text +COPYING text +LICENSE text +NEWS text +README text +TODO text +.gitattributes text +.gitignore text + +# --- Binary --- +*.gem binary +*.so binary + +# --- Archives / images (common) --- +*.gif binary +*.gz binary +*.ico binary +*.jpeg binary +*.jpg binary +*.png binary +*.tar binary +*.zip binary + +# --- GitHub Linguist --- +**/vendor/bundle/** linguist-vendored +**/vendor/cache/** linguist-vendored +**/coverage/** linguist-generated +**/doc/** linguist-documentation +**/pkg/** linguist-generated diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3189593 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - directory: / + package-ecosystem: bundler + schedule: + interval: weekly + - directory: / + package-ecosystem: github-actions + schedule: + interval: weekly diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..ff21ec7 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,117 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +# +# Created: 15th August 2026 +# Updated: 15th August 2026 +# + +name: Ruby + +on: + push: + branches: + - master + - dev + - boilerplate + - idiomatic + - rc1 + - rc2 + - rc3 + pull_request: + +permissions: + contents: read + +defaults: + run: + shell: bash + +jobs: + test: + + strategy: + fail-fast: false + + matrix: + os: + - macos-latest + - ubuntu-latest + - windows-latest + + ruby-version: + # - head + - '3.4' + - '3.3' + - '3.2' + - '3.1' + - '3.0' + - '2.7' + - '2.6' + + include: + - os: ubuntu-latest + ruby-version: '2.5' + - os: ubuntu-latest + ruby-version: '2.4' + - os: ubuntu-latest + ruby-version: '2.0' + - os: windows-latest + ruby-version: mingw + + runs-on: ${{ matrix.os }} + + steps: + - name: Checking out code + uses: actions/checkout@v4 + + - name: Remove Gemfile.lock + run: rm -f Gemfile.lock + + - name: Set up Ruby v${{ matrix.ruby-version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - name: Show Ruby version + run: ruby -v + + - name: Run tests + run: bundle exec rake test + + - name: Gem build and install smoke + shell: bash + run: | + gem build libCLImate.gemspec + gem install --local libclimate-ruby-*.gem + ruby -e "require 'libclimate/version'; abort('VERSION missing') unless defined?(LibCLImate::VERSION); puts LibCLImate::VERSION" + + warnings: + + name: Warnings + + runs-on: ubuntu-latest + + steps: + - name: Checking out code + uses: actions/checkout@v4 + + - name: Remove Gemfile.lock + run: rm -f Gemfile.lock + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Show Ruby version + run: ruby -v + + - name: Run unit tests with warnings + run: ./run_all_unit_tests.sh --lib --warnings diff --git a/.gitignore b/.gitignore index 3615780..0d510c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,38 +1,39 @@ - # directories (by name) -build/ - +/.bzr/ /.bundle/ +/.config/ +/.svn/ /.yardoc/ + /_yardoc/ /InstalledFiles/ - +/build/ /coverage/ /doc/ /lib/bundler/man/ +/old-gems/ /pkg/ /rdoc/ +/scratch/ /spec/reports/ /test/tmp/ /test/version_tmp/ /tmp/ -/vendor/bundle +/vendor/bundle/ # directories (by pattern) # files (by name) -/.config -/.repl_history -/.ruby-version -/spec/examples.txt - .DS_Store .repl_history +.ruby-version .rvmrc +/spec/examples.txt + # files (by pattern) *~ @@ -42,6 +43,8 @@ build/ *.bridgesupport *.gem *.rbc +*.scc +*.suo *.swp +*.tmp *.zip - diff --git a/.ruby-version-exclusions b/.ruby-version-exclusions index 9e53287..a8df221 100644 --- a/.ruby-version-exclusions +++ b/.ruby-version-exclusions @@ -1,11 +1,2 @@ 1.8.7-p375 1.9.3-p551 -#2.0.0-p648 -#2.1.10 -#2.2.10 -#2.3.8 -#2.4.5 -#2.5.3 -#2.6.1 -4.0.6 - diff --git a/.sis/project_name.txt b/.sis/project_name.txt new file mode 100644 index 0000000..67dc5fe --- /dev/null +++ b/.sis/project_name.txt @@ -0,0 +1 @@ +libCLImate.Ruby diff --git a/.vimrc b/.vimrc index 1bf33a0..b8184be 100644 --- a/.vimrc +++ b/.vimrc @@ -1,4 +1,4 @@ -" Synesis C/C++ project .vimrc — aligned with .sis/.vscode/c_cxx/settings.json +" Synesis Ruby project .vimrc — aligned with .vscode/settings.json (2-space Ruby) set nocompatible filetype indent plugin on @@ -17,12 +17,12 @@ set fixeol set list set listchars=tab:->,trail:-,extends:>,precedes:<,nbsp:+ -" editor.detectIndentation: false — global defaults (editor.tabSize: 4, insertSpaces: true) +" editor.detectIndentation: false — global defaults (editor.tabSize: 2, insertSpaces: true) set colorcolumn=76 set expandtab -set shiftwidth=4 -set softtabstop=4 -set tabstop=4 +set shiftwidth=2 +set softtabstop=2 +set tabstop=2 " colorcolumn draws a full-column tint in Vim (not a VS Code-style 1px line). " Keep it subtle via the ColorColumn highlight group; reapply after colorscheme changes. diff --git a/.vscode/settings.json b/.vscode/settings.json index 0858e77..19efccd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,225 +1,43 @@ { - "[bat]": { - "editor.insertSpaces": true, - "editor.rulers": [ 60, 76, ], - "editor.tabSize": 4, - }, - "[c]": { - "editor.insertSpaces": true, - "editor.rulers": [ 60, 64, 68, 72, 76, - ], - "editor.tabSize": 4, - }, - "[cmake]": { - "editor.insertSpaces": false, - "editor.tabSize": 4, - }, - "[cpp]": { - "editor.insertSpaces": true, - "editor.rulers": [ 60, 64, 68, 72, 76, - ], - "editor.tabSize": 4, - }, - "[csharp]": { - "editor.insertSpaces": true, - "editor.rulers": [ 60, 76, ], - "editor.tabSize": 4, - }, - "[go]": { - "editor.codeActionsOnSave": {}, - "editor.defaultFormatter": "golang.go", - "editor.formatOnSave": true, - "editor.insertSpaces": false, - "editor.tabSize": 2, - }, - "[json]": { - "editor.insertSpaces": false, - "editor.tabSize": 2, - }, - "[markdown]": { - "editor.insertSpaces": true, - "editor.tabSize": 2, - }, - "[python]": { - "diffEditor.ignoreTrimWhitespace": false, - "editor.insertSpaces": true, - "editor.rulers": [ 60, 76, ], - "editor.tabSize": 4, - }, - "[ruby]": { - "editor.insertSpaces": true, - "editor.rulers": [ 60, 76, ], - "editor.tabSize": 2, - }, - "[rust]": { - "editor.insertSpaces": true, - "editor.rulers": [ 60, 76, ], - "editor.tabSize": 4, - }, - "[shellscript]": { - "editor.insertSpaces": true, - "editor.rulers": [ 60, 76, ], - "editor.tabSize": 2, - }, - "[toml]": { - "editor.insertSpaces": false, - "editor.tabSize": 2, - }, - "[typescript]": { - "editor.insertSpaces": true, - "editor.tabSize": 2, - }, - "cmake.configureOnOpen": false, - "editor.detectIndentation": false, - "editor.insertSpaces": false, - "editor.renderWhitespace": "all", - "editor.rulers": [ 76, ], - "editor.tabSize": 2, - "files.associations": { - "__bit_reference": "cpp", - "__bits": "cpp", - "__config": "cpp", - "__debug": "cpp", - "__errc": "cpp", - "__functional_03": "cpp", - "__functional_base": "cpp", - "__hash_table": "cpp", - "__locale": "cpp", - "__memory": "cpp", - "__mutex_base": "cpp", - "__node_handle": "cpp", - "__nullptr": "cpp", - "__split_buffer": "cpp", - "__string": "cpp", - "__threading_support": "cpp", - "__tree": "cpp", - "__tuple": "cpp", - "__verbose_abort": "cpp", - "algorithm": "cpp", - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "charconv": "cpp", - "chrono": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "compare": "cpp", - "complex": "cpp", - "concepts": "cpp", - "console_functions.h": "c", - "corecrt.h": "c", - "crtdefs.h": "c", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "exception": "cpp", - "execution": "cpp", - "fcntl.h": "c", - "format": "cpp", - "forward_list": "cpp", - "functional": "cpp", - "implicit_link.h": "c", - "initializer_list": "cpp", - "io.h": "c", - "iomanip": "cpp", - "ios": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "iterator": "cpp", - "limits": "cpp", - "list": "cpp", - "locale": "cpp", - "map": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "mutex": "cpp", - "new": "cpp", - "numeric": "cpp", - "optional": "cpp", - "ostream": "cpp", - "queue": "cpp", - "ratio": "cpp", - "set": "cpp", - "setenv.h": "c", - "shwild.h": "c", - "sstream": "cpp", - "stack": "cpp", - "stdexcept": "cpp", - "stdio.h": "c", - "streambuf": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "terse-api.h": "c", - "thread": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "typeinfo": "cpp", - "uio.h": "c", - "unixem.h": "c", - "unordered_map": "cpp", - "util.h": "c", - "utility": "cpp", - "variant": "cpp", - "vector": "cpp", - "xfacet": "cpp", - "xiosbase": "cpp", - "xlocale": "cpp", - "xlocbuf": "cpp", - "xlocinfo": "cpp", - "xlocmes": "cpp", - "xlocmon": "cpp", - "xlocnum": "cpp", - "xloctime": "cpp", - "xmemory": "cpp", - "xstring": "cpp", - "xtests.internal.string.c": "cpp", - "xtr1common": "cpp", - "xtree": "cpp", - "xutility": "cpp", - }, - "files.exclude": { - "**/*.egg-info": true, - "**/*.swp": true, - "**/.git": true, - "**/__pycache__": true, - }, - "files.insertFinalNewline": true, - "files.trimTrailingWhitespace": true, - "git.mergeEditor": false, - "go.formatFlags": [], - "go.formatTool": "goimports", - "go.lintFlags": [ - "--fast", - ], - "go.lintOnSave": "workspace", - "go.lintTool": "golangci-lint", - "go.useLanguageServer": true, - "gopls": { - "ui.completion.usePlaceholders": true, - "ui.semanticTokens": true, - }, - "python.analysis.typeCheckingMode": "standard", - "python.languageServer": "Pylance", - "rust-analyzer.completion.autoimport.enable": false, - "rust-analyzer.showUnlinkedFileNotification": false, - "search.exclude": { - "**/*.egg-info": true, - "**/*.swp": true, - "**/.git": true, - "**/__pycache__": true, - "**/node_modules": true, - "**/target": true, - }, - "search.useIgnoreFiles": false, + "[json]": { + "editor.insertSpaces": true, + "editor.tabSize": 2, + }, + "[markdown]": { + "editor.insertSpaces": true, + "editor.tabSize": 2, + }, + "[python]": { + "editor.insertSpaces": true, + "editor.rulers": [ 60, 76 ], + "editor.tabSize": 4, + }, + "[ruby]": { + "editor.defaultFormatter": "Shopify.ruby-lsp", + "editor.formatOnSave": true, + "editor.formatOnType": true, + "editor.insertSpaces": true, + "editor.rulers": [ 60, 76 ], + "editor.semanticHighlighting.enabled": true, + "editor.tabSize": 2, + }, + "[shellscript]": { + "editor.insertSpaces": true, + "editor.rulers": [ 60, 76 ], + "editor.tabSize": 2, + }, + "[toml]": { + "editor.insertSpaces": false, + "editor.tabSize": 2, + }, + "cmake.configureOnOpen": false, + "editor.detectIndentation": false, + "editor.insertSpaces": false, + "editor.renderWhitespace": "all", + "editor.rulers": [ 76 ], + "editor.tabSize": 2, + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true, + "git.mergeEditor": false, + "rubyLsp.formatter": "auto", } diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 0000000..6af465a --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,21 @@ +# libCLImate.Ruby - Authors + + +## Major Contributors + +| Name | GitHub | +| ----------- | --------------------------------- | +| Matt Wilson | [mwsis](https://github.com/mwsis) | + + +## Defect reports, fixes and suggestions (for which we are very grateful) + +| Name | GitHub | +| ----------- | --------------------------------- | +| \ | | + + +Contributions are welcomed. + + + diff --git a/CHANGES.md b/CHANGES.md index 855d1df..42b14ea 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -# **libCLImate.Ruby** Changes +# libCLImate.Ruby - Changes + + +## 0.17.2 - 15th August 2026 + +* added `# frozen_string_literal: true` to all **lib/** sources; ## 0.17.1 - 30th July 2026 @@ -8,91 +13,286 @@ ## 0.17.0.2 - 30th July 2026 -* + added `TODO.md` and updated existing boilerplate files to use the end-of-file marker; -* ~ updated boilerplate: - * ~ `README.md`: updated tagline placement, added license and other badges, and enhanced dependencies section with Efferent/Afferent coupling information; - * ~ `LICENSE`: updated copyright years and format; - * ~ `libCLImate.gemspec`: updated comment header and date; - * ~ `.vscode/settings.json`: updated various language settings for indentation, rulers, and file associations; - * ~ `build_gem.sh`, `generate_rdoc.sh`, `test/scratch/blankzeroes.rb`: updated dates; -* ~ updated dependencies; -* ~ tidying; +* added **TODO.md** and updated existing boilerplate files to use the end-of-file marker; +* updated boilerplate (**README.md**, **LICENSE**, **libCLImate.gemspec**, **.vscode/settings.json**, helper scripts); +* updated **README.md** tagline placement, badges, and Efferent/Afferent dependencies section; +* updated dependencies; +* tidying; * added **.vimrc**; ## 0.17.0.1 - 5th March 2025 -* **Documentation**: - * Improved `README.md` tagline placement, expanded dependencies section with Efferent/Afferent coupling details, and added license badge; - * Updated `CHANGES.md` with a summary of these changes; - * Added `TODO.md` for project task tracking; - * Updated `EXAMPLES.md` to use end-of-file marker; -* **IDE Settings (`.vscode/settings.json`)**: - * Expanded language-specific settings for indentation, rulers, and formatting for C, C++, C#, Go, JSON, Markdown, Python, Ruby, Rust, Shellscript, and TypeScript; - * Configured Go formatting and linting; - * Updated file associations and search exclusions; - * Set `git.mergeEditor` to `false`; -* **Code Formatting**: Applied consistent indentation (spaces over tabs, 2-space where applicable) in various Ruby example and test files (`examples/*.rb`, `test/unit/*.rb`, `test/scratch/*.rb`) to adhere to `.cursor/rules/ruby-standards.mdc`; +* improved **README.md** tagline placement, dependencies section, and license badge; +* updated **CHANGES.md**; +* added **TODO.md**; +* updated **EXAMPLES.md** to use end-of-file marker; +* expanded **.vscode/settings.json** language and formatting settings; +* applied consistent indentation in examples and tests; ## 0.17.0 - 10th August 2024 -* + added option `:value_attributes` to cause any possible value-names, as described by `#value_names`, to be applied as attributes with the given value, if any, on the command-line; -* ~ updated dependencies; -* ~ updated **CHANGES.md**; -* ~ preparatory work; -* ~ updated dependencies; -* ~ settings; -* ~ updated **run_all_unit_tests.sh** from **synesissoftware/misc-dev-scripts**; +* added option `:value_attributes` so value-names from `#value_names` are applied as attributes when present on the command-line; +* updated dependencies; +* updated **CHANGES.md**; +* preparatory work; +* settings; +* updated **run_all_unit_tests.sh** (from **synesissoftware/misc-dev-scripts**); + + +## 0.16.0.1 - 1st December 2023 + +* Merged branch double_slash_index; ## 0.16.0 - 1st December 2023 -* + added attribute `libCLImate::Climate#double_slash_index` / `libCLImate::Climate::ParseResults#double_slash_index`; -* ~ updating dependency versions; -* ~ tidying; +* added `libCLImate::Climate#double_slash_index` / `libCLImate::Climate::ParseResults#double_slash_index`; +* updated dependency versions; +* tidying; ## 0.15.2 - 26th June 2022 -* ~ forced version update; +* forced version update; ## 0.15.1 - 26th June 2022 -* ~ updated **README.md** and Gemspec; -* ~ fix to examples; +* updated **README.md** and gemspec; +* fix to examples; ## 0.15.0 - 29th April 2019 -* + added ``Climate#parse()`` and ``Climate#parse_and_verify()`` methods; -* + added ``Climate::ParseResults()`` class, which is returned from the ``#parse()`` and ``#parse_and_verify()`` methods; -* ~ various changes to examples and improvements to documentation; +* added `Climate#parse()` and `Climate#parse_and_verify()`; +* added `Climate::ParseResults`, returned from `#parse()` and `#parse_and_verify()`; +* various example and documentation improvements; ## 0.14.1 - 29th April 2019 -* + added **Gemfile** +* added **Gemfile**; + + +## 0.14.0.1 - 29th April 2019 + +* merge; ## 0.14.0 - 15th April 2019 -* + ``Climate#constrain_values`` now supports ``Array`` type (as well as ``Integer`` and ``Range``); -* + added ``Climate#usage_help_suffix``, which defaults to "use --help for usage"; +* `Climate#constrain_values` now supports `Array` (as well as `Integer` and `Range`); +* added `Climate#usage_help_suffix`, defaulting to "use --help for usage"; ## 0.13.0 - 13th April 2019 -* + added ``CLASP::Arguments.load()``, which allows to load argument-specifications from ``Hash`` or from YAML; -* + added examples/flag_and_option_specifications.from_DATA.rb, which illustrates use of ``__END__`` / ``DATA`` containing climate specification in YAML form; -* + added ``Climate#on_flag()`` and ``Climate#on_option()`` methods, which allow a block to be attached to an existing flag or option specification; -* ~ corrected defect whereby ``exit_on_unknown`` was used instead of ``exit_on_missing`` when checking required values; +* added `CLASP::Arguments.load()` for loading argument-specifications from `Hash` or YAML; +* added **examples/flag_and_option_specifications.from_DATA.rb** illustrating `__END__` / `DATA` YAML climate specification; +* added `Climate#on_flag()` and `Climate#on_option()` to attach blocks to existing specifications; +* corrected defect whereby `exit_on_unknown` was used instead of `exit_on_missing` when checking required values; + + +## 0.12.2 - 13th April 2019 + +* much improved documentation; + + +## 0.12.1 - 12th April 2019 + +* minor documentation fixes; + + +## 0.12.0 - 12th April 2019 + +* updated in light of CLASP's changed terminology from *[aA]lias => *[sS]pecification; + + +## 0.11.2 - 8th January 2018 + +* SimpleConsoleLogService : ~ corrected handling of symbol as severity; + + +## 0.11.1 - 6th January 2018 + +* renamed SimpleConsoleService => SimpleConsoleLogService; + added NullLogService class; + added log service class tests; + + +## 0.11.0 - 19th March 2019 + +* Climate methods #add_alias(), #add_flag(), #add_option() now take FlagAlias and OptionAlias class instances in addition to names; + + +## 0.10.1.1 - 19th October 2018 + +* dependencies; + + +## 0.10.1 - 6th January 2018 + +* added :benchmark severity level; + + +## 0.9.4 - 6th January 2018 + +* added unit-tests for stock severity levels; + + +## 0.9.3 - 6th January 2018 + +* tagged release; + + +## 0.9.2 - 2nd January 2018 + +* prefix now in [ ]; + + +## 0.9.1 - 24th December 2017 + +* fixing; + + +## 0.8.4 - 8th January 2019 + +* tagged release; + + +## 0.8.3 - 6th September 2018 + +* minor changes to documentation markup; + + +## 0.8.2 - 13th July 2018 + +* merge version update; + + +## 0.8.1 - 18th June 2018 + +* now recognised PROGRAM_VER_PATCH (in the stead of PROGRAM_VER_REVISION); + + +## 0.8.0 - 23rd December 2017 + +* starting to break out impl. into Pantheios::Core; + + +## 0.7.4 - 7th February 2018 + +* merge; + + +## 0.7.3 - 5th February 2018 + +* LibCLImate::Climate::set_program_name(), which uses Colcon if available; + + +## 0.7.2 - 3rd January 2018 + +* merge version update; + + +## 0.7.1 - 1st January 2018 + +* added support for required options (based on CLASP.Ruby 0.12; + + +## 0.6.5 - 1st January 2018 + +* preparatory mods; + + +## 0.6.4 - 1st January 2018 + +* fixed the version inference; + + +## 0.6.3 - 22nd June 2017 + +* tagged release; + + +## 0.6.2 - 16th March 2017 + +* fix; + + +## 0.6.1 - 16th March 2017 + +* added inference of version; + + +## 0.5.8 - 17th October 2016 + +* tidying up contract enforcements; + + +## 0.5.7 - 17th October 2016 + +* simplified unit test; + + +## 0.5.6 - 17th October 2016 + +* updated documentation; + + +## 0.5.5 - 26th June 2016 + +* changed hash-bangs; + + +## 0.5.4 - 18th June 2016 + +* fixed lacking blocks in new add_*() methods; + + +## 0.5.3 - 17th June 2016 + +* fix; + + +## 0.4.1 - 14th June 2016 + +* tidying; + + +## 0.3.1 - 13th June 2016 + +* merge; + + +## 0.2.4 - 13th June 2016 + +* 0.2.4 changes; + + +## 0.2.3 - 12th June 2016 + +* fixed extras handling for flags; + + +## 0.2.2 - 11th June 2016 + +* merge; + + +## 0.2.1 - 6th June 2016 + +* specified ranges for dependent libraries; + + +## 0.1.2 - 14th May 2016 + +* added Climate class, and basics of API; -## previous versions +## 0.1.1 - 14th July 2015 -T.B.C. +* added basic skeleton (0.1.1); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..fee7b0f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,36 @@ +# libCLImate.Ruby - Contributing + + +## Table of Contents + +- [Defects and features](#defects-and-features) +- [Pull requests](#pull-requests) +- [Tests](#tests) +- [License](#license) + + +## Defects and features + +Open an issue on https://github.com/synesissoftware/libCLImate.Ruby/issues. + + +## Pull requests + +Pull requests are welcome on https://github.com/synesissoftware/libCLImate.Ruby. Keep diffs local to the change; match existing indentation (2 spaces in Ruby) and the Synesis markdown set (**README.md**, **CHANGES.md**, **NEWS.md**, **TODO.md**, **INSTALL.md**, **CONTRIBUTING.md**, **SECURITY.md**). + + +## Tests + +``` +bundle exec rake test +``` + +or `./run_all_unit_tests.sh`. + + +## License + +Contributions are accepted under the 3-clause BSD license. See [LICENSE](./LICENSE). + + + diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 0000000..a988b90 --- /dev/null +++ b/FAQ.md @@ -0,0 +1,28 @@ +# libCLImate.Ruby - FAQ + +The FAQ list is under (constant) development. If you post a question on the +[Issues](https://github.com/synesissoftware/libCLImate.Ruby/issues) forum +it will be used to create one. + + +## Table of Contents + +- [Q1: "How do I install this library?"](#q1-how-do-i-install-this-library) + + +# FAQs: + + +## Q1: "How do I install this library?" + +Install via **gem**: + +``` +gem install libclimate-ruby +``` + +See [README.md](./README.md) for usage. + + + + diff --git a/Gemfile b/Gemfile index 6d090cc..29f6d2e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,13 +2,15 @@ source "https://rubygems.org" -gem 'clasp-ruby', [ '~> 0.23', '>= 0.23.0.2' ] +gemspec -if RUBY_VERSION >= '2' +# rake 13 requires Ruby >= 2.3 +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3") - gem 'xqsr3', '~> 0.39' + gem "rake", '~> 13.0' else - gem 'xqsr3', '~> 0.21.3' + gem "rake", '~> 12.3' end +gem "test-unit", '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 014dbd5..5574c30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,15 +1,22 @@ +PATH + remote: . + specs: + libclimate-ruby (0.17.1) + clasp-ruby (~> 0.23, >= 0.23.0.2) + xqsr3 (~> 0.39) + GEM remote: https://rubygems.org/ specs: - clasp-ruby (0.23.0.2) - xqsr3 (0.39.3) + clasp-ruby (0.23.1) + xqsr3 (0.39.5) PLATFORMS - x86_64-darwin-20 + arm64-darwin-25 + ruby DEPENDENCIES - clasp-ruby (~> 0.23, >= 0.23.0.2) - xqsr3 (~> 0.39) + libclimate-ruby! BUNDLED WITH - 2.3.16 + 2.6.9 diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..95ebdd6 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,41 @@ +# libCLImate.Ruby - Installation and Use + + +## Table of Contents + +- [Install the gem](#install-the-gem) +- [From a source checkout](#from-a-source-checkout) +- [Using the library](#using-the-library) + + +## Install the gem + +``` +gem install libclimate-ruby +``` + +or add to a **Gemfile**: + +```Ruby +gem 'libclimate-ruby' +``` + +then `bundle install`. + + +## From a source checkout + +``` +bundle install +bundle exec rake test +``` + + +## Using the library + +```Ruby +require 'libclimate' +``` + + + diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..4494425 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,61 @@ +# libCLImate.Ruby - News + +| Date | News Item | +| ------------------ | ----------------------------------------------------------------------------------------------- | +| 15th August 2026 | [**libCLImate.Ruby** 0.17.2](https://github.com/synesissoftware/libCLImate.Ruby/releases/tag/0.17.2) | +| 30th July 2026 | [**libCLImate.Ruby** 0.17.1](https://github.com/synesissoftware/libCLImate.Ruby/releases/tag/0.17.1) | +| 30th July 2026 | **libCLImate.Ruby** 0.17.0.2 released | +| 6th March 2025 | **libCLImate.Ruby** 0.17.0.1 released | +| 10th August 2024 | **libCLImate.Ruby** 0.17.0 released | +| 1st December 2023 | **libCLImate.Ruby** 0.16.0.1 released | +| 1st December 2023 | **libCLImate.Ruby** 0.16.0 released | +| 26th June 2022 | **libCLImate.Ruby** 0.15.2 released | +| 26th June 2022 | **libCLImate.Ruby** 0.15.1 released | +| 29th April 2019 | **libCLImate.Ruby** 0.15.0 released | +| 29th April 2019 | **libCLImate.Ruby** 0.14.1 released | +| 29th April 2019 | **libCLImate.Ruby** 0.14.0.1 released | +| 15th April 2019 | **libCLImate.Ruby** 0.14.0 released | +| 13th April 2019 | **libCLImate.Ruby** 0.13.0 released | +| 13th April 2019 | **libCLImate.Ruby** 0.12.2 released | +| 12th April 2019 | **libCLImate.Ruby** 0.12.1 released | +| 12th April 2019 | **libCLImate.Ruby** 0.12.0 released | +| 19th March 2019 | **libCLImate.Ruby** 0.11.0 released | +| 8th January 2019 | **libCLImate.Ruby** 0.8.4 released | +| 19th October 2018 | **libCLImate.Ruby** 0.10.1.1 released | +| 6th September 2018 | **libCLImate.Ruby** 0.8.3 released | +| 13th July 2018 | **libCLImate.Ruby** 0.8.2 released | +| 18th June 2018 | **libCLImate.Ruby** 0.8.1 released | +| 7th February 2018 | **libCLImate.Ruby** 0.7.4 released | +| 5th February 2018 | **libCLImate.Ruby** 0.7.3 released | +| 8th January 2018 | **libCLImate.Ruby** 0.11.2 released | +| 6th January 2018 | **libCLImate.Ruby** 0.11.1 released | +| 6th January 2018 | **libCLImate.Ruby** 0.10.1 released | +| 6th January 2018 | **libCLImate.Ruby** 0.9.4 released | +| 6th January 2018 | **libCLImate.Ruby** 0.9.3 released | +| 3rd January 2018 | **libCLImate.Ruby** 0.7.2 released | +| 2nd January 2018 | **libCLImate.Ruby** 0.9.2 released | +| 1st January 2018 | **libCLImate.Ruby** 0.7.1 released | +| 1st January 2018 | **libCLImate.Ruby** 0.6.5 released | +| 1st January 2018 | **libCLImate.Ruby** 0.6.4 released | +| 24th December 2017 | **libCLImate.Ruby** 0.9.1 released | +| 23rd December 2017 | **libCLImate.Ruby** 0.8.0 released | +| 22nd June 2017 | **libCLImate.Ruby** 0.6.3 released | +| 16th March 2017 | **libCLImate.Ruby** 0.6.2 released | +| 16th March 2017 | **libCLImate.Ruby** 0.6.1 released | +| 17th October 2016 | **libCLImate.Ruby** 0.5.8 released | +| 17th October 2016 | **libCLImate.Ruby** 0.5.7 released | +| 17th October 2016 | **libCLImate.Ruby** 0.5.6 released | +| 26th June 2016 | **libCLImate.Ruby** 0.5.5 released | +| 18th June 2016 | **libCLImate.Ruby** 0.5.4 released | +| 17th June 2016 | **libCLImate.Ruby** 0.5.3 released | +| 14th June 2016 | **libCLImate.Ruby** 0.4.1 released | +| 13th June 2016 | **libCLImate.Ruby** 0.3.1 released | +| 13th June 2016 | **libCLImate.Ruby** 0.2.4 released | +| 12th June 2016 | **libCLImate.Ruby** 0.2.3 released | +| 11th June 2016 | **libCLImate.Ruby** 0.2.2 released | +| 6th June 2016 | **libCLImate.Ruby** 0.2.1 released | +| 14th May 2016 | **libCLImate.Ruby** 0.1.2 released | +| 14th July 2015 | **libCLImate.Ruby** 0.1.1 released | + + + diff --git a/README.md b/README.md index 97d462a..1372621 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ libCLImate, for Ruby [![Gem Downloads](https://img.shields.io/gem/dt/libclimate-ruby.svg)](https://rubygems.org/gems/libclimate-ruby) [![GitHub release](https://img.shields.io/github/v/release/synesissoftware/libCLImate.Ruby.svg)](https://github.com/synesissoftware/libCLImate.Ruby/releases/latest) [![Last Commit](https://img.shields.io/github/last-commit/synesissoftware/libCLImate.Ruby)](https://github.com/synesissoftware/libCLImate.Ruby/commits/master) +[![Ruby](https://github.com/synesissoftware/libCLImate.Ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/synesissoftware/libCLImate.Ruby/actions/workflows/ruby.yml) ## Table of Contents diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..d05668d --- /dev/null +++ b/Rakefile @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# Rakefile for libCLImate.Ruby + +require 'rake/testtask' + + +Rake::TestTask.new do |tt| + + tt.libs << 'lib' + tt.libs << 'test' + tt.name = 'test' + tt.test_files = FileList['test/**/tc_*.rb'] + tt.verbose = true +end + + +task :default => :test + + +# ############################## end of file ############################# # diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..7574698 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,23 @@ +# libCLImate.Ruby - Security + + +## Table of Contents + +- [Reporting a vulnerability](#reporting-a-vulnerability) +- [Supported versions](#supported-versions) + + +## Reporting a vulnerability + +Please report security issues privately via GitHub Security Advisories on https://github.com/synesissoftware/libCLImate.Ruby/security, or by opening an issue if an advisory cannot be filed. Do not attach exploit proofs of concept against third-party systems. + + +## Supported versions + +| Version | Supported | +| ------- | --------- | +| 0.17.x | ✅ | +| < 0.17 | ❌ | + + + diff --git a/TODO.md b/TODO.md index 92afe39..5c15580 100644 --- a/TODO.md +++ b/TODO.md @@ -21,6 +21,7 @@ ## Packaging improvements * [ ] GitHub Actions; +* [ ] Rename gemspec so the filename stem matches `spec.name` (`libCLImate.gemspec` → **libclimate-ruby.gemspec**); diff --git a/build_gem.cmd b/build_gem.cmd new file mode 100644 index 0000000..c894c21 --- /dev/null +++ b/build_gem.cmd @@ -0,0 +1,13 @@ +@ECHO OFF + +REM ######################################################################## +REM File: build_gem.cmd +REM +REM Purpose: Builds the gem +REM +REM Created: 11th July 2016 +REM Updated: 14th August 2026 +REM +REM ######################################################################## + +FOR %%f IN (*.gemspec) DO gem build "%%f" %* diff --git a/build_gem.sh b/build_gem.sh index 6425dde..864823e 100755 --- a/build_gem.sh +++ b/build_gem.sh @@ -5,12 +5,9 @@ # # Purpose: Builds the gem # -# Created: 14th July 2015 -# Updated: 30th July 2026 -# -# Author: Matthew Wilson +# Created: 9th June 2016 +# Updated: 14th August 2026 # ############################################################################# -gem build libCLImate.gemspec $* - +gem build *.gemspec $* diff --git a/examples/flag_and_option_specifications.from_DATA.md b/examples/flag_and_option_specifications.from_DATA.md index 1299cf9..814751e 100644 --- a/examples/flag_and_option_specifications.from_DATA.md +++ b/examples/flag_and_option_specifications.from_DATA.md @@ -1,4 +1,4 @@ -# libCLImate.Ruby Example - **flag_and_option_specifications.from_DATA** +# libCLImate.Ruby - Example - **flag_and_option_specifications.from_DATA** ## Summary diff --git a/examples/flag_and_option_specifications.md b/examples/flag_and_option_specifications.md index d1c20a4..142ce34 100644 --- a/examples/flag_and_option_specifications.md +++ b/examples/flag_and_option_specifications.md @@ -1,4 +1,4 @@ -# libCLImate.Ruby Example - **flag_and_option_specifications** +# libCLImate.Ruby - Example - **flag_and_option_specifications** ## Summary diff --git a/examples/show_usage_and_version.md b/examples/show_usage_and_version.md index f8b2e2d..98cb85c 100644 --- a/examples/show_usage_and_version.md +++ b/examples/show_usage_and_version.md @@ -1,4 +1,4 @@ -# libCLImate.Ruby Example - **show_usage_and_version** +# libCLImate.Ruby - Example - **show_usage_and_version** ## Summary diff --git a/generate_rdoc.cmd b/generate_rdoc.cmd new file mode 100644 index 0000000..4f6f7ad --- /dev/null +++ b/generate_rdoc.cmd @@ -0,0 +1,28 @@ +@ECHO OFF + +REM ######################################################################## +REM File: generate_rdoc.cmd +REM +REM Purpose: Generates documentation +REM +REM Created: 14th August 2026 +REM Updated: 14th August 2026 +REM +REM ######################################################################## + +IF EXIST doc RMDIR /S /Q doc +rdoc ^ + -x build_gem.cmd ^ + -x build_gem.sh ^ + -x generate_rdoc.cmd ^ + -x generate_rdoc.sh ^ + -x run_all_unit_tests.sh ^ + -x *.gemspec ^ + -x doc/ ^ + -x gems/ ^ + -x old-gems/ ^ + -x test/performance/ ^ + -x test/scratch/ ^ + -x tc_.*\.rb ^ + -x ts_all.rb ^ + %* diff --git a/generate_rdoc.sh b/generate_rdoc.sh index 8437ae2..e7dc865 100755 --- a/generate_rdoc.sh +++ b/generate_rdoc.sh @@ -6,25 +6,26 @@ # Purpose: Generates documentation # # Created: 11th June 2016 -# Updated: 30th July 2026 +# Updated: 14th August 2026 # ############################################################################# rm -rfd doc rdoc \ - -x build_gem.sh \ - -x generate_rdoc.sh \ - -x run_all_unit_tests.sh \ - -x libCLImate.gemspec \ - \ - -x doc/ \ - -x gems/ \ - -x old-gems/ \ - -x test/scratch/ \ - \ - -x ts_all.rb \ - -x tc_.*\.rb \ - \ - $* - - + -x build_gem.cmd \ + -x build_gem.sh \ + -x generate_rdoc.cmd \ + -x generate_rdoc.sh \ + -x run_all_unit_tests.sh \ + -x *.gemspec \ + \ + -x doc/ \ + -x gems/ \ + -x old-gems/ \ + -x test/performance/ \ + -x test/scratch/ \ + \ + -x tc_.*\.rb \ + -x ts_all.rb \ + \ + $* diff --git a/lib/libclimate.rb b/lib/libclimate.rb index 7bdfd02..7e25b75 100644 --- a/lib/libclimate.rb +++ b/lib/libclimate.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true # ######################################################################## # # File: libclimate.rb # # Purpose: Top-level include for libclimate.Ruby library # # Created: 13th July 2015 -# Updated: 14th May 2016 +# Updated: 15th August 2026 # # Home: http://github.com/synesissoftware/libCLImate.Ruby # diff --git a/lib/libclimate/climate.rb b/lib/libclimate/climate.rb index 987c2c5..74b2710 100644 --- a/lib/libclimate/climate.rb +++ b/lib/libclimate/climate.rb @@ -1,11 +1,11 @@ - +# frozen_string_literal: true # ######################################################################## # # File: lib/libclimate/climate.rb # # Purpose: Definition of the ::LibCLImate::Climate class # # Created: 13th July 2015 -# Updated: 30th July 2026 +# Updated: 15th August 2026 # # Home: http://github.com/synesissoftware/libCLImate.Ruby # diff --git a/lib/libclimate/libclimate.rb b/lib/libclimate/libclimate.rb index 852fe0c..cf7fb8d 100644 --- a/lib/libclimate/libclimate.rb +++ b/lib/libclimate/libclimate.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true # ######################################################################## # # File: libclimate/libclimate.rb # # Purpose: Main file for libclimate.Ruby library # # Created: 13th July 2015 -# Updated: 10th August 2024 +# Updated: 15th August 2026 # # Home: http://github.com/synesissoftware/libCLImate.Ruby # diff --git a/lib/libclimate/version.rb b/lib/libclimate/version.rb index 2bd746d..f67c576 100644 --- a/lib/libclimate/version.rb +++ b/lib/libclimate/version.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true # ######################################################################## # # File: libclimate/version.rb # # Purpose: Version for libclimate.Ruby library # # Created: 13th July 2015 -# Updated: 30th July 2026 +# Updated: 15th August 2026 # # Home: http://github.com/synesissoftware/libCLImate.Ruby # @@ -44,7 +45,7 @@ module LibCLImate # Current version of the libCLImate.Ruby library - VERSION = '0.17.1' + VERSION = '0.17.2' private VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc: diff --git a/libCLImate.gemspec b/libCLImate.gemspec index dd30df0..0a476ee 100644 --- a/libCLImate.gemspec +++ b/libCLImate.gemspec @@ -4,21 +4,19 @@ # Purpose: Gemspec for libCLImate.Ruby library # # Created: 1st March 2019 -# Updated: 30th July 2026 +# Updated: 15th August 2026 # # ######################################################################### # $:.unshift File.join(File.dirname(__FILE__), 'lib') -require 'libclimate' +require 'libclimate/version' -require 'date' Gem::Specification.new do |spec| spec.name = 'libclimate-ruby' spec.version = LibCLImate::VERSION - spec.date = Date.today.to_s spec.summary = 'libCLImate.Ruby' spec.description = <= 2.0', '< 4' ] - spec.add_runtime_dependency 'clasp-ruby', [ '~> 0.23', '>= 0.23.0.2' ] - spec.add_runtime_dependency 'xqsr3', [ '~> 0.39' ] + spec.metadata = { + 'bug_tracker_uri' => 'https://github.com/synesissoftware/libCLImate.Ruby/issues', + 'changelog_uri' => 'https://github.com/synesissoftware/libCLImate.Ruby/blob/master/CHANGES.md', + 'homepage_uri' => 'https://github.com/synesissoftware/libCLImate.Ruby', + 'source_code_uri' => 'https://github.com/synesissoftware/libCLImate.Ruby', + } + + spec.add_runtime_dependency "clasp-ruby", [ '~> 0.23', '>= 0.23.0.2' ] + spec.add_runtime_dependency "xqsr3", [ '>= 0.39.5', '< 1.0' ] - spec.files = Dir[ 'Rakefile', '{bin,examples,lib,man,spec,test}/**/*', 'README*', 'LICENSE*' ] & `git ls-files -z`.split("\0") + spec.files = Dir[ 'Rakefile', '{bin,examples,lib,man,spec,test}/**/*', 'README*', 'LICENSE*' ] & `git ls-files -z`.split("\0") end + + +# ############################## end of file ############################# # diff --git a/run_all_unit_tests.sh b/run_all_unit_tests.sh index 78126a7..6aea55b 100755 --- a/run_all_unit_tests.sh +++ b/run_all_unit_tests.sh @@ -8,9 +8,9 @@ # executing each rbenv version # # Created: 9th June 2011 -# Updated: 12th April 2024 +# Updated: 12th August 2026 # -# Copyright (c) Matthew Wilson, 2011-2024 +# Copyright (c) Matthew Wilson, 2011-2026 # All rights reserved # # Redistribution and use in source and binary forms, with or without @@ -53,144 +53,132 @@ while [ -h "$Source" ]; do [[ $Source != /* ]] && Source="$ScriptDir/$Source" done ScriptDir="$(cd -P "$( dirname "$Source" )" && pwd)" +Basename="$(basename "$Source")" # colours if command -v tput > /dev/null; then - RbEnvClr_Blue=${FG_BLUE:-$(tput setaf 4)} - RbEnvClr_Red=${FG_BLUE:-$(tput setaf 1)} - RbEnvClr_Bold=${FD_BOLD:-$(tput bold)} - RbEnvClr_None=${FD_NONE:-$(tput sgr0)} + SisClr_Blue=${FG_BLUE:-$(tput setaf 4)} + SisClr_Red=${FG_RED:-$(tput setaf 1)} + SisClr_Bold=${FD_BOLD:-$(tput bold)} + SisClr_None=${FD_NONE:-$(tput sgr0)} else - RbEnvClr_Blue= - RbEnvClr_Red= - RbEnvClr_Bold= - RbEnvClr_None= + SisClr_Blue= + SisClr_Red= + SisClr_Bold= + SisClr_None= fi -# special command-line handling ('--pwd') +# special command-line handling ('--pwd', '--rbenv-versions') ProjectDir="$ScriptDir" +ForwardArgs=() +FoundHelp= +RunRbEnvAllVersions= for arg in "$@" do case "$arg" in - --pwd) - - ProjectDir=$(pwd) - ;; - *) - - Arguments="$Arguments $arg" - ;; - esac -done - + --help) -# special command-line handling ('--rbenv-versions') -# rbenv handling - -RunRbEnvAllVersions= -Arguments= + FoundHelp=1 + ForwardArgs+=("$arg") + ;; + --pwd) -for arg in "$@" -do + ProjectDir=$(pwd) + ForwardArgs+=("$arg") + ;; + --rbenv-versions) - case "$arg" in + RunRbEnvAllVersions=1 + ;; + *) - --rbenv-versions) - - RunRbEnvAllVersions=1 - ;; - *) - - Arguments="$Arguments $arg" - ;; + ForwardArgs+=("$arg") + ;; esac done -if [ ! -z "$RunRbEnvAllVersions" ]; then - - if ! command -v rbenv > /dev/null; then +if [ ! -z "$FoundHelp" ]; then - >&2 echo "$0: ${RbEnvClr_Red}${RbEnvClr_Bold}rbenv${RbEnvClr_None} not detected" + RunRbEnvAllVersions= +fi - exit 1 - fi +if [ ! -z "$RunRbEnvAllVersions" ]; then - if [ ! -e "$ProjectDir/.ruby-version" ];then + if ! command -v rbenv > /dev/null; then - >&2 echo "$0: ${RbEnvClr_Red}${RbEnvClr_Bold}.ruby-version${RbEnvClr_None} file not detected" + >&2 echo "$0: ${SisClr_Red}${SisClr_Bold}rbenv${SisClr_None} not detected" - exit 1 + exit 1 fi exclusions=() if [ -e "$ProjectDir/.ruby-version-exclusions" ]; then - exclusion_lines=`cat "$ProjectDir/.ruby-version-exclusions"` - for line in $exclusion_lines; do + exclusion_lines=`cat "$ProjectDir/.ruby-version-exclusions"` + for line in $exclusion_lines; do - exclusions+=($line) - done + exclusions+=("$line") + done fi - echo "executing command line '${RbEnvClr_Blue}${RbEnvClr_Bold}$0 $Arguments${RbEnvClr_None}' with all Ruby versions ..." + echo "executing command line '${SisClr_Blue}${SisClr_Bold}$0 ${ForwardArgs[*]}${SisClr_None}' with all Ruby versions ..." - current=$(rbenv local) + current= + if [ -f "$ProjectDir/.ruby-version" ]; then - #echo "current version: $current" + current=$(tr -d '[:space:]' < "$ProjectDir/.ruby-version") + fi versions=() while IFS= read -r line; do - versions+=("$line") + versions+=("$line") done < <(rbenv versions --bare) - echo "versions: ${RbEnvClr_Blue}${RbEnvClr_Bold}${versions[*]}${RbEnvClr_None}; skipped versions: ${RbEnvClr_Blue}${RbEnvClr_Bold}${exclusions[*]}${RbEnvClr_None}; current version: ${RbEnvClr_Blue}${RbEnvClr_Bold}${current}${RbEnvClr_None}" + echo "versions: ${SisClr_Blue}${SisClr_Bold}${versions[*]}${SisClr_None}; skipped versions: ${SisClr_Blue}${SisClr_Bold}${exclusions[*]}${SisClr_None}; current version: ${SisClr_Blue}${SisClr_Bold}${current:-(none)}${SisClr_None}" result=0 - for version in ${versions[@]} + for version in "${versions[@]}" do - echo + echo - skip= + skip= - for exclusion in "${exclusions[@]}"; do + for exclusion in "${exclusions[@]}"; do - if [[ "$exclusion" == "$version" ]]; then + if [[ "$exclusion" == "$version" ]]; then - skip=1 - fi - done + skip=1 + fi + done - if [ "$skip" != "" ]; then + if [ "$skip" != "" ]; then - echo "skipping Ruby version ${RbEnvClr_Blue}${RbEnvClr_Bold}$version${RbEnvClr_None}:" - else + echo "skipping Ruby version ${SisClr_Blue}${SisClr_Bold}$version${SisClr_None}:" + else - echo "processing Ruby version ${RbEnvClr_Blue}${RbEnvClr_Bold}$version${RbEnvClr_None}:" + echo "processing Ruby version ${SisClr_Blue}${SisClr_Bold}$version${SisClr_None}:" - echo -e "\texecuting command line '$0 $Arguments' with Ruby version $version ..." - rbenv local $version + echo -e "\texecuting command line 'RBENV_VERSION=$version $0 ${ForwardArgs[*]}' with Ruby version $version ..." - if ! $0 $Arguments; then + if ! RBENV_VERSION="$version" "$0" "${ForwardArgs[@]}"; then - result=1 - fi + result=1 fi + fi done - rbenv local $current - exit $result fi @@ -199,6 +187,7 @@ fi Separate= DebugFlag= +PrependLib= WarningsFlag=-W0 for v in "$@" @@ -212,46 +201,58 @@ do ;; --help) - echo "USAGE: $Source { | --help | [ --debug ] [ --separate ] }" - echo - echo "flags:" - echo - echo " --help" - echo " shows this help and terminates" - echo - echo " --debug" - echo " executes Ruby interpreter in debug mode" - echo - echo " --pwd" - echo " executes from present working directory, rather than relative to the script directory" - echo - echo " --rbenv-versions" - echo " executes this script (with all other specified arguments) for each rbenv version (except those listed in the file .ruby-version-exclusions, if present)" - echo - echo " --separate" - echo " executes each unit-test in a separate program" - echo - echo " --warnings" - echo " executes Ruby interpreter in warnings mode" - echo - - exit + cat << EOF +USAGE: $Basename { | --help | [ --debug ] [ --lib ] [ --pwd ] [ --rbenv-versions ] [ --separate ] [ --warnings ]} + +flags: + + --help + shows this help and terminates + + --debug + executes Ruby interpreter in debug mode + + --lib + prepends the lib directory under the script's directory into RUBYLIB before executing + + --pwd + executes from present working directory, rather than relative to the script directory + + --rbenv-versions + executes this script (with all other specified arguments) for each rbenv version (except those listed in the file .ruby-version-exclusions, if present) + + --separate + executes each unit-test in a separate program + + --warnings + executes Ruby interpreter in warnings mode +EOF + + exit 0 + ;; + --lib) + + PrependLib=1 ;; --pwd) + # already-processed as special case above + ;; + --rbenv-versions) + # already-processed as special case above ;; --separate) Separate=true ;; - --warnings) + --warnings|--warn) WarningsFlag=-W2 #-W:performance ;; *) - echo "unrecognised argument; use --help for usage" + >&2 echo "unrecognised argument '$v'; use --help for usage" exit 1 ;; @@ -261,13 +262,30 @@ done # executing tests +if [ ! -z "$PrependLib" ]; then + + export RUBYLIB=$ProjectDir/lib:$RUBYLIB +fi + + if [ -z "$Separate" ]; then ruby $DebugFlag $WarningsFlag "$ProjectDir/test/unit/ts_all.rb" else - find "$ProjectDir" -name 'tc_*.rb' -exec ruby $DebugFlag $WarningsFlag {} \; + result=0 + + while IFS= read -r -d '' testfile; do + + if ! ruby $DebugFlag $WarningsFlag "$testfile"; then + + result=1 + fi + done < <(find "$ProjectDir" -name 'tc_*.rb' -print0) + + exit $result fi + # ############################## end of file ############################# #