pathspec-ruby is a Ruby gem that matches .gitignore-style path specifications. It follows the full gitignore syntax — negation patterns, directory-only rules, glob wildcards, and precedence ordering.

Ported from the Python pathspec library, it ships a CLI (pathspec-rb) and a Ruby API:

gitignore = PathSpec.from_filename('.gitignore')
gitignore.match 'coverage/index.html'   # => true
gitignore.match 'important.txt'         # => false (negated)
gitignore.match_tree '/src/repo'        # returns matching file paths

Published as the pathspec gem on RubyGems. Supports Ruby 3.2 through 4.0. Apache 2.0 licensed.