Class: Ast::Merge::Ruleset::FeatureProfile
- Inherits:
-
Object
- Object
- Ast::Merge::Ruleset::FeatureProfile
- Defined in:
- lib/ast/merge/ruleset/feature_profile.rb
Overview
Shared value object describing a merge implementation or ruleset surface using spec-aligned feature terminology.
FeatureProfile is the bridge from ruleset capability declarations to merge-facing behavior. It may reference parser capabilities and support styles, but it is not itself a parser adapter or renderer.
Instance Attribute Summary collapse
-
#attachment_strategy ⇒ Object
readonly
Returns the value of attribute attachment_strategy.
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#comment_capability ⇒ Object
readonly
Returns the value of attribute comment_capability.
-
#comment_style ⇒ Object
readonly
Returns the value of attribute comment_style.
-
#delegation_policies ⇒ Object
readonly
Returns the value of attribute delegation_policies.
-
#logical_owner_policies ⇒ Object
readonly
Returns the value of attribute logical_owner_policies.
-
#logical_owners ⇒ Object
readonly
Returns the value of attribute logical_owners.
-
#match_key ⇒ Object
readonly
Returns the value of attribute match_key.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#owner_selector ⇒ Object
readonly
Returns the value of attribute owner_selector.
-
#read_strategy ⇒ Object
readonly
Returns the value of attribute read_strategy.
-
#render_family ⇒ Object
readonly
Returns the value of attribute render_family.
-
#repair_policies ⇒ Object
readonly
Returns the value of attribute repair_policies.
-
#support_style ⇒ Object
readonly
Returns the value of attribute support_style.
-
#surfaces ⇒ Object
readonly
Returns the value of attribute surfaces.
Instance Method Summary collapse
- #attachment_strategy_family ⇒ Object
- #attachment_strategy_metadata ⇒ Object
- #augmenter_preferred_attachment? ⇒ Boolean
- #comment_aware? ⇒ Boolean
- #delegated_surface_aware? ⇒ Boolean
-
#initialize(owner_selector:, match_key:, read_strategy: nil, attachment_strategy: nil, comment_style: nil, render_family: nil, comment_capability: nil, support_style: nil, capabilities: {}, logical_owners: {}, repair_policies: [], surfaces: [], delegation_policies: [], metadata: {}) ⇒ FeatureProfile
constructor
A new instance of FeatureProfile.
- #layout_aware? ⇒ Boolean
- #logical_owner? ⇒ Boolean
- #match_key_family ⇒ Object
- #match_key_metadata ⇒ Object
- #normalized_attachment? ⇒ Boolean
- #owner_selector_family ⇒ Object
- #owner_selector_kind ⇒ Object
- #owner_selector_metadata ⇒ Object
- #repair_aware? ⇒ Boolean
- #structural_only? ⇒ Boolean
- #surface_aware? ⇒ Boolean
- #to_h ⇒ Object
- #tracked_attachment? ⇒ Boolean
Constructor Details
#initialize(owner_selector:, match_key:, read_strategy: nil, attachment_strategy: nil, comment_style: nil, render_family: nil, comment_capability: nil, support_style: nil, capabilities: {}, logical_owners: {}, repair_policies: [], surfaces: [], delegation_policies: [], metadata: {}) ⇒ FeatureProfile
Returns a new instance of FeatureProfile.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 29 def initialize( owner_selector:, match_key:, read_strategy: nil, attachment_strategy: nil, comment_style: nil, render_family: nil, comment_capability: nil, support_style: nil, capabilities: {}, logical_owners: {}, repair_policies: [], surfaces: [], delegation_policies: [], metadata: {} ) @owner_selector = owner_selector&.to_sym @match_key = match_key&.to_sym @read_strategy = read_strategy&.to_sym @attachment_strategy = &.to_sym @comment_style = comment_style&.to_sym @render_family = render_family&.to_sym @comment_capability = comment_capability @support_style = support_style @capabilities = capabilities.dup.freeze @logical_owners = logical_owners.dup.freeze @logical_owner_policies = @logical_owners.map do |kind, action| LogicalOwnerPolicy.new(kind: kind, action: action) end.freeze @repair_policies = normalize_repair_policies(repair_policies) @surfaces = normalize_surfaces(surfaces) @delegation_policies = normalize_delegation_policies(delegation_policies) @metadata = .dup.freeze end |
Instance Attribute Details
#attachment_strategy ⇒ Object (readonly)
Returns the value of attribute attachment_strategy.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def @attachment_strategy end |
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def capabilities @capabilities end |
#comment_capability ⇒ Object (readonly)
Returns the value of attribute comment_capability.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def comment_capability @comment_capability end |
#comment_style ⇒ Object (readonly)
Returns the value of attribute comment_style.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def comment_style @comment_style end |
#delegation_policies ⇒ Object (readonly)
Returns the value of attribute delegation_policies.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def delegation_policies @delegation_policies end |
#logical_owner_policies ⇒ Object (readonly)
Returns the value of attribute logical_owner_policies.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def logical_owner_policies @logical_owner_policies end |
#logical_owners ⇒ Object (readonly)
Returns the value of attribute logical_owners.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def logical_owners @logical_owners end |
#match_key ⇒ Object (readonly)
Returns the value of attribute match_key.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def match_key @match_key end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def @metadata end |
#owner_selector ⇒ Object (readonly)
Returns the value of attribute owner_selector.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def owner_selector @owner_selector end |
#read_strategy ⇒ Object (readonly)
Returns the value of attribute read_strategy.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def read_strategy @read_strategy end |
#render_family ⇒ Object (readonly)
Returns the value of attribute render_family.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def render_family @render_family end |
#repair_policies ⇒ Object (readonly)
Returns the value of attribute repair_policies.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def repair_policies @repair_policies end |
#support_style ⇒ Object (readonly)
Returns the value of attribute support_style.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def support_style @support_style end |
#surfaces ⇒ Object (readonly)
Returns the value of attribute surfaces.
13 14 15 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 13 def surfaces @surfaces end |
Instance Method Details
#attachment_strategy_family ⇒ Object
88 89 90 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 88 def &.fetch(:family, nil) end |
#attachment_strategy_metadata ⇒ Object
84 85 86 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 84 def ProfileVocabulary.() end |
#augmenter_preferred_attachment? ⇒ Boolean
134 135 136 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 134 def &.fetch(:augmenter_preferred, false) || false end |
#comment_aware? ⇒ Boolean
100 101 102 103 104 105 106 107 108 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 100 def comment_aware? if support_style.respond_to?(:available?) support_style.available? elsif comment_capability.respond_to?(:available?) comment_capability.available? else false end end |
#delegated_surface_aware? ⇒ Boolean
122 123 124 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 122 def delegated_surface_aware? delegation_policies.any? end |
#layout_aware? ⇒ Boolean
64 65 66 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 64 def layout_aware? capabilities.fetch(:layout_aware, false) end |
#logical_owner? ⇒ Boolean
96 97 98 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 96 def logical_owner? capabilities.fetch(:logical_owner, logical_owners.any?) end |
#match_key_family ⇒ Object
80 81 82 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 80 def match_key_family &.fetch(:family, nil) end |
#match_key_metadata ⇒ Object
76 77 78 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 76 def ProfileVocabulary.(match_key) end |
#normalized_attachment? ⇒ Boolean
130 131 132 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 130 def &.fetch(:normalized, false) || false end |
#owner_selector_family ⇒ Object
72 73 74 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 72 def owner_selector_family &.fetch(:family, nil) end |
#owner_selector_kind ⇒ Object
92 93 94 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 92 def owner_selector_kind OwnerSelection.selector_kind(owner_selector, logical_owners: logical_owners) end |
#owner_selector_metadata ⇒ Object
68 69 70 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 68 def ProfileVocabulary.(owner_selector) end |
#repair_aware? ⇒ Boolean
114 115 116 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 114 def repair_aware? repair_policies.any? end |
#structural_only? ⇒ Boolean
110 111 112 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 110 def structural_only? !layout_aware? && !comment_aware? && !logical_owner? end |
#surface_aware? ⇒ Boolean
118 119 120 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 118 def surface_aware? surfaces.any? end |
#to_h ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 138 def to_h { owner_selector: owner_selector, match_key: match_key, read_strategy: read_strategy, attachment_strategy: , comment_style: comment_style, render_family: render_family, comment_capability: comment_capability&.to_h, support_style: support_style&.to_h, capabilities: capabilities, logical_owners: logical_owners, logical_owner_policies: logical_owner_policies.map(&:to_h), repair_policies: repair_policies.map(&:to_h), surfaces: surfaces.map(&:to_h), delegation_policies: delegation_policies.map(&:to_h), metadata: , layout_aware: layout_aware?, owner_selector_family: owner_selector_family, owner_selector_kind: owner_selector_kind, match_key_family: match_key_family, attachment_strategy_family: , logical_owner: logical_owner?, comment_aware: comment_aware?, structural_only: structural_only?, repair_aware: repair_aware?, surface_aware: surface_aware?, delegated_surface_aware: delegated_surface_aware?, tracked_attachment: , normalized_attachment: , augmenter_preferred_attachment: }.compact end |
#tracked_attachment? ⇒ Boolean
126 127 128 |
# File 'lib/ast/merge/ruleset/feature_profile.rb', line 126 def &.fetch(:tracked_comments, false) || false end |