Defining gem dependencies in single file Ruby scripts
16-Jul-2020 1607
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 #Defining #dependencies #single #scripts #gem #scripts https://rubyonrails.ba/link/defining-gem-dependencies-in-single-file-ruby-scripts