Bundlerinline(bundler v1.10 及更高版本)

有时你需要为某人制作剧本,但你不确定他的机器上有什么。你的脚本需要什么吗?不用担心。Bundler 有一个很好的功能。

它提供了一个 gemfile 方法,在脚本运行之前,它下载并需要所有必需的 gem。一个小例子:

require 'bundler/inline' #require only what you need

#Start the bundler and in it use the syntax you are already familiar with
gemfile(true) do 
  source 'https://rubygems.org'
        gem 'nokogiri', '~> 1.6.8.1'
        gem 'ruby-graphviz'
end