Ruby Weekly Issue 588: January 27, 2022
source link: https://rubyweekly.com/issues/588
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Ruby Weekly Issue 588
#588 — January 27, 2022
✍️ Last week's issue had so many interesting bits of news that it was a hard act to follow, so while this is a quieter week in the Ruby world, be sure to check last week's issue too if you skipped it at all :-)
__
Peter Cooper — Editor
Ruby Weekly
RPush 7.0: The Push Notification Service — An abstraction over numerous push notification systems, including those from Apple, Google, Amazon, and more. This 7.0 release adds Ruby 3.1 and Rails 7.0 support.
Ian Leitch
Building GraphQL APIs in Rails — GraphQL is a flexible, strongly-typed query language, and while it doesn’t naturally mesh directly to Rails' typically REST-oriented approach, there are ways to make it possible, and if you don’t even know why you might use GraphQL, David does a good job of explaining it all here.
David Sanchez
ButterCMS Melts into Your Ruby App. #1 Rated Headless CMS — ButterCMS is your content backend. Enable your marketing team to update website + app content without needing you. Try the #1 rated Headless CMS for Ruby today. Free for 30 days.
ButterCMS sponsor
Spree Commerce 4.4: The Open Source Rails Ecommerce System — Spree is a long standing ecommerce system built on top of Rails and 4.4 is a big release for them including using Hotwire for a smoother dashboard experience, features for selling digital downloads, wishlist functionality, and more. Solidus is another option in this space; it began life as a fork of Spree.
Spree Commerce
IN BRIEF:
-
The DragonRuby Game Toolkit has been made free for the next two weeks to encourage Rubyists to enter some forthcoming game jams and increase Ruby's representation in the game dev space.
-
Eight years after his famous video about learning Vim in a week, Mike Coutermarsh is still using Vim and sharing his up to date dotfiles.
-
RubyGems 3.3.6 has been released.
-
There was a (very) brief discussion on Hacker News about whether Rails is worth learning as a solo founder in 2022. Spoiler: Yes.
Go Engineer — Help us scale one of the biggest Postgres-powered Rails majestic monoliths in the world.
Buildkite
Senior Rails Developer @ Wherefour (100% Remote) — Curious how stuff gets made? Come build great software that makes great products.
Wherefour
Find Ruby Jobs Through Hired — Create a profile on Hired to connect with hiring managers at growing startups and Fortune 500 companies. It's free for job-seekers.
Hired
📕 Articles & Tutorials
Using Entropy for User-Friendly Strong Passwords — A look at the approach database platform PlanetScale took with their signup form to enforce strong passwords while also playing nicely with password managers.
Mike Coutermarsh (PlanetScale)
Build Your Own Concurrency Control in Sidekiq — If you’ve got background jobs you want to perform sequentially, a locking system may be useful. Sidekiq::Sequence or SidekiqUniqueJobs may also be useful if you need similar functionality out of the box.
Mihai Colceriu
Enqueue Jobs Quickly with Sidekiq’s Bulk Features — What if you have the opposite problem.. lots of jobs you want to cram into Sidekiq as fast as possible? Andy Croll has your back, and can get you down from lots of trips across the network to just one.
Andy Croll
Free eBook: Efficient Search in Rails with Postgres — Speed up a search query from seconds to milliseconds and learn about exact matches, trigrams, ILIKE, and full-text.
pganalyze sponsor
Upgrading Rails from 6.1 to 7.0: Things to Consider — A tactical upgrade guide from the company that makes a business around upgrading Rails.
Cleiviane Costa (FastRuby.io)
Switching from Webpacker 5 to jsbundling-rails with webpack — Since there will be no Webpacker 6, you might want to be aware of this.
Rails Contributors
Test and Optimize Your Rails App's Database Performance — Quickly covers three ways to investigate problems and then seven ways to mitigate said problems.
Milap Neupane
Working with Ruby C Extensions on a MacBook — While some of this is Mac-focused, there are loads of linked resources that dive deeper, so if you’re interested in Ruby and C, this is a fine place to start.
Ulysse Buonomo
Rails 7's Support for Postgres' Generated Columns
Swaathi Kakarla
🛠 Code & Tools
Que 1.0: A Ruby Job Queue That Uses Postgres's Advisory Locks — A perfect use for Postgres’s built in advisory locking mechanism to bring more reliable job queue functionality to Ruby by using said locks to protect the state of the jobs.
Chris Hanks
Shortcut Puts the Agile in Agile and the “Can” in Kanban
Shortcut (formerly Clubhouse.io) sponsor
Wasabi: A Simple WSDL Parser — Web Services Description Language is an XML-based language for defining web service functionality (frequently used with SOAP).
Daniel Harrington
Sidekiq 6.4: Simple, Efficient Background Processing for Ruby — We've mentioned it a few times already in this issue, but there's a new release too ;-)
Mike Perham
rails_param: Parameter Validation and Type Coercion for Rails
Nicolas Blanco
MemoWise 1.6: A Modern Choice for Ruby Memoization — Now officially supports Ruby 3.1.
Panorama Education
React on Rails: Bringing React, Webpack, and Rails Together with Webpacker
ShakaCode
Counter Culture 3.2: 'Turbo-Charged' Counter Caches for Rails Apps
Magnus von Koeller
💡 Tip of the Week
File
Methods: Part Two
In last week's tip, we learned about __FILE__
, which gives us the path to the current file, and File.expand_path
which gives us the full absolute filepath.
File.dirname
As the name implies, File.dirname
will give us the path to the directory of a file. Combining this with what we learned last week, this means that if we had a file at ruby_weekly/sample.rb
with the following contents:
puts File.dirname(__FILE__)
..we could run it and see the directory:
$ ruby ruby_weekly/sample.rb
ruby_weekly
Interestingly, in Ruby 3.1, File.dirname
introduced an optional second parameter, an integer which represents how many levels to go up the directory tree. So for instance, if the full path to the above file is /Users/jemmaissroff/ruby_weekly/sample.rb
, and we edit the file slightly to use the full path, and a second argument:
puts File.dirname(
File.expand_path(__FILE__), 2
)
we'll see the path to the directory two up the directory tree from our file:
$ ruby ruby_weekly/sample.rb
/Users/jemmaissroff/
File.join
Last up in File
methods (I promise we're getting there!), File.join
joins its arguments with a "/" to create a filepath. For instance:
File.join("app", "controllers", "file_name.rb")
# => "app/controllers/file_name.rb"
Notice this is exactly the same as if we'd run:
["app", "controllers", "file_name.rb"].join("/")
# => "app/controllers/file_name.rb"
This can be useful to construct a file path from a relative file. Before Ruby 3.1 introduced the second argument to File.dirname
, it was often used to join ".."
which takes us one directory up the tree.
Why are all of these file methods relevant? Some gems or Ruby applications often use a combination of them to load the appropriate files.
Take a look at this code (split across multiple lines for email formatting reasons) and see if you now can decipher exactly what it's doing!
File.expand_path(
File.join(
File.dirname(__FILE__, 2), 'lib'
)
)
This week’s tip was written by Jemma Issroff.
Recommend
-
7
JavaScript Weekly Issue 574 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
7
Node Weekly Issue 422 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
6
Node Weekly Issue 421 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
7
JavaScript Weekly Issue 573 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
1
Ruby Weekly Issue 587 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
3
Ruby Weekly Issue 589 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
6
Ruby Weekly Issue 590 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
6
Ruby Weekly Issue 591 Easy to unsubscribe at any time. Your e-mail address is safe — here's our privacy policy.
-
5
Today's Wordle Answer #588 - January 28, 2023 Solution And Hints ...
-
6
量大管饱!这台HP Smart Tank 588打印机值得购入 绿苹果 责任编辑:wangyifei 发布于:2023-06-06 00:15 PConline原创 ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK