Module: GitlabEdition
- Defined in:
- lib/gitlab_edition.rb
Class Method Summary collapse
- .ee ⇒ Object
- .ee? ⇒ Boolean
- .extension_path_prefixes ⇒ Object
- .extensions ⇒ Object
- .jh ⇒ Object
- .jh? ⇒ Boolean
- .path_glob(path) ⇒ Object
- .root ⇒ Object
Class Method Details
.ee ⇒ Object
64 65 66 |
# File 'lib/gitlab_edition.rb', line 64 def self.ee yield if ee? end |
.ee? ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gitlab_edition.rb', line 35 def self.ee? # To reduce dependencies in QA image we are not using # `Gitlab::Utils::StrongMemoize` but reimplementing its functionality. return @is_ee if defined?(@is_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) # rubocop:disable Rails/NegateInclude end |
.extension_path_prefixes ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitlab_edition.rb', line 14 def self.extension_path_prefixes path_prefixes = extensions return '' if path_prefixes.empty? path_prefixes.map! { "#{_1}/" } path_prefixes.unshift '' # For example `{,ee/,jh/}` "{#{path_prefixes.join(',')}}" end |
.extensions ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab_edition.rb', line 25 def self.extensions if jh? %w[ee jh] elsif ee? %w[ee] else %w[] end end |
.jh ⇒ Object
68 69 70 |
# File 'lib/gitlab_edition.rb', line 68 def self.jh yield if jh? end |
.jh? ⇒ Boolean
55 56 57 58 59 60 61 62 |
# File 'lib/gitlab_edition.rb', line 55 def self.jh? return @is_jh if defined?(@is_jh) @is_jh = ee? && root.join('jh').exist? && !%w[true 1].include?(ENV['EE_ONLY'].to_s) # rubocop:disable Rails/NegateInclude end |
.path_glob(path) ⇒ Object
10 11 12 |
# File 'lib/gitlab_edition.rb', line 10 def self.path_glob(path) "#{root}/#{extension_path_prefixes}#{path}" end |
.root ⇒ Object
6 7 8 |
# File 'lib/gitlab_edition.rb', line 6 def self.root Pathname.new(File.('..', __dir__)) end |