Class: CodeOwnership::Configuration

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/code_ownership/configuration.rb

Constant Summary collapse

DEFAULT_JS_PACKAGE_PATHS =
T.let(['**/'], T::Array[String])

Class Method Summary collapse

Class Method Details

.fetchObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/code_ownership/configuration.rb', line 17

def self.fetch
  config_hash = YAML.load_file('config/code_ownership.yml')

  if config_hash.key?('require')
    config_hash['require'].each do |require_directive|
      Private::ExtensionLoader.load(require_directive)
    end
  end

  new(
    owned_globs: config_hash.fetch('owned_globs', []),
    unowned_globs: config_hash.fetch('unowned_globs', []),
    js_package_paths: js_package_paths(config_hash),
    skip_codeowners_validation: config_hash.fetch('skip_codeowners_validation', false),
    raw_hash: config_hash,
    require_github_teams: config_hash.fetch('require_github_teams', false)
  )
end

.js_package_paths(config_hash) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/code_ownership/configuration.rb', line 37

def self.js_package_paths(config_hash)
  specified_package_paths = config_hash['js_package_paths']
  if specified_package_paths.nil?
    DEFAULT_JS_PACKAGE_PATHS.dup
  else
    Array(specified_package_paths)
  end
end