-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
@mention allow for custom regex to identify usernames. #157
@mention allow for custom regex to identify usernames. #157
Conversation
brittballard
commented
Oct 6, 2014
- This allows for easier customization of the mention patter regex
@jch I believe this is the modification discussed in the previous PR. |
@brittballard while this does allow a user to overload the Care to give that implementation a go? |
Ah, yes that looks very nice. Sure I'll resubmit. Thank you. |
3632c23
to
c468f29
Compare
@jch what do you think of this? I set it up to only allow for modification of the username to avoid confusion. Allowing someone to change the entire regex was problematic because the rest of the class depends on the presence of the "@", which makes sense to me. |
Downside to this is that a new regex object is created everytime the filter On Monday, October 6, 2014, Britt Ballard [email protected] wrote:
Jerry Cheung |
@jch that's a good point. Sure I'll look into taking that route. |
3b06874
to
effa0fd
Compare
@jch what do you think of this solution? |
Working on that bad test now. |
effa0fd
to
b639cca
Compare
b639cca
to
8e0915b
Compare
$ # end of line | ||
) | ||
/ix | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a simple and clever solution. 👍
Are the tests passing for you? The Hash#new docs suggest that you're responsible for storing the value. I haven't tried running it yet though.
It is the block’s responsibility to store the value in the hash if required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test do currently pass. I read that as telling me I had to include hash[key]
in the block (line 46). If there is a simpler or cleaner way I'm all for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
8e0915b
to
9e2a96c
Compare
expression = HTML::Pipeline::MentionFilter::MentionPatterns[/test/] | ||
|
||
assert_same expression, HTML::Pipeline::MentionFilter::MentionPatterns[/test/] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems too tied to the implementation to me. It's testing the definition of Hash.new
rather than actual behavior. I think we can do without it. I think you can roll this test into the one below, and assert that filtering with the default regex leads to a pattern_count
of 1, and filtering again with a custom regex gives a pattern_count
of 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'll make the change.
@brittballard it's coming together! I noticed you were doing force pushes for the changes, which is fine if you prefer it. But I don't have any problems with having the intermediate commits either. Your call. |
* This allows for easier customization of the usernam mention pattern regex
9e2a96c
to
57f6cce
Compare
@jch I have gotten into the dangerous habit of using |
@brittballard I like using amend also, but limit myself to only commits that haven't been pushed up yet. |
That's a good policy. |
Ready for review again, or were there other changes you wanted to make? |
Ready for review, sir. |
👍 slated for 2.0 release 🍻 |
…rscore @mention allow for custom regex to identify usernames.