Welcome to another edition of This Week in #dev, a series of posts where we bring some of the most interesting Slack conversations to the public. Today we’re talking about finding out why a yarn package is installed, how to limit values to a range in Ruby, and Rails application templates.
Daniel Nolan learned that Yarn has a command called
why which can be used to
find out what version of a module is being used and why it is installed.
$ yarn why jest yarn why vx.x.x [1/4] 🤔 Why do we have the module "jest"...? [2/4] 🚚 Initializing dependency graph... [3/4] 🔍 Finding dependency... [4/4] 🚡 Calculating file sizes... info Has been hoisted to "jest" info This module exists because it's specified in "devDependencies". info Disk size without dependencies: "1.29kB" info Disk size with unique dependencies: "101.31kB" info Disk size with transitive dependencies: "20.35MB" info Amount of shared dependencies: 125
Neil Carvalho learned about the Comparable#clamp method in Ruby. This method
is used to limit a value to a given range of values. For example, if you have a variable
x with a value of 15 and you want to ensure that it never exceeds 10 or falls
below 5, you could use
x.clamp(5, 10) to restrict it to that range. It also
works with a
12.clamp(0..100) #=> 12 -3.123.clamp(0..100) #=> 0 'd'.clamp('a'..'f') #=> 'd' 'z'.clamp('a'..'f') #=> 'f' -20.clamp(0..) #=> 0 523.clamp(..100) #=> 100
Rails Application Templates
Steve Polito has gained a renewed interest in Rails Application Templates after working on Suspenders during our annual hackathon and is considering exploring their potential use as an alternative to Suspenders in appropriate cases.
He has started researching how application templates can require specific
arguments and enforce specific versions of Ruby and Rails. He recommends
checking out David Copeland’s template and mentions that Rails also supports a
.railsrc config file that can be used to run the
rails new command with default
arguments. Steve also notes that templates can be run against existing
This edition was brought to you by Daniel Nolan, Neil Carvalho, and Steve Polito. Thanks to all contributors! 🎉