#​556 — June 10, 2021

Read on the Web

Jemma is back with another tip of the week - check it out at the end of this issue. The only problem is I can never remember the syntax for heredocs off the top of my head as it is.. :-)
__
Peter Cooper and Glenn Goodrich

Ruby Weekly

▶  Matz's Euruko Keynote: Beyond Ruby 3.0 — The founder and chief designer of our favorite language recently gave a virtual keynote and focused on what Ruby has achieved with version 3, and where efforts are headed next. It’s quite long but easily skimmed, or you can enjoy Matheus Richard's Twitter notes of what Matz covered. Ruby 3.1 is due Christmas 2021 but will be a ‘conservative’ release with few new features.

Yukihiro 'Matz' Matsumoto

A Review of Ruby Installers and Ruby Switchers — I remember when RVM was the only game in town, but now there are a few options for Ruby managers, so understanding their pros and cons is important.

Benoit Daloze

▶  Are You Listening to FounderQuest Yet? — It’s a weekly podcast about three Ruby developers bootstrapping a software business on their own terms...and murderbots, ninjas, garlic scapes, and (checks notes) something called Big Mouth Billy Bass. Don’t miss out.

FounderQuest sponsor

Performance, Stress, and Load Tests in Rails — A break down of approaches to performance testing Rails apps and what sort of metrics you might want to collect, followed by a practical example of actually doing it.

Paweł Dąbrowski

An Update from the Maintainer of PrawnPrawn is a popular Ruby PDF generation library originally created by Gregory Brown but now maintained by Alexander Mankuta. Here he shares a little history, how he considers Prawn to be ‘complete’, and the stresses and realities of being an open source maintainer.

Alexander Mankuta

Building a New Programming Language In Ruby: The Interpreter — Having written the parser and lexer in previous posts, the interpreter now rounds out the final execution need for the ‘Stoffle’ language.

Alex Braha Stoll

Removing Assets Dependencies from Rails Apps for Runtime — Once assets are generated, we don’t need the gems that did the generation, but Rails keeps them around in production. Josef gets rid of them.

Josef Strzibny

▶  Can Active Storage Serve Images for the Modern Web? — Dave Kimura and Luke Stutters talk with Mark Hutter about Active Storage and his experience building a large image driven application.

Ruby Rogues Podcast podcast

▶  Ten Rails Tips and Tricks — These are always great.

Drifting Ruby

A Handful of Sidekiq Good Practices
Paweł Dąbrowski

Some Reasons Why Bugs Might Feel 'Impossible' to Resolve
Julia Evans

🛠 Code and Tools

Rux 1.0: A JSX-Inspired Way to Render View Components in Ruby — If you’re a fan of the React approach of including templates directly within normal code, this might intrigue you. There’s rux-rails to take it into Rails, too.

Cameron Dutro

ZipTricks: Compact ZIP File Writing/Reading Library — Boasts support for streaming out archive creation so you can create large ZIP archives (such as of customer data, perhaps) without eating up all your RAM.

WeTransfer

Autoscale Your Heroku App For Free, Forever — Introducing the Rails Autoscale free tier. Web and worker dynos included, up to 20 autoscale events per month.

Rails Autoscale sponsor

SearchKick 4.5: Intelligent Search Made Easy with Elasticsearch — A mature library that uses Elasticsearch to provide ‘smart’ and fuzzy search as well as autocomplete functionality that learns from what your users are searching for.

Andrew Kane

Pagy 4.8: A Popular Pagination Gem — It’s been a couple of years since we’ve linked to Pagy but it’s still getting updated, works with all Rack-based frameworks and is storage/ORM agnostic, so what’s not to like?

Domizio Demichelis

🥑 30+ Releases Later, Avo Admin Gets Better Everyday.
Rails ❤️ Avo

Avo Admin for Rails sponsor

CSV 3.2.0: CSV Reading and Writing Library — Formerly part of the Ruby standard library, this is now maintained as a separate gem.

Ruby Core Team

JRuby 9.2.18.0 Released — An update to the Ruby 2.5.x compatible branch.

JRuby Core Team

childprocess 4.1: Cross-Platform Library for Managing Child Processes — This latest release adds ARM64-macos support.

Eric Kessler

Loofah 2.10.0: Nokogiri-Powered HTML/XML Manipulation and Sanitization
Mike Dalessio

Jobs

Senior Software Engineer — Snapdocs is a Unicorn now with over $1.5B valuation. Join our growing distributed team in the US and help us disrupt the mortgage and real-estate industry.
Snapdocs

Ruby on Rails Engineer Positions — We’re growing teams in Europe and North America, we’re also one of the fastest growing SaaS companies globally. Tech : Postgres, AWS, React, Redux.
Workday

Find Ruby Jobs with Hired — Take 5 minutes to build your free profile & start getting interviews for your next job. Companies on Hired are actively hiring right now.
Hired

💡 Tip of the Week

Heredoc Method Chaining

Ruby's Heredocs allow us to easily write multiline strings, or big blocks of text. Oftentimes, when writing these heredocs, we need to do some sort of string manipulation. We often do this string manipulation as a separate method call after we've initialized the string using a heredoc. This might look something like:

string = <<~EOF  
  This is a multiline string
  but we don't actually want
  any newlines in the final version
EOF

string.gsub!("\n", " ")

=> "This is a multiline string but we don't actually want any newlines in the final version "

(Please note, the odd formatting above is due to our code blocks not supporting wrapping ;-) Email is a tricky format!)

However, less well known is that we can actually call methods on the heredoc itself. As you may have noticed, syntactically this won't work by calling the method after the closing identifier. Instead, any methods can be called right after the opening identifier. In this case, this would look like this:

string = <<~EOF.gsub("\n", " ")
  This is a multiline string
  but we don't actually want
  any newlines in the final version
EOF

=> "This is a multiline string but we don't actually want any newlines in the final version "

We can also chain together methods on the heredoc in a similar fashion:

string = <<~EOF.gsub("\n", " ").upcase
  This is a multiline string
  but we don't actually want
  any newlines in the final version
EOF

=> "THIS IS A MULTILINE STRING BUT WE DON'T ACTUALLY WANT ANY NEWLINES IN THE FINAL VERSION "

In the case above, we replaced the newlines with spaces and converted the string to upper case.

This week’s tip was written by Jemma Issroff.