1 min read

Inline Bundler for Ruby Scripts

You can write a simple Ruby script which includes in-line bundler and so avoids the need to have a separate Gemfile.
Inline Bundler for Ruby Scripts
Photo by Lina Verovaya / Unsplash

You can write a simple Ruby script which includes in-line bundler and so avoids the need to have a separate Gemfile.

#!/usr/bin/env ruby

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'httparty'
end

puts HTTParty.get('https://billy-ruffian.co.uk')

As long as you have Ruby on your system, you'll have Bundler. If you don't have any of the gems referenced, Bundler will merrily download it for you and require it in your source.