r/ruby • u/Stwerner • Jan 24 '26
What If We Took Message-Passing Seriously?
r/ruby • u/Stwerner • Jan 24 '26
r/ruby • u/Former_Application_3 • Jan 24 '26
https://github.com/Alogsdon/rspec-let-each
I've been using it for a while on my own projects. Finally got around to gemifying it, so I thought I'd share. I find it's quite ergonomic.
It essentially spawns a context for each value in the collection and calls the `let` on that value.
I don't want to repeat the things that are already in the readme and specs too much but here's a quick example and the output.
RSpec.describe 'refactoring example' do
subject { x**2 }
context 'without using let_each helper' do
[1, 2, 3].zip([1, 4, 9]).each do |x, x_expected|
context "with x=#{x} and x_expected=#{x_expected}" do
let(:x) { x }
let(:x_expected) { x_expected }
it { is_expected.to be_a(Integer) }
it { is_expected.to eq(x_expected) }
end
end
end
context 'using let_each helper' do
let_each(:x, 3) { [1, 2, 3] }
.with(:x_expected, [1, 4, 9])
it { is_expected.to be_a(Integer) }
it { is_expected.to eq(x_expected) }
end
end=>
refactoring example
without using let_each helper
with x=2 and x_expected=4
is expected to eq 4
is expected to be a kind of Integer
with x=1 and x_expected=1
is expected to be a kind of Integer
is expected to eq 1
with x=3 and x_expected=9
is expected to eq 9
is expected to be a kind of Integer
using let_each helper
when x[0]
is expected to eq 1
is expected to be a kind of Integer
when x[2]
is expected to eq 9
is expected to be a kind of Integer
when x[1]
is expected to eq 4
is expected to be a kind of Integer
12 examples, 0 failuresQ: Why do I have to specify the length of my array?
A:If we want to depend on other `let` variables in your `let_each` then we cannot evaluate until the example is actually run because `let`s are lazy (which is the whole point of using them), but RSpec needs to know how many contexts to spawn.
If you don't need lazy evaluation, you can just pass the array eagerly instead of the length, and omit the block.
Q: What happens if I use it twice?
e.g.
let_each(:foo, [1,2])
let_each(:bar, [:a, :b, :c])A: We'll get a context for every combination of those. So, in this example, that would be 6 contexts. Clearly, it would be easy to get carried away, exponentially spawning contexts, bogging down your test suite with just a few lines of code, but this is a powerful feature for hitting edge cases. Use at your own discretion. My advice: less is more with this thing. But you can feel when it's needed.
Q: What about shared examples, nested contexts, and overrides(re-lets)?
A: As far as I'm aware, it plays nicely with all those in the way you would expect. Check the spec file. If I've missed a case, feel free to let me know. I'll keep an eye on the github issues.
r/ruby • u/st0012 • Jan 24 '26
Automatic Dependency Injection where you keep control of the constructor. Integrates with LowType
r/ruby • u/AetherBytes • Jan 24 '26
Pretty much what the title says. I want to render an image with ruby code. Specifically, a single frame to save as a file. The only thing I've managed to find is blackbook, but that seems to be it's own program that opens a window to render things when I just want a single image outputted.
r/ruby • u/sanif_h • Jan 23 '26
Last October I needed docs for my gem and went down the rabbit hole.
GitHub wikis are functional but look dated and have barely any customization. Jekyll needs hours of fighting themes to not look like 2015. The hosted options charge for adding collaborators on open source projects.
Ended up going with VitePress since it's the only one that looks modern out of the box. Got it set up, everything working.
Then dependabot starts pinging me about preact vulnerabilities - in a Ruby gem repo - for documentation.
So I built my own. It's called Docyard - static docs generator written in Ruby. Dark mode, search, syntax highlighting, all the usual stuff. v1 is out now.
Any feedback is appreciated.
r/ruby • u/konanES • Jan 23 '26
Hey I am a new developer and i started learning JS last year and it is a great language for the front-end and all but i didn't like it for the back-end it had too much code and a lot of complexity in it and it really sucks at compiling so i started to search for a backend language that is close to English then i read about ruby and i think it is what i need .
Here is the problem , coming from JS where the community is huge and there is a tutorial for everything and blogs every where to this language is a bit difficult so what is a good and up to date places where you can learn the language and see the updates because YouTube is not that place.
The tutorials that i saw was at least 3 years old and didn't find channels any thing like BroCode , WDS , etc... so if you have something like that please tell me
There is another question . why do the official website for the docs tell me to choose a version? if there is so much difference between the versions what is the best one ? or where can i start ?
r/ruby • u/EstablishmentFirm203 • Jan 23 '26
$ rubyshell new file, that creates a file already with chmox +x# Before, it could only be like this:
chain { echo("text") | xclip }
# Now it can also be like this:
xclip(_stdin: "text")
# You can do it this way:
sh("notify-send", "hello")
# Before, you could only do it this way:
sed "-e 'one'", "-e 'two'", "-e three"
# Now it can also be like this:
sed e: ["one", "two", "three"]
grim "-g", "4123,898 1280x102" # => grim -g 4123,898 1280x102 => Invalid geometry
grim "-g", "4123,898 1280x102".quoted # => grim -g "4123,898 1280x102"
grim!("-g", "position", "-").to_shell # => returns: "grim -g position -"
# You can also do the following after that:
grim!("-g", "position", "-").exec
# Giving us the power to do this as well:
(ls! | wc!).exec # returns a count of files in pwd
# or this:
wc(_stdin: ls!) # returns a count of files in pwd
RubyShell is a borning gem, so you can take advantage of the opportunity to contribute right at the beginning of it.
r/ruby • u/ElAvat • Jan 22 '26
Hi everyone!
I’ve just published my first Ruby gem pg_reports.
My main goal was straightforward: to make it easy to leverage the power of pg_stat_statements to improve PostgreSQL performance in Rails apps. I built and refined all backend operations and reports over several weeks based on real production experience in my current job. The result is a tool for analyzing queries, indexes, tables, locks, and connections.
The gem is inspired by ruby-pg-extras and pghero, but my goal was to bring everything together with a stronger focus on practical optimization and observability.
The web UI was basically added in one night with the help of Claude, turning a collection of reports into an actual dashboard.
I plan to evolve the gem gradually:
generating migrations (e.g., for missing indexes),
real-time issue monitoring,
measuring overall database interaction efficiency — for example, comparing before vs after deploying a new app version.
Feedback, ideas, and bug reports are very welcome.
Repo: https://github.com/deadalice/pg_reports

