Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doco update req: ignore vs filter #309

Closed
japgolly opened this issue Jul 27, 2012 · 9 comments
Closed

Doco update req: ignore vs filter #309

japgolly opened this issue Jul 27, 2012 · 9 comments

Comments

@japgolly
Copy link

Could somebody please update the doco to clarify the difference between ignore and filter?
It's unclear and filtering out and ignoring sounds like the same thing to me.

@rymai
Copy link
Member

rymai commented Jul 27, 2012

I think ignore is useful for ignoring specific folders (e.g. tmp, logs etc...) while filter is useful to narrow down the files to watch, usually by giving extension patterns (e.g. \.rb$).

Note that the two methods are complementary. For instance you could filter /\.rb$/ files and ignore /lib\/foo/ in which you could have .rb files.

@japgolly
Copy link
Author

Ahhh right, so to put it simply ignore is for directories and filter is for files. Is that right?

@rymai
Copy link
Member

rymai commented Jul 29, 2012

Hum, most of the time that's indeed the use case in practice, but I think you could ignore files and filter directories. @Maher4Ever do you confirm that?

@Maher4Ever
Copy link
Contributor

The ignore method can be used to exclude a file or a directory from the set of files being watched. Let's say you have used the watch method to monitor a directory but you are not interested in changes happening to images, you could use the ignore method to exclude them.

The filter method has a different purpose. It can be used to focus on, or rather filter the important files and directories without having to specify them by hand in the watch method. If you are watching multiple directories but only interested in changes to the ruby files, use the filter method.

As @rymai said above, both of them can be used for files and directories.

@rymai
Copy link
Member

rymai commented Jul 30, 2012

Thanks @Maher4Ever! Should we update the Listen's README with these clarifications?

@Maher4Ever
Copy link
Contributor

Yeah, I guess that should be done to stop confusing more people.

@japgolly
Copy link
Author

Thanks guys. ignore sounds very straightforward.
Let me just clarify again - so if I'm understanding you correctly then when watch is called to watch a directory (with no filename provided), filter specifies a regex that all files in that directory must match in order to be further processed (with non-matching files being ignored).

@rymai
Copy link
Member

rymai commented Jul 31, 2012

Yep I think you got it right!

@japgolly
Copy link
Author

japgolly commented Aug 2, 2012

Ok sweet. Thanks for the time explaining it to me guys!

I'll leave the issue open as a reminder to give the README some extra love. Just close whenever; don't mind me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants