Skip to content

Add JSON format for compatibility of a gem#148

Merged
JuanVqz merged 7 commits intomainfrom
feature/JSON-response
Mar 24, 2026
Merged

Add JSON format for compatibility of a gem#148
JuanVqz merged 7 commits intomainfrom
feature/JSON-response

Conversation

@etagwerker
Copy link
Copy Markdown
Member

@etagwerker etagwerker commented Mar 20, 2026

Hi there,

I think it'd be useful to have a JSON format responder, in case an AI agent wants to consume this information.

Please check it out.

Thanks!

@sentry
Copy link
Copy Markdown

sentry bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.00%. Comparing base (b945c45) to head (276fe61).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
app/controllers/gemmies_controller.rb 80.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #148      +/-   ##
==========================================
+ Coverage   86.88%   87.00%   +0.11%     
==========================================
  Files          48       48              
  Lines         694      708      +14     
==========================================
+ Hits          603      616      +13     
- Misses         91       92       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a JSON response format for the existing gem “show” endpoint so external consumers (e.g., agents/tools) can fetch gem compatibility information per Rails version.

Changes:

  • Add respond_to handling in GemmiesController#show for format.json, including JSON 404 behavior.
  • Implement a JSON payload builder that returns gem name plus compatibility entries per Rails release.
  • Add request specs covering existing gem (compatible/incompatible), pending/no compats (“checking”), and not-found behavior.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
spec/requests/api/compats_spec.rb Adds request coverage for the new .json response behavior and payload shape
app/controllers/gemmies_controller.rb Implements JSON responder + payload construction for gem compatibility
Gemfile.lock Adds an additional supported platform entry

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

etagwerker and others added 4 commits March 21, 2026 07:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz left a comment

Choose a reason for hiding this comment

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

I'll be honest, I don't like this rescue in the show action and the test in the api since the controller is not in the api folder. i would have used jbuilder as well, but you have a coupon for today's review.

it "returns not found and lets Rails handle the response" do
get "/gems/nonexistent_gem_12345.json"

expect(response).to have_http_status(:not_found)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rails is handling the 404

Replace find_by_name! + rescue with find_by_name + conditional
to avoid using exceptions for control flow. Return head :not_found
for HTML requests when the gem is not found. Remove the
corresponding "gem does not exist" test case.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@etagwerker etagwerker requested a review from JuanVqz March 24, 2026 02:37
@etagwerker
Copy link
Copy Markdown
Member Author

@JuanVqz Thanks for your review. Valid points. I just addressed them.

Please let me know if you see anything else.

@JuanVqz JuanVqz merged commit 1676056 into main Mar 24, 2026
1 check passed
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.

3 participants