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

Refactor html and page serveing logic into modules #593

Merged
merged 9 commits into from Dec 4, 2023

Conversation

technicalpickles
Copy link
Contributor

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 and HTML 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 named serve_, 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.

lib/mini_profiler.rb Outdated Show resolved Hide resolved
Copy link
Collaborator

@nateberkopec nateberkopec left a 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.

@@ -94,6 +94,7 @@ def create_fake_snapshot(method, path, duration, started_at)
end
end

Rack::MiniProfiler.config.enable_advanced_debugging_tools = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated?

Copy link
Contributor Author

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.rb Show resolved Hide resolved
class MiniProfiler
module Actions
def serve_snapshot(env)
self.current = nil
Copy link
Collaborator

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.

@nateberkopec nateberkopec merged commit 570809b into MiniProfiler:master Dec 4, 2023
@technicalpickles technicalpickles deleted the extract-html branch January 9, 2024 13:21
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.

None yet

2 participants