Skip to main content

All You Need to Know About Comments in Ruby - Tarka Labs

All You Need to Know About Comments in Ruby - Tarka Labs

Link

A Beginner's Guide to Abstraction

A Beginner's Guide to Abstraction

Link

til-rb, a gem to help you write and manage a TIL repo

til-rb, a gem to help you write and manage a TIL repo

Link

Fun facts about Ruby

Fun facts about Ruby #4

Link

Triggering a command line on file change

1 min read

Today I was migrating a somewhat old codebase to Ruby on Rails 6.0.0. As per usual, this can be a very tidious job requiring a bunch of depencies to be updated as well. In this case, the Gemfile contains around 150 lines.

When I have to do that kind of job, the first thing I do is commenting out every single gem except for rails itself, then bundle update, then I re-add the other gems to the Gemfile.

It rarely goes smoothly, since every gem has it's own dependencies and sometime the bundle command has trouble to find a way to update everything in one go, so I usually re-add 2-5 gems at once then run bundle update on my modified Gemfile, until all the dependencies have been re-added.

The whole process of going back and forth to editing, saving, running the bundle command is somewhat exhausting, so today I decided to have a look at a more productive way to do this : the following command uses inotifywait to detect whenever I save the Gemfile then run bundle update automagically.

while inotifywait -e close_write Gemfile; do bundle update; done

 

How to install Solargraph with Sublime Text LSP

1 min read

Solargraph is a Ruby Language Server. It's meant to add code completion and inline documentation onto IDEs.

We have to install the gem first

gem install solargraph

Within Sublime Text Control Panel (CTRL+Shift+P) :

  1. Find Package Control: Install Package
  2. Then LSP
  3. Hit enter

By default, the ST plugin will look for rvm, not rbenv. We have to force the settings Preferences > Package Settings > LSP > Settings, and paste this :

https://gist.github.com/cedricbousmanne/099bccef4472912aba61545d0c31d5ec

Note : you need to adjust the value of the path on line 8. You can find the exact installation path of solargraph on your system with the following command

which solargraph

Finally we can enable the server via the Sublime Text Control Panel (CTRL+Shift+P)

6W7tjXLl.png

How to install Rubocop for Sublime Text with rbenv

1 min read

Rubocop is a static code analyzer and formatter for Ruby. Long story short : it helps you to write better code.

Installing it pretty straight-forward :

gem install rubocop

Within Sublime Text Control Panel (CTRL+Shift+P) :

  1. Find Package Control: Install Package
  2. Then Rubocop (currently v2018.12.05.18.01.20)
  3. Hit enter

By default, the ST plugin will look for rvm, not rbenv. We have to force the settings Preferences > Package Settings > Rubocop > Settings - Users, and paste this :

https://gist.github.com/cedricbousmanne/2c89bf83de175f6fa6fe8dea9b7724b7

Now we can have a list of the available options by typing rubocop withing the Control Panel (CTRL+Shift+P).

RVV9n3B.png

We’re planning to launch a Ruby Meetup Luxembourg in 2019. Anyone interested to jump in? PM for details and don’t hesitate to ping a friend! <p>#nonclass </p>