https://github.com/jimschubert/iggy
This repository is a mirror.
https://github.com/jimschubert/iggy
Last synced: over 1 year ago
JSON representation
This repository is a mirror.
- Host: GitHub
- URL: https://github.com/jimschubert/iggy
- Owner: jimschubert
- License: apache-2.0
- Created: 2017-01-05T02:17:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-06T14:53:25.000Z (about 9 years ago)
- Last Synced: 2025-02-15T05:46:39.046Z (over 1 year ago)
- Language: Java
- Homepage: https://gitlab.com/jimschubert/iggy/
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iggy
Iggy is an ignore file processor for java. It was originally a part of swagger-codegen.
[](https://gitlab.com/jimschubert/iggy/commits/master)
[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22iggy%22)
## Usage
Given an ignore file, for example `/your/directory/.ignore`:
```
# This is an example ignore file
# Match everything below this directory
path/to/dir/**
# Match all Test files with all extensions
**/*Test*.*
# Match files with one character filename and extension
**/?.?
# Match all files beginning with first or second
**/{first*,second*}
```
This file can be read and evaluated like this:
```java
IgnoreProcessor processor = new IgnoreProcessor("/your/directory");
processor.allowsFile(new File("path/to/dir/ignored"));//= false
processor.allowsFile(new File("other/path/to/dir/ignored"));//= true (DirectoryRule isn't implicitly recursive)
processor.allowsFile(new File("nested/test/SomeTest.java"));//= false
processor.allowsFile(new File("nested/a.b"));//= false
processor.allowsFile(new File("nested/abc.d"));//= true
processor.allowsFile(new File("nested/first.txt"));//= false
processor.allowsFile(new File("nested/second.txt"));//= false
processor.allowsFile(new File("nested/third.txt"));//= true
```
## Patterns
File patterns follow closely to that of `.gitignore`. All ignore patterns allow glob patterns supported by [java.nio.file.PathMatcher](https://docs.oracle.com/javase/tutorial/essential/io/find.html),
unless otherwise noted.
* Rooted file pattern: `/*.ext`
- Must exist in the root of the directory
- Must begin with a forward slash `/`
- Supports `*` or `*.ext` pattern
- Does not support `PathMatcher` patterns
* Directory Rule
- Matches against directories (`dir/`) or directory contents (`dir/**`)
- Must either end in `/` or `**`
* File Rule
- Matches an individual `filename` or `filename.ext`
- Supports all `PathMatcher` patterns
Similar to `.gitignore` processing, a double asterisk (`**`) can be used in place of a directory to indicate recursion.
For example:
```
path\to\**\file
```
matches both `path\to\some\file` and `path\to\some\nested\file`.
Single asterisks (`*`) match any characters within a pattern.
For example:
```
path\to\*file
```
matches both `path\to\your_file` and `path\to\my_file`, as well as `path\to\file`.
These are the base cases for most uses. For more details on supported glob patterns, see [What is a Glob?](https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob)
# License
Apache 2.0.
see [License](./LICENSE)