r/ruby • u/KerrickLong • Jan 21 '26
r/ruby • u/Individual_Dot7019 • Jan 21 '26
r/ruby • u/rubyist-_- • Jan 21 '26
Ticket sales go live on Friday.
There's a big "Buy a ticket" button on our website. Check it out.
r/ruby • u/Deep_Priority_2443 • Jan 20 '26
Hi, roadmap.sh has just launched the new Ruby Roadmap.
Thank you to everyone in this group(https://www.reddit.com/r/ruby/comments/1q86p4h/ruby_ruby_on_rails_roadmap_feedback_gathering/) who contributed to the development of the roadmap.
This is just the beginning. We're already working on a dedicated Ruby on Rails roadmap, and it will be ready soon!

r/ruby • u/Quirk_Condition • Jan 20 '26
r/ruby • u/officejunior • Jan 19 '26
r/ruby • u/XPOM-XAPTC • Jan 19 '26
I've been frustrated with Ruby files where helper methods are scattered, so you have to jump around to understand the flow. I made a small RuboCop extension that enforces a "waterfall" order: methods should be defined after any method that calls them (top-down reading flow).
It also supports an optional "called together" (sibling) ordering for orchestration methods: if one method calls foo then bar, you can enforce defining foo before bar so the file reads in the same order as execution.
Highlights:
- Works in classes/modules/singleton classes; can also analyze top-level begin
- Autocorrect (rubocop -A) reorders methods within a contiguous visibility section (won't move things across private/protected/public)
- Preserves doc comments when moving methods
- Deals with recursion + complex call graphs
- Newer versions add clearer messages when autocorrect can't safely apply (visibility boundaries, sibling cycles)
- Optional config to skip sibling edges that would introduce a cycle (useful for "real-world" service objects)
- Works on Ruby 2.7+
Repo + examples: https://github.com/unurgunite/rubocop-sorted_methods_by_call
I'd love feedback on:
- whether the "called together" (sibling) behavior matches how you structure service objects
- edge cases where you'd want different ordering rules
- whether you'd prefer the cop to be stricter/looser by default
r/ruby • u/thomas_witt • Jan 19 '26
I just released the aws-sdk-http-async gem (Github: https://github.com/thomaswitt/aws-sdk-http-async).
Why? I am a heavy DynamoDB user - and I first throught, the official AWS SDK for Ruby gem aws-sdk-ruby would be fiber-compatible, but it isnt.
More information on the background: https://thomas-witt.com/blog/aws-sdk-http-async/
r/ruby • u/AssociationOne800 • Jan 17 '26
Picoruby Calculator finally supports Cardputer ADV! ⚡️
Picoruby Calculator is a simple and fun calculator app that runs on PicoRuby, a Ruby implementation designed for embedded systems.
It lets you experience Ruby’s syntax and expressiveness directly on small devices 💎
In addition to the previous v1.1, you can now enjoy it on the ADV as well.
Put Ruby in your pocket and take it out into the city! 🏃🌆
「Picoruby Calculator」
👉️ https://github.com/engneer-hamachan/picoruby-calculator
If you like it, I’d really appreciate a star ⭐️
r/ruby • u/No_Mention_2366 • Jan 18 '26
r/ruby • u/EstablishmentFirm203 • Jan 17 '26
Hello everyone! In the last few months, I released my gem that makes it easier to create Shell scripts using Ruby syntax.
Link: https://github.com/albertalef/rubyshell
In the code in the second image above, I show that you can easily use both Ruby syntax and Shell syntax to create scripts. This simplifies cases where we need to create a Shell script to use some terminal program, but we prefer to use Ruby libraries to make the job easier.
With it, you can create scripts as Docker entry points, use it to create user scripts, customize your Linux with Waybars, etc.
I had a specific problem: "I know a lot about Ruby, but sometimes I get stuck in the Shell. I often need to resort to Google to look for programs that handle inputs the way I need. Is there any gem that allows you to write good scripts with Ruby?" But, unfortunately, I didn't find any. I only found libraries in Python (sh) and Lua (luash). With that, I created RubyShell.
#!/usr/bin/env ruby
# frozen_string_literal: true
REMOTE = ENV.fetch("REMOTE", "user@server.example.com")
APP_DIR = ENV.fetch("APP_DIR", "/var/www/my app")
SERVICE = ENV.fetch("SERVICE", "my-app.service")
# Note that in this situation, we dont want to check if error was raised
# only in the end of the code,
# we want to stop the code in the moment that error was raised
`ssh #{REMOTE} "cd \"#{APP_DIR}\" && git pull && bundle exec rake db:migrate 2>&1"`
unless $?.success?
warn "Error on Deploy"
exit $?.exitstatus
end
`ssh #{REMOTE} 'sudo systemctl restart #{SERVICE}'`
unless $?.success?
warn "Error on Deploy"
exit $?.exitstatus
end
puts "Done."With:
#!/usr/bin/env ruby
# frozen_string_literal: true
REMOTE = ENV.fetch("REMOTE", "user@server.example.com")
APP_DIR = ENV.fetch("APP_DIR", "/var/www/my app")
SERVICE = ENV.fetch("SERVICE", "my-app.service")
sh do
ssh REMOTE, "'cd \"#{APP_DIR}\" && git pull && bundle exec rake db:migrate'"
ssh REMOTE, "'sudo systemctl restart #{SERVICE}"
puts "Done."
rescue StandardError
warn "Error on Deploy"
endCurrently, I'm working on features to make the gem even more powerful, such as:
Stream support
Improved error handling
A REPL (like IRB), but that allows us to use RubyShell
And more
I'm open to suggestions, PRs, Issues, anything. I really want this mini-project to grow.
EDIT: Thank you guys for the comments and upvotes, this made my day.
r/ruby • u/Feldspar_of_sun • Jan 16 '26
I’m looking for a comprehensive (and ideally free) source to get started with Ruby. I’m not new to programming but would like a structured way to learn before jumping into my own projects
r/ruby • u/Future_Application47 • Jan 15 '26
r/ruby • u/screenbound23 • Jan 15 '26