Defining gem dependencies in single file Ruby scripts

Sometimes I come across cases where I need to write a simple script which uses a gem. The simplest way to go about this is to gem install gem-name and then require 'gem-name' in your script. However, this means that you need to remember to install the gem before running the script.Bundler has an inline gemfile definition feature that lets you define gem dependencies in a single-file Ruby script. To use this feature, require 'bundler/inline' and provide a gemfile block that has the code that you normally put in a Gemfile.
Defining gem dependencies in single file Ruby scripts #ruby #rubydeveloper #rubyonrails #gem #scripts https://rubyonrails.ba/single/defining-gem-dependencies-in-single-file-ruby-scripts

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles