Class: Packwerk::Layer::Package
- Inherits:
-
T::Struct
- Object
- T::Struct
- Packwerk::Layer::Package
- Extended by:
- T::Sig
- Defined in:
- lib/packwerk/layer/package.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from(package, layers) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/packwerk/layer/package.rb', line 34 def from(package, layers) config = package.config # This allows the layer to be inferred based on the package root package_root = package.name.split('/').first if config['layer'] layer = config['layer'] elsif package_root && layers.names.include?(package_root) layer = package_root else layer = nil end Package.new( layer: layer, enforcement_setting: config[Config.new.enforce_key], config: config ) end |
Instance Method Details
#can_depend_on?(other_package, layers:) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/packwerk/layer/package.rb', line 19 def can_depend_on?(other_package, layers:) return true if !enforces? flow_sensitive_layer = layer flow_sensitive_other_layer = other_package.layer return true if flow_sensitive_layer.nil? return true if flow_sensitive_other_layer.nil? layers.index_of(flow_sensitive_layer) >= layers.index_of(flow_sensitive_other_layer) end |
#enforces? ⇒ Boolean
14 15 16 |
# File 'lib/packwerk/layer/package.rb', line 14 def enforces? enforcement_setting == true || enforcement_setting == 'strict' end |