Bundler offers a module that we can include in our script and that offers all the features of a Gemfile but to define our gems inside the script.

Instead of

require 'rainbow'

puts Rainbow("My very important message in red").red

You can do

require 'bundler/inline'

gemfile do
    source 'https://rubygems.org'

    gem 'rainbow', '~> 3.0.0'
end

puts Rainbow("My very important message in red").red