Module: Gitlab::LanguageData

Extended by:
Utils::StrongMemoize
Defined in:
lib/gitlab/language_data.rb

Constant Summary collapse

EXTENSION_MUTEX =
Mutex.new

Class Method Summary collapse

Methods included from Utils::StrongMemoize

clear_memoization, strong_memoize, strong_memoized?

Class Method Details

.clear_extensions!Object


26
27
28
29
30
# File 'lib/gitlab/language_data.rb', line 26

def clear_extensions!
  EXTENSION_MUTEX.synchronize do
    clear_memoization(:extensions)
  end
end

.extensionsObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/language_data.rb', line 10

def extensions
  EXTENSION_MUTEX.synchronize do
    strong_memoize(:extensions) do
      Set.new.tap do |set|
        YAML.load_file(Rails.root.join('vendor', 'languages.yml')).each do |_name, details|
          details['extensions']&.each do |ext|
            next unless ext.start_with?('.')

            set << ext.downcase
          end
        end
      end
    end
  end
end