-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add :http_verbs option #50
base: master
Are you sure you want to change the base?
Conversation
Example: http_verbs: %w[get head] http_verbs: %w[post get head put patch delete] http_verbs: :all
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 looking very promising! Thanks for a quick turnaround on this issue. 🙏 I left few comments. Could you please also use double-quoted strings everywhere? Sorry for the confusion, there is a mixture of both styles but going forward I'd like to keep them double-quoted.
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.
Things are looking good! Would you please address the remaining 'houndci' style issues? There are still some single-quoted strings left, arrays that can be converted to symbol arrays etc. Also, there are some tests failures in Rails 3.2
. I know it's old Rails - sorry! But I don't want to break things in this release. I will consider dropping support later on in a separate release. Thank you!
4680972
to
64aa93d
Compare
9a033f2
to
e28ea0f
Compare
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.
Thank you Hopper for making these changes! Things are looking really good. There is a small style issue left.
There is one dilemma that I'm 'debating' which is the name of the parameter :http_verbs
. The verbs
term is kind of inaccurate because these are not all verbs and also it is rather 'colloquial' usage. The HTTP rfc talks about HTTP methods. It feels more appropriate to use methods
. I'm equally debating whether it should be request_methods
or http_methods
? What're your thoughts on this? I want to make sure we pick the best configuration name.
Maybe the |
def initialize(name, url, options = {}) | ||
@name = name || raise_name_error | ||
@url = url || raise_url_error | ||
@match = options.fetch(:match, Loaf.configuration.match) | ||
@request_methods = options.fetch(:request_methods, Loaf.configuration.request_methods) |
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.
Metrics/LineLength: Line is too long. [92/80]
current = current_crumb?( | ||
path, | ||
options.fetch(:match) { crumb.match }, | ||
request_methods: options.fetch(:request_methods) { crumb.request_methods } |
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.
Metrics/LineLength: Line is too long. [84/80]
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.
Apologies for not having replied to your request for review earlier. I took a break from open-source. I left a few comments. Let's move this PR forward.
Glad to hear that! I'll get it done sometime this week. |
@@ -65,8 +69,8 @@ def breadcrumb_trail(options = {}) | |||
# the pattern to match on | |||
# | |||
# @api public | |||
def current_crumb?(path, pattern = :inclusive) | |||
return false unless request.get? || request.head? | |||
def current_crumb?(path, pattern = :inclusive, request_methods: Loaf.configuration.request_methods) |
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.
Metrics/LineLength: Line is too long. [103/80]
ba3602e
to
c5d8971
Compare
c5d8971
to
b94519a
Compare
I just fixed all those style issues. Also fixed a wrong proc config test issue |
@@ -3,10 +3,12 @@ class Article < Struct.new(:id, :title); end | |||
class CommentsController < ApplicationController | |||
|
|||
breadcrumb lambda { |c| c.find_article(c.params[:post_id]).title }, | |||
lambda { |c| c.post_comments_path(c.params[:post_id]) } | |||
lambda { |c| c.post_comments_path(c.params[:post_id]) }, |
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.
Style/Lambda: Use the -> { ... } lambda literal syntax for single line lambdas.
Are there plans to merge these changes? |
Describe the change
Add
:http_verbs
option to breadcrumb parametersWhy are we doing this?
When I use this gem on some legacy projects, I met a circumstance which I have to show breadcrumbs on POST/PATCH action. I tried to add an option
:http_only
at #49. But @piotrmurach suggest me to usehttp_verbs
.Benefits
Now the current breadcrumb can match with multiple HTTP methods