1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
# Buff Ignore
[](http://badge.fury.io/rb/buff-ignore) [](https://travis-ci.org/sethvargo/buff-ignore) [](https://gemnasium.com/sethvargo/buff-ignore) [](https://codeclimate.com/github/sethvargo/buff-ignore)
Buff::Ignore is a Ruby helper library for parsing and managing an ignore file (such as a `.gitignore` or `chefignore`). It uses [`File#fnmatch`](http://www.ruby-doc.org/core-2.0/File.html#method-c-fnmatch). It includes helpful methods for apply ignores to a file list.
## Installation
Add buff-ignore to your `Gemfile`:
```gemfile
gem 'buff-ignore'
```
And then execute the `bundle` command to install:
```
$ bundle
```
Or install buff-ignore directly:
```
$ gem install buff-ignore
```
## Usage
Buff::Ignore is designed to be used as a library. First, you must require it:
```ruby
require 'buff/ignore'
```
Next, create an instance of an ignore file:
```ruby
ignore = Buff::Ignore::IgnoreFile.new('/path/to/ignore/file')
```
_(If the file does not exist, an exception will be raised)_
Finally, apply the `ignore` to a list of files:
```ruby
list = Dir['**/*']
result = ignore.apply(list)
```
You can also destructively apply changes. This will modify the receiving argument `list`:
```ruby
ignore.apply!(list)
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## License & Authors
- Author: Seth Vargo (sethvargo@gmail.com)
```text
Copyright 2013 Seth Vargo <sethvargo@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
|