r/ruby • u/jasonswett • 16h ago
Call Things What They Are
r/ruby • u/_joeldrapper • 12h ago
We just released the first beta of Phlex 3, which includes a special Ruby-to-Ruby just-in-time compiler, allowing us to optimise performance far beyond what’s possible at runtime.
The compiler starts from what’s actually loaded. It asks each component’s live methods where they were defined, parses those files with Prism and turns them into a syntax tree.
Then it walks the tree and decides what each call really means by asking the running program: is div still Phlex’s div, or has someone overridden it, refined it or mixed something over it? Is that constant still the string it was? Each call we can prove is ours is replaced with a node that just appends text. Everything else is left as it was.
Next comes fusing: neighbouring appends merge, so a run of static elements becomes a single string, escaped and serialised once.
Finally, the tree is formatted back into Ruby, with a source map so that errors point to your original file and line, and this is evaluated in place of the original methods.
I posted more details including some micro benchmark results. You can also see the full release notes on GitHub.
I don’t know if this is going to work or if we’re going to discover some new edge case we hadn’t thought of, but it looks promising so far and it’s been running in production with 465 components for over 24 hours without any issues.
A lesson from maintaining legacy Ruby on Rails apps.
r/ruby • u/nateberkopec • 1d ago
Vibe coded in an hour. Please send all feedback to https://github.com/nateberkopec/stylebench. If you wish there was a model here that I didn't include, go run it yourself!
We are happy to announce the release of JRuby 9.4.16.0, a sponsored release mostly containing third-party security updates. Users still on JRuby 9.4 are encouraged to update and sign up for support services at https://headius.com to assist with future releases and upgrading to JRuby 10.x.
JRuby 9.4.x targets Ruby 3.1 compatibility.
Thank you to our contributors this release, you help keep JRuby moving forward! @jessecai33, @mnpoonia
Updated several dependencies to pick up security fixes.
r/ruby • u/chrisrackstallion • 3d ago
**Edited to better explain my ramblings. Hopefully...
Morning all,
You ask a coding agent to refactor the comments view. It breaks reply nesting, and this spec fails:
it "shows replies nested under their parent" do
expect(page).to have_css(".comment .comment", text: "Nice post")
expect(page).to have_css(".comment[data-depth='1']")
endThe agent "fixes" the failure by deleting the second assertion. The suite is green. The only evidence is one hunk in a 600 line diff, and nothing tells you that this spec mattered more than the forty around it.
Tests protect your code, but nothing protects the tests. That matters once agents write both.
I've released agent_primitives, a gem that covers that gap. It has two parts.
1. You write down what the app must keep doing. Each capability gets a short doc with plain numbered sentences:
I1 — A reader can reply to any comment.
I2 — Replies show nested under their parent.2. You tag the specs that prove each sentence.
it "shows replies nested under their parent", intent: "comment_threads#I2" doThese are ordinary RSpec examples and they run as before. The tag is just metadata.
Now the same agent edit gets reported:
$ bundle exec agent_primitives guard --base main
spec/system/comment_threads_spec.rb
7:1 N the example proving comment_threads#I2 lost 1 assertion(s) — it still carries the tag while proving less of the clause [proof/weakened]If the agent deletes the example outright, the check that runs in CI fails:
$ bundle exec agent_primitives evals
docs/primitives/capabilities/comment_threads.md
9:1 E spec/system/comment_threads_spec.rb carries no `intent: "comment_threads#I2"` tag [evaluation/untagged]
1 capability, 4 clauses — 1 offenceRewording a sentence is reported too, so an agent can't change what the app is supposed to do without you seeing it.
A few other things it does:
It needs RSpec and an agent that can load skills.
gem "agent_primitives", group: :developmentSource and README: GitHub - pitch-sourcery/agent_primitives · GitHub
I extracted it from the harness I use every day on my own startup's Rails app. It's a 0.1.0, so tell me where it's confusing or wrong.
r/ruby • u/Much-Stable-449 • 7d ago
I've been working on a Ruby project called pinterest-dl and thought it would be nice to have a few other developers involved in it
It's a tool for extracting media URLs from Pinterest and downloading images and videos
I'd like to find a couple of Ruby developers who are interested in working on it together — things like improving the code, writing tests, fixing bugs and coming up with new ideas or features
You don't have to be an expert or have tons of experience
I'm just looking for people who enjoy Ruby and are interested in contributing to an open-source project
It would be nice to have a few people to share ideas with and build this thing together instead of working on everything alone :)
Here's the repo if you want to check it out:
https://github.com/monji024/pinterest-dl
Feel free to reach out if you're interested!
r/ruby • u/Mandarinez • 7d ago
r/ruby • u/andrewmcodes • 9d ago
New Remote Ruby episode is out!
This week Chris, David, and I talk about how AI is changing Ruby development, including:
- My five-file rule for AI-generated pull requests
- Stacked PRs and parallel AI coding sessions
- Automating dependency updates and security fixes
- RubyGems, Bundler, and Active Record improvements
How are you keeping AI-generated code manageable and reviewable?
r/ruby • u/127001-sweet-127001 • 11d ago
A method-count limit wouldn't flag this class:
class InvoiceService
def charge; @gateway.charge; end
def refund; @gateway.refund; end
def render; @template.render; end
def filename; @template.filename; end
endIt's only four methods. But charge/refund operate on one field, while render/filename operate on another. If you're looking for a possible payment/rendering split, that's a more interesting signal than the size alone.
I work on ArchUnitRuby, a free MIT-licensed gem. Its LCOM4 implementation counts connected groups of methods through shared fields. On this source it returns 2:
require 'archunit'
scope = ArchUnit.metrics('.')
.for_classes_matching('InvoiceService')
scope.lcom.lcom4.measure.each do |item|
puts "#{item.identifier}: #{item.value}"
endChange the four methods to charge, refund, void and status, all using @gateway, and the same measurement is 1. The method count is still four.
I wouldn't turn that into a universal "LCOM4 must equal 1" gate. A constructor touching both fields can connect these groups, and Ruby methods that collaborate through calls won't necessarily share a field. This implementation measures field sharing, not whether your domain model is good.
A useful thing to inspect, though
For me the interesting use is narrowing a review: find a service with separated groups, look at what each group does, then decide whether splitting it actually makes the code easier to change. The number starts that conversation; it doesn't settle it.
The measurement API shown here is in the published archunit gem, version 1.0.0.
r/ruby • u/Ok_Stomach6651 • 13d ago
r/ruby • u/ffmegaman • 13d ago
After work, I am always building my side projects, usually in Ruby and/or Rails. Over the years I have accumulated a lot of small web apps and now with AI, I'm building more apps at a faster rate. They all need error tracking, APM, and uptime monitoring. I don't want to have to keep paying for monitoring services, especially since my apps are all so small, so I decided I would just build one to handle all my errors, uptime, and APM needs.
I've open sourced the web app here https://github.com/creativesorcery/goodsorcery_web
And corresponding ruby client gem here https://github.com/creativesorcery/goodsorcery-ruby
It doesn't have all the bells and whistles, but I think it gets the job done at least for my needs. I did add an MCP endpoint there, so AI agents can query and investigate errors and APM data. I hope others will find it useful.
r/ruby • u/robbyrussell • 13d ago
r/ruby • u/127001-sweet-127001 • 13d ago
Store and ::Billing::Store aren't interchangeable names just because they end the same way. Once a Ruby project has nested namespaces, a dependency tool needs to account for where a reference lives.
I maintain ArchUnitRuby. Its opt-in constant analysis resolves known project definitions and records the dependency on the defining file, rather than treating every occurrence of the word Store as the same thing.
The supported lookup model includes lexical nesting and explicit root-qualified references. It also has limits: reopened definitions can be ambiguous, and dynamic constant operations aren't a license to guess which file owns a name.
I verified a qualified project-constant reference against a file boundary: it produced a violation, while unrelated code in the same selected file passed. The constant didn't need a matching require_relative to appear in the graph.
This is useful when import-only rules are too quiet for your Ruby codebase. Enable dependency_analysis: :imports_and_constants deliberately and review the documented lookup limits before treating the graph as complete.
r/ruby • u/Much-Stable-449 • 14d ago
I started this because downloading stuff from Pinterest can be surprisingly annoying.
Sometimes you just want the original image, sometimes it's a video, sometimes it's buried in a board, and sometimes the website decides to make a simple request way more complicated than it needs to be.
So I started building pinterest-dl.
A few things I wanted to solve:
It's not just a CLI either. I wanted it to work as a Ruby library, so it can be used in scripts and other applications too.
I'm sure there are things I could've done better, so I'd genuinely like to hear what other Ruby developers think about the implementation and API.
Repo: https://github.com/monji024/pinterest-dl
I thought this would be a tiny weekend project. Apparently, Pinterest had other plans.
r/ruby • u/Good_Flight1781 • 15d ago
Hi r/rails,
I spend most of my day in app/views, but editor support for templates has always felt limited compared to what I get in .rb files. So I built Ruby Templates, a free, MIT-licensed VS Code extension for ERB, Haml, and Slim. No extra gems required.
render "users/card" to open the partial. Completion covers partials, ViewComponents, *_path helpers, model columns, controller-defined @ivars, and t(".keys").Catches Rails issues, including some I kept running into during code reviews:
<% render "x" %> that doesn’t output anything, and the same issue with link_to and other helpers;<%= if … %> where <% if … %> was intended;binding.irb or debug left in a view;@ivar used inside a partial;locals:;render call in a loop that could use collection:;raw or html_safe used on user content;t(".key") missing from en.yml;data-controller reference with no matching Stimulus controller;button_to inside form_with, which creates nested forms.alt attributes, duplicate IDs, <a> tags without href, and “click here” link text..ruby-templates.toml. You can enable or disable rules by folder and opt into stricter formatting rules, such as a particular quote style or one attribute per line.npx @x-ror/ruby-templates check app/views and npx @x-ror/ruby-templates format --check.It works alongside Ruby LSP: Ruby LSP handles your .rb files, and Ruby Templates handles your templates.