|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +PathSpec Ruby - .gitignore-style pattern matching in Ruby |
| 4 | + |
| 5 | +## Project overview |
| 6 | + |
| 7 | +Ruby gem implementing .gitignore-style pattern matching with both library API and CLI tool. Supports Ruby 3.2-4.0.1 with comprehensive test coverage and multi-Ruby CI. |
| 8 | + |
| 9 | +## Setup commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Install mise (Ruby version manager) |
| 13 | +brew install mise # macOS |
| 14 | +# Other platforms: https://mise.jdx.dev/getting-started.html |
| 15 | + |
| 16 | +# Activate mise |
| 17 | +eval "$(mise activate zsh)" # or bash, fish, etc. |
| 18 | + |
| 19 | +# Install Ruby and bundler versions |
| 20 | +mise install |
| 21 | + |
| 22 | +# Install dependencies |
| 23 | +mise run install |
| 24 | +# or: bundle install |
| 25 | +``` |
| 26 | + |
| 27 | +## Testing |
| 28 | + |
| 29 | +```bash |
| 30 | +# Run all tests (lint, unit, integration, docs) |
| 31 | +mise run test |
| 32 | +# or: bundle exec rake |
| 33 | + |
| 34 | +# Unit tests only |
| 35 | +mise run test:unit |
| 36 | +# or: bundle exec rake spec |
| 37 | + |
| 38 | +# Integration tests (CLI) only |
| 39 | +mise run test:integration |
| 40 | +# or: bundle exec rake spec_integration |
| 41 | + |
| 42 | +# All specs (unit + integration) |
| 43 | +mise run test:all |
| 44 | +# or: bundle exec rake spec_all |
| 45 | + |
| 46 | +# Cross-Ruby matrix testing via Docker |
| 47 | +mise run test:matrix |
| 48 | +# or: bundle exec rake test_matrix |
| 49 | +``` |
| 50 | + |
| 51 | +## Code style |
| 52 | + |
| 53 | +- Use RuboCop 1.63.5 for linting |
| 54 | +- Method length limit: 69 lines |
| 55 | +- Use single quotes for strings without interpolation |
| 56 | +- Use `%w[]` for word arrays |
| 57 | +- Auto-fix with: `bundle exec rubocop --autocorrect` |
| 58 | +- For large data arrays: add `# rubocop:disable Metrics/MethodLength` |
| 59 | + |
| 60 | +## Build and release |
| 61 | + |
| 62 | +```bash |
| 63 | +# Build gem |
| 64 | +mise run build |
| 65 | +# or: gem build pathspec.gemspec |
| 66 | + |
| 67 | +# Generate documentation |
| 68 | +bundle exec rake docs |
| 69 | + |
| 70 | +# Development install |
| 71 | +rake install |
| 72 | +``` |
| 73 | + |
| 74 | +## Project structure |
| 75 | + |
| 76 | +``` |
| 77 | +pathspec-ruby/ |
| 78 | +├── lib/pathspec/ # Core library |
| 79 | +│ ├── pathspec.rb # Main PathSpec class |
| 80 | +│ └── patterns/ # Pattern implementations |
| 81 | +├── bin/pathspec-rb # CLI executable |
| 82 | +├── spec/ |
| 83 | +│ ├── unit/ # Library tests |
| 84 | +│ └── integration/ # CLI tests |
| 85 | +├── benchmarks/ # Performance tests |
| 86 | +├── docs/ # Documentation source |
| 87 | +├── Rakefile # Build tasks |
| 88 | +├── .tool-versions # Ruby/bundler versions |
| 89 | +└── pathspec.gemspec # Gem spec |
| 90 | +``` |
| 91 | + |
| 92 | +## Development workflow |
| 93 | + |
| 94 | +1. Make changes to `lib/` code |
| 95 | +2. Add/update tests in `spec/unit/` for library changes |
| 96 | +3. Add/update tests in `spec/integration/` for CLI changes |
| 97 | +4. Run `mise run test` - must pass before committing |
| 98 | +5. Fix any RuboCop offenses |
| 99 | +6. Test cross-Ruby with `mise run test:matrix` |
| 100 | +7. Commit with descriptive messages |
| 101 | + |
| 102 | +## CLI tool usage |
| 103 | + |
| 104 | +```bash |
| 105 | +bundle exec pathspec-rb -f .gitignore match "file.swp" |
| 106 | +bundle exec pathspec-rb -f .gitignore specs_match "file.swp" |
| 107 | +bundle exec pathspec-rb -f .gitignore tree ./src |
| 108 | +``` |
| 109 | + |
| 110 | +## Common issues |
| 111 | + |
| 112 | +**Bundler conflicts**: Always use `mise run install` to ensure correct versions from `.tool-versions` |
| 113 | + |
| 114 | +**RuboCop failures**: Auto-fix with `bundle exec rubocop --autocorrect`. Method length is common issue - extract large data arrays to separate methods with rubocop:disable comments |
| 115 | + |
| 116 | +**CI failures**: Check GitHub Actions. RuboCop and integration test failures are most common causes |
| 117 | + |
| 118 | +## Dependencies |
| 119 | + |
| 120 | +- **Runtime**: None (pure Ruby) |
| 121 | +- **Development**: rspec (~> 3.10), rubocop (~> 1.63.0), fakefs (~> 2.5), kramdown (~> 2.3), benchmark-ips (~> 2.0) |
0 commit comments