Class: Packwerk::Layer::Config

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packwerk/layer/config.rb

Constant Summary collapse

ARCHITECTURE_VIOLATION_TYPE =
T.let('architecture', String)
ARCHITECTURE_ENFORCE =
T.let('enforce_architecture', String)
LAYER_VIOLATION_TYPE =
T.let('layer', String)
LAYER_ENFORCE =
T.let('enforce_layers', String)

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



15
16
17
18
# File 'lib/packwerk/layer/config.rb', line 15

def initialize
  @layers_key_configured = T.let(@layers_key_configured, T.nilable(T::Boolean))
  @layers_list = T.let(@layers_list, T.nilable(T::Array[String]))
end

Instance Method Details

#enforce_keyObject



41
42
43
# File 'lib/packwerk/layer/config.rb', line 41

def enforce_key
  layers_key_configured? ? LAYER_ENFORCE : ARCHITECTURE_ENFORCE
end

#layers_keyObject



31
32
33
# File 'lib/packwerk/layer/config.rb', line 31

def layers_key
  layers_key_configured? ? 'layers' : 'architecture_layers'
end

#layers_key_configured?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/packwerk/layer/config.rb', line 26

def layers_key_configured?
  @layers_key_configured ||= YAML.load_file('packwerk.yml')['architecture_layers'].nil?
end

#layers_listObject



21
22
23
# File 'lib/packwerk/layer/config.rb', line 21

def layers_list
  @layers_list ||= YAML.load_file('packwerk.yml')[layers_key] || []
end

#violation_keyObject



36
37
38
# File 'lib/packwerk/layer/config.rb', line 36

def violation_key
  layers_key_configured? ? LAYER_VIOLATION_TYPE : ARCHITECTURE_VIOLATION_TYPE
end