Sorting Your Gems

twitter logo github logo Originally published at scottw.com on ・1 min read

I was looking through the Dev.to source, and the first thing that jumped out at me was the Gemfile was sorted (within each group). This made it much easier to scan and think about their dependencies.

Using Vim, I was able to sort my Gemfile in a couple of seconds.

  1. Select the lines within the group (or all of those outside of a group).
  2. enter command mode (:) and type sort

That’s it. Now, if you were like me, you still sometimes flipflop between β€˜ and β€œ (working on it!), you will need to pick one (β€œ) and do a find and replace %s/'/"/g as well otherwise things will not sort quite right.

twitter logo DISCUSS (1)
markdown guide
 

We do this on CodeFund. github.com/gitcoinco/code_fund_ads/

I also do it on most of my side projects. I think it makes sense to sort any list that you need/want to scan visually. Things like permitted strong parameter attributes in your controllers, etc... Sorting helps you find things quickly and detect potential issues (like duplicate entries).

Classic DEV Post from Jun 2

Stay Healthy as a Developer

Scott Watermasysk profile image
Boostrapped Founder