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
Refactor html and page serveing logic into modules #593
Refactor html and page serveing logic into modules #593
Conversation
… suffix. Move those to their own actions module
…were missing client_settings
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.
My comments are all nits, so marking as approve.
website/sample.rb
Outdated
@@ -94,6 +94,7 @@ def create_fake_snapshot(method, path, duration, started_at) | |||
end | |||
end | |||
|
|||
Rack::MiniProfiler.config.enable_advanced_debugging_tools = true |
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.
Unrelated?
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.
Sorta. I didn't intend to commit this, but I needed to add it to be able to test everything. I can extract it to another PR though.
lib/mini_profiler/actions.rb
Outdated
class MiniProfiler | ||
module Actions | ||
def serve_snapshot(env) | ||
self.current = nil |
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.
Maybe should be top level as well.
Another attempt to try to cleanup MiniProfiler. I started trying to group similar logic together to pull out to its own module, and the ones that stood out had to do with serving an HTTP response directly (ie actions) and generating HTML for said response.
That lead me to introducing
Actions
andHTML
modules. This is just grouping methods into logical modules and including them, so it really change much functionally. It does let you see similar methods a lot closer together.For
Actions
, most of the methods were already namedserve_
, so I moved those to Actions. Anything else that was serving up a request directly was moved there and named as well.I changed
serve_html
a little because despite the name, it does serve up other things. I hoisted those conditionals for snapshot, results, and flamegraphs out of the method to the one place where serve_html was called.