Ruby Icon

Ruby

Ruby is a scripting language designed for simplified object-oriented programming.
302 Stories
All Topics

David Heinemeier Hansson gist.github.com

A peek inside HEY's Gemfile 👀

DHH posted a gist sharing HEY’s Ruby dependencies for the curious. It’s a pretty stock Rails app with MySQL (?!) and Redis stores, Elasticsearch, and a few other niceties. One line that caught my eye was:

gem 'turbo', github: 'basecamp/turbo'

That points to a private repo, so there will probably be some new open source turbolinks stuff here real soon. Anything else in this Gemfile catch your interest?

Shopify Engineering Icon Shopify Engineering

Refactoring legacy code with the Strangler Fig pattern

This is an excellent refactoring story using one of Shopify’s core classes.

As you can imagine, one of the most critical areas in Shopify’s Ruby on Rails codebase is the Shop model. Shop is a hefty class with well over 3000 lines of code, and its responsibilities are numerous. When Shopify was a smaller company with a smaller codebase, Shop’s purpose was clearer: it represented an online store hosted on our platform. Today, Shopify is far more complex, and the business intentions of the Shop model are murkier. It can be described as a God Object: a class that knows and does too much.

They use Martin Fowler’s Strangler Fig pattern to achieve the refactoring. You may recall we discussed this on our episode with Amal Hussein.

Rails matestack.org

Rapidly create interactive UIs in pure Ruby

I like the why behind Matestack:

Implementing two separate systems (backend-api, frontend-app) is a pain: Two different code bases, two repositories to maintain, two different deployment schedules, two test environments, two everything… Being a small dev team, we decided not to adopt this modern web development complexity and decided to create… Matestack!

If you have 30 minutes and want an easy button to learn all about it, Jonas Jabari gave a talk on it at Ruby Unconf 2019.

Eileen Uchitelle github.blog

Running GitHub on Rails 6.0

Eileen Uchitelle shared the backstory of how they have GitHub running on Rails 6.0 just 1.5 weeks after its final release. 👏

As soon as we finished the Rails 5.2 upgrade last year, we started upgrading our application to Rails 6.0. Instead of waiting for the final release, we’d upgrade every week by pulling in the latest changes from Rails master and run all of our tests against that new version. This allowed us to find regressions quickly and early—often finding regressions in Rails master just hours after they were introduced. Upgrading weekly made it easy to find where these regressions were introduced since we were bisecting Rails with only a week’s worth of commits instead of more than a year of commits.

Piotr Murach github.com

tty-logger – readable, structured, beautiful logging in the terminal

A Ruby gem that significantly improves the situation with terminal logging as part of TTY Toolkit. It allows streaming of log data to any IO device (socket, file, etc…) with a highly customizable and pretty output to make key information stand out. You can limit the depth of the displayed data and specify the maximum size in bytes.

tty-logger – readable, structured, beautiful logging in the terminal

Joel Ambass joel.am

Making monkey patches sane again

Joel Ambass with some good thoughts (and a tiny gem) on monkey patching in Ruby

Applied correctly and with care, monkey patching becomes a powerful tool that every ruby programmer can benefit from.

I really dig his idea and implementation of a version guard as my main source of trepidation when monkey patching around a bug is not knowing if/when I can remove my patch.

Vladimir Dementyev Evil Martians

Rails 6: B-sides and rarities

Discover the lesser-known parts of the next major framework upgrade, appealing to mature applications that have been around for a while. Instead of focusing on “greatest hits,” we will walk you through B-sides and rarities that make this new release enjoyable in subtler ways.

What B-sides and rarities are Vladimir speaking of?

While the most-advertised Rails 6 features like Action Mailbox and Action Text steal all the spotlight, it is unlikely that a real-life Rails application that has been around for a while will benefit from the ease of building WYSIWYG text editors right after the upgrade.

At the same time, less flashy features like multiple databases support or parallel testing can bring immediate gains to your productivity—and Rails 6 has enough of those to offer if you know where to look.

Stripe Icon Stripe

Sorbet – a static type checker for Ruby

Some interesting new open source coming out of the team at Stripe. It appears they’ve stolen a few (good) tricks from TypeScript’s playbook:

Sorbet is 100% compatible with Ruby. It type checks normal method definitions, and introduces backwards-compatible syntax for method signatures.

Explicit method signatures make Sorbet useful for anyone reading the code too (not just the author). Type annotations serve as a tool for understanding long after they’re written.

Sorbet is designed to be useful, not burdensome. Explicit annotations are repaid with clear error messages, increased safety, and increased productivity.

There’s docs, a demo, and a talk from Strange Loop 2018, but you’ll have to wait to get your hands on the source. It’s advertised as Coming Summer 2019.

Rails chanind.github.io

Why I miss Rails

David Chanin:

I know Rails isn’t universally beloved by developers, and I’m not suggesting that we give up React and es7 and go back to writing server-templated web-apps like it’s 2012 again.

There’s a false dichotomy here. You don’t have to give up React to write server-templated web-apps. That being said, I understand what he’s trying to say.

However, I do think that in the transition to the modern web stack (something like React / nodejs / graphql / etc), we’ve unsolved some of what tools like Rails made easy 10 years ago - and I don’t think it needs to be that way.

This post is less a love song to Rails as it is a pitch for the value of unified frameworks in web development.

Thoughtbot Icon Thoughtbot

Templating tmux with tmuxinator

If you’re a tmux user, but you’ve never heard of tmuxinator… it’s time to fix that. Simon van Dyk has a solid intro to it on Thoughtbot’s blog:

tmuxinator is a ruby gem that allows you to easily manage tmux sessions by using yaml files to describe the layout of a tmux session, and open up that session with a single command.

I’ve been using tmuxinator for years and highly recommend it. 👌

Floor DrEES Phusion Blog

Using GitHub Actions to build and publish a Ruby gem

Follow along as our friends at Phusion walk us through the process of creating a GitHub Actions workflow to build and publish a Ruby gem to the RubyGems registry.

One of the actions featured in the version that’s currently exclusively available to GitHub employees and a selected and undisclosed group of Beta testers, is the ‘GitHub Action for npm’, which wraps the npm CLI to enable common npm commands.

We set out to instead make an example workflow to build and publish a Ruby library (or: gem) to the default public registry, and created a GitHub repository, with a Docker container for a ‘Rubygems’ action: github.com/scarhand/actions-ruby

Ruby bundler.io

Announcing Bundler 2.0

Congrats to the Bundler team (and entire Ruby community) for shipping an awesome update to this critical piece of infrastructure! Bundler truly changed the game for Rubyists around the world and we continue to benefit from its goodness.

What’s new in 2.0? A lot, but I’ll cherry pick a minor change that made me smile:

Changed the github: 'some/repo' gem source to use the https schema by default

Finally! That’s worth the price of admission from where I’m sitting. Also:

With the release of Bundler 2, the core team now kicks off a new release schedule for Bundler: we’re going to aim for one major version release per year, so we can drop support for older Ruby and RubyGems versions around the same time that the Ruby core team does. Being able to stop supporting Ruby 1.8.7 is a huge relief!

To the future!

David Heinemeier Hansson Ruby on Rails blog

Action Mailbox for Rails 6

DHH announced on the Ruby on Rails blog the details behind Action Mailbox, the second brand new framework coming to Rails 6 (the first was Action Text). Action Mailbox routes incoming emails to controller-like mailboxes for processing in Rails.

The framework was, like Action Text and Active Storage, extracted from Basecamp 3. We’ve been using a related approach to route everything from forwarded emails to email replies to messages and discussions. After extracting the ideas into Action Mailbox, we reintegrated the framework into Basecamp, and we’ve been running the code we’re sharing today for over a month in production.

0:00 / 0:00