Class: SmartProxyDynflowCore::BundlerHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_dynflow_core/bundler_helper.rb

Class Method Summary collapse

Class Method Details

.require_groups(*groups) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/smart_proxy_dynflow_core/bundler_helper.rb', line 3

def self.require_groups(*groups)
  if File.exist?(File.expand_path('../../Gemfile.in', __FILE__))
    # If there is a Gemfile.in file, we will not use Bundler but BundlerExt
    # gem which parses this file and loads all dependencies from the system
    # rathern then trying to download them from rubygems.org. It always
    # loads all gemfile groups.
    begin
      require 'bundler_ext' unless defined?(BundlerExt)
    rescue LoadError
      # Debian packaging guidelines state to avoid needing rubygems, so
      # we only try to load it if the first require fails (for RPMs)
      begin
        require 'rubygems' rescue nil
        require 'bundler_ext'
      rescue LoadError
        puts "`bundler_ext` gem is required to run smart_proxy"
        exit 1
      end
    end
    BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), *groups)
  else
    require 'bundler' unless defined?(Bundler)
    Bundler.require(*groups)
  end
end