Module: Lono::Bundle
Overview
Named Bundle vs Bundler to avoid having to fully qualify ::Bundler
Instance Method Summary collapse
- #bundler_groups ⇒ Object
- #gemfile? ⇒ Boolean
- #handle_error(e) ⇒ Object
- #require ⇒ Object
-
#setup ⇒ Object
Looks like for zeitwerk module autovivification to work
bundle execmust be called.
Instance Method Details
#bundler_groups ⇒ Object
48 49 50 |
# File 'lib/lono/bundle.rb', line 48 def bundler_groups [:default, Lono.env.to_sym] end |
#gemfile? ⇒ Boolean
44 45 46 |
# File 'lib/lono/bundle.rb', line 44 def gemfile? ENV['BUNDLE_GEMFILE'] || File.exist?("Gemfile") end |
#handle_error(e) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lono/bundle.rb', line 25 def handle_error(e) puts e. return if e..include?("already activated") puts <<~EOL.color(:yellow) WARNING: Unable to require "bundler/setup" There may be something funny with your ruby and bundler setup. You can try upgrading bundler and rubygems: gem update --system gem install bundler Here are some links that may be helpful: * https://bundler.io/blog/2019/01/03/announcing-bundler-2.html Also, running bundle exec in front of your command may remove this message. EOL end |
#require ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/lono/bundle.rb', line 17 def require return unless gemfile? Kernel.require "bundler/setup" Bundler.require(*bundler_groups) rescue LoadError => e handle_error(e) end |
#setup ⇒ Object
Looks like for zeitwerk module autovivification to work bundle exec must be called.
This allows zeitwork module autovivification to work even if the user has not called lono with bundle exec lono.
Bundler.setup is essentially the same as bundle exec
Reference: https://www.justinweiss.com/articles/what-are-the-differences-between-irb/
9 10 11 12 13 14 15 |
# File 'lib/lono/bundle.rb', line 9 def setup return unless gemfile? Kernel.require "bundler/setup" Bundler.setup # Same as Bundler.setup(:default) rescue LoadError => e handle_error(e) end |