diff options
Diffstat (limited to 'lib/gitlab.rb')
-rw-r--r-- | lib/gitlab.rb | 50 |
1 files changed, 7 insertions, 43 deletions
diff --git a/lib/gitlab.rb b/lib/gitlab.rb index d93d7acbaad..2449554d3c0 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -1,10 +1,15 @@ # frozen_string_literal: true require 'pathname' +require 'forwardable' + +require_relative 'gitlab_edition' module Gitlab - def self.root - Pathname.new(File.expand_path('..', __dir__)) + class << self + extend Forwardable + + def_delegators :GitlabEdition, :root, :extensions, :ee?, :ee, :jh?, :jh end def self.version_info @@ -89,47 +94,6 @@ module Gitlab Rails.env.development? || Rails.env.test? end - def self.extensions - if jh? - %w[ee jh] - elsif ee? - %w[ee] - else - %w[] - end - end - - def self.ee? - @is_ee ||= - # We use this method when the Rails environment is not loaded. This - # means that checking the presence of the License class could result in - # this method returning `false`, even for an EE installation. - # - # The `FOSS_ONLY` is always `string` or `nil` - # Thus the nil or empty string will result - # in using default value: false - # - # The behavior needs to be synchronised with - # config/helpers/is_ee_env.js - root.join('ee/app/models/license.rb').exist? && - !%w[true 1].include?(ENV['FOSS_ONLY'].to_s) - end - - def self.jh? - @is_jh ||= - ee? && - root.join('jh').exist? && - !%w[true 1].include?(ENV['EE_ONLY'].to_s) - end - - def self.ee - yield if ee? - end - - def self.jh - yield if jh? - end - def self.http_proxy_env? HTTP_PROXY_ENV_VARS.any? { |name| ENV[name] } end |