Module: Metaclean
- Defined in:
- lib/metaclean/display.rb,
lib/metaclean.rb,
lib/metaclean/cli.rb,
lib/metaclean/mat2.rb,
lib/metaclean/qpdf.rb,
lib/metaclean/runner.rb,
lib/metaclean/version.rb,
lib/metaclean/exiftool.rb,
lib/metaclean/strategy.rb
Overview
The “policy” module: which tools to run for which file, and what counts as privacy-relevant if it survives a clean.
Keeping this logic in its own file means the runner doesn’t need to know about formats — it just asks Strategy.tools_for(path) and runs whatever comes back.
Defined Under Namespace
Modules: Display, Exiftool, Mat2, Qpdf, Strategy Classes: CLI, Error, Runner, ToolsMissing
Constant Summary collapse
- VERSION =
'2.0.0'
Class Method Summary collapse
-
.ensure_tools! ⇒ Object
Preflight: all three tools must be installed.
-
.safe_path(path) ⇒ Object
A path beginning with “-” is misread as an option by the tools we shell out to — e.g.
Class Method Details
.ensure_tools! ⇒ Object
Preflight: all three tools must be installed. We run them together for full coverage and to verify the strip, so a partial toolchain is not “good enough” — bail with one clear message naming what’s missing and how to install everything. Called once by the CLI before any inspect/clean work.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/metaclean.rb', line 48 def self.ensure_tools! missing = [] missing << 'exiftool' unless Exiftool.available? missing << 'mat2' unless Mat2.available? missing << 'qpdf' unless Qpdf.available? return if missing.empty? raise ToolsMissing, <<~MSG Missing required tool(s): #{missing.join(', ')} metaclean needs ExifTool, mat2 and qpdf together. Install all three: macOS: brew install exiftool mat2 qpdf Debian/Ubuntu: sudo apt install libimage-exiftool-perl mat2 qpdf Fedora: sudo dnf install perl-Image-ExifTool mat2 qpdf Arch: sudo pacman -S perl-image-exiftool mat2 qpdf Windows: use WSL2 (https://learn.microsoft.com/windows/wsl/install) + the Debian/Ubuntu line MSG end |
.safe_path(path) ⇒ Object
A path beginning with “-” is misread as an option by the tools we shell out to — e.g. exiftool’s ‘-config FILE` loads and runs arbitrary Perl. Open3 argument arrays bypass the shell, but NOT the invoked tool’s own option parser. Prefixing a leading-dash relative path with “./” makes it unambiguously a filename to every tool. Absolute paths and normal names pass through untouched. Used at every shell-out boundary.
39 40 41 42 |
# File 'lib/metaclean.rb', line 39 def self.safe_path(path) s = path.to_s s.start_with?('-') ? File.join('.', s) : s end |