diff options
author | Samuel E. Giddins <segiddins@segiddins.me> | 2015-02-26 20:58:08 -0800 |
---|---|---|
committer | Samuel E. Giddins <segiddins@segiddins.me> | 2015-02-26 20:58:08 -0800 |
commit | d992a6df25aa383765a542938263708a4440e15e (patch) | |
tree | 3a8499190160726d84da0e90f8237e494c2a3954 | |
parent | d8f61693cc89476c1ee3cc01ccf03c0908531a4d (diff) | |
download | bundler-d992a6df25aa383765a542938263708a4440e15e.tar.gz |
[Inline] Add bundler/inline to allow using Bundler without a Gemfile
-rw-r--r-- | lib/bundler/inline.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb new file mode 100644 index 0000000000..fb3df6d23c --- /dev/null +++ b/lib/bundler/inline.rb @@ -0,0 +1,20 @@ +def gemfile(install = false, &blk) + require 'bundler' + old_root = Bundler.method(:root) + def Bundler.root + Pathname.pwd.expand_path + end + ENV['BUNDLE_GEMFILE'] ||= 'Gemfile' + + builder = Bundler::Dsl.new + builder.instance_eval(&blk) + definition = builder.to_definition(nil, true) + def definition.lock(*); end + definition.validate_ruby! + Bundler::Installer.install(Bundler.root, definition, :system => true) if install + runtime = Bundler::Runtime.new(nil, definition) + runtime.setup_environment + runtime.setup.require + + Bundler.send(:define_singleton_method, :root, old_root) +end |