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

Support exclude filters #83

Merged
merged 2 commits into from
Nov 16, 2022
Merged

Support exclude filters #83

merged 2 commits into from
Nov 16, 2022

Conversation

jntn-st
Copy link
Contributor

@jntn-st jntn-st commented Apr 21, 2019

This implements a new configuration option "exclude" for a regexp group. #29

@coveralls
Copy link

coveralls commented Apr 21, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 9a0cc9f on jntn-st:excludefilters into 8c13dd8 on nning:master.

@jntn-st
Copy link
Contributor Author

jntn-st commented Apr 30, 2019

@nning, just a friendly reminder to take a look at this PR.

@nning
Copy link
Owner

nning commented May 4, 2019

Thank you very much for your contribution! I just made some minor code styling comments and will test your feature after you made those changes. Would you also add tests, please (e.g. in spec/feed_spec.rb)?

@jntn-st
Copy link
Contributor Author

jntn-st commented May 4, 2019

I can't find the code styling comments you are referring to. I'm quite new to github, so it may just be that I don't know where to look for them. Sure, I will add tests, it is a reasonable requirement.

@@ -103,7 +103,7 @@ def process_link(feed, item)
# The link is not in +@seen+ Array.
unless @seen.include?(link)
# Skip if filter defined and not matching.
unless feed.matches_regexp?(item.title)
unless feed.matches_regexp?(item.title) && !(feed.exclude?(item.title))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unless feed.matches_regexp?(item.title) && !(feed.exclude?(item.title))
unless feed.matches_regexp?(item.title) && !feed.exclude?(item.title)

return unless regexps.is_a?(Array)

regexps.each do |regexp|
matcher = regexp['matcher']
path = regexp['download_path']
exclude = regexp['exclude']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exclude = regexp['exclude']
exclude = regexp['exclude']

@nning
Copy link
Owner

nning commented Sep 24, 2019

I'm sorry, I just realized, I did not submit my review. Would you please add tests? Thanks again for your contribution!

Copy link
Owner

@nning nning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a configuration example in the README.

@@ -41,21 +42,30 @@ def matches_regexp?(title)
@regexp.nil? || !(title =~ @regexp).nil?
end

def exclude?(title)
@excludes.each do |regexp, exclude|
return title =~ to_regexp(exclude) if title =~ to_regexp(regexp)
Copy link
Owner

@nning nning Nov 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of title =~ to_regexp(exclude) should only be evaluated once.

@GnaXi
Copy link

GnaXi commented May 8, 2020

When can we expect this pull request to be merged?
It's a MUCH needed feature! :)

@nning nning mentioned this pull request Nov 16, 2022
@nning nning merged commit 5c5a21d into nning:master Nov 16, 2022
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

Successfully merging this pull request may close these issues.

4 participants