Skip to content

Take in Path, ruby and command calling from ProUtils - #3

Merged
trans merged 2 commits into
masterfrom
proutils-salvage
Nov 25, 2026
Merged

trans merged 2 commits into
masterfrom
proutils-salvage

Conversation

@trans

@trans trans commented Nov 25, 2026

Copy link
Copy Markdown
Member

What was worth keeping from ProUtils (a 2014 reworking of Ratch's utilities, being retired), fitted to Ratch's per-shell modes instead of ProUtils' global variables.

Ratch::Path

A Pathname that keeps to its shell's mode. Shell#path, #file, #dir, #work, #parent, #home and #root now return one.

Before this, shell.path('tmp').rmtree deleted the directory even in a dry run, because the shell handed out plain Pathnames. Now the writing methods (mkpath, rmtree, rename, chmod, write, delete and so on) do nothing in noop mode and are reported when tracing. Paths derived from one (+, parent, children, ...) keep the same shell. A Path is still equal to the Pathname of the same path. Files opened for writing with open are not covered.

Commands

  • Shell#ruby runs a command with the present Ruby.
  • Shell#cmd runs any method called on it as a command: shell.cmd.git 'status'. Several arguments are passed as they are, a final Hash becomes options, and a single String is a command line.
  • Ratch::Commands is the optional form of the same on the shell itself: shell.git 'status'. A shell has it with the :commands option (--commands for the ratch command) or by including the module. Only a program found on the PATH is taken as a command, so a misspelt method is still a NoMethodError.

Smaller things

  • The ratch command takes options before the script's name as well as after.
  • Array#to_list drops nils; Object#to_yamlfrag handles tagged documents and the end mark; FileTest.bin? no longer raises without a PATH.
  • Version 2.1.0, unreleased. 113 tests (26 new).

🤖 Generated with Claude Code

trans and others added 2 commits November 25, 2026 13:31
Path is a Pathname that keeps to its shell's mode, so the paths a shell
gives out no longer ignore noop and trace. Shell#ruby runs the present
Ruby, Shell#cmd runs any method called on it as a command, and the
optional Commands module does the same on the shell itself for programs
found on the PATH. The core extensions take ProUtils' later versions.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On Ruby 3.1 a child process can print a warning about duplicate default
gems, which is nothing to do with what is tested.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@trans
trans merged commit 21bb2f9 into master Nov 25, 2026
10 checks passed
@trans
trans deleted the proutils-salvage branch November 25, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant