Class: Canon::Config::MatchConfig
- Inherits:
-
Object
- Object
- Canon::Config::MatchConfig
- Defined in:
- lib/canon/config.rb
Overview
Match configuration for comparison behavior
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #apply_profile_data(data) ⇒ Object
- #clear_profile! ⇒ Object
-
#collapse_whitespace_elements ⇒ Object
Element names where whitespace is COLLAPSED (HTML-style behavior).
-
#initialize(format = nil) ⇒ MatchConfig
constructor
A new instance of MatchConfig.
-
#preserve_whitespace_elements ⇒ Object
Element names where whitespace is PRESERVED exactly (no manipulation).
-
#profile ⇒ Object
Profile accessor with ENV override support.
- #profile=(value) ⇒ Object
-
#profile_options ⇒ Hash
Return all profile-sourced values from the resolver, excluding the :profile key itself (which is accessed via #profile).
- #reset! ⇒ Object
-
#strip_whitespace_elements ⇒ Object
Element names where whitespace-only text nodes are STRIPPED.
-
#to_h ⇒ Object
Build match options from profile and options.
Constructor Details
#initialize(format = nil) ⇒ MatchConfig
Returns a new instance of MatchConfig.
177 178 179 180 181 |
# File 'lib/canon/config.rb', line 177 def initialize(format = nil) @format = format @resolver = build_resolver(format) @options = {} end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
175 176 177 |
# File 'lib/canon/config.rb', line 175 def @options end |
Instance Method Details
#apply_profile_data(data) ⇒ Object
237 238 239 240 241 242 243 244 245 |
# File 'lib/canon/config.rb', line 237 def apply_profile_data(data) return unless data data.each do |key, value| sym_key = key.to_sym converted = value.is_a?(String) ? value.to_sym : value @resolver.set_profile(sym_key, converted) end end |
#clear_profile! ⇒ Object
247 248 249 |
# File 'lib/canon/config.rb', line 247 def clear_profile! @resolver.clear_profile! end |
#collapse_whitespace_elements ⇒ Object
Element names where whitespace is COLLAPSED (HTML-style behavior). Multiple whitespace chars collapse to single space; boundaries preserved.
220 221 222 |
# File 'lib/canon/config.rb', line 220 def collapse_whitespace_elements @resolver.resolve(:collapse_whitespace_elements) || [] end |
#preserve_whitespace_elements ⇒ Object
Element names where whitespace is PRESERVED exactly (no manipulation). All whitespace characters are significant in these elements.
214 215 216 |
# File 'lib/canon/config.rb', line 214 def preserve_whitespace_elements @resolver.resolve(:preserve_whitespace_elements) || [] end |
#profile ⇒ Object
Profile accessor with ENV override support
193 194 195 |
# File 'lib/canon/config.rb', line 193 def profile @resolver.resolve(:profile) end |
#profile=(value) ⇒ Object
197 198 199 |
# File 'lib/canon/config.rb', line 197 def profile=(value) @resolver.set_programmatic(:profile, value) end |
#profile_options ⇒ Hash
Return all profile-sourced values from the resolver, excluding the :profile key itself (which is accessed via #profile). These are the YAML-profile settings (e.g., preserve_whitespace_elements) that are stored in the resolver’s profile layer but not exposed through the built-in MATCH_PROFILES system.
208 209 210 |
# File 'lib/canon/config.rb', line 208 def @resolver.profile.except(:profile) end |
#reset! ⇒ Object
187 188 189 190 |
# File 'lib/canon/config.rb', line 187 def reset! @resolver = build_resolver(@format) @options = {} end |
#strip_whitespace_elements ⇒ Object
Element names where whitespace-only text nodes are STRIPPED.
225 226 227 |
# File 'lib/canon/config.rb', line 225 def strip_whitespace_elements @resolver.resolve(:strip_whitespace_elements) || [] end |
#to_h ⇒ Object
Build match options from profile and options
230 231 232 233 234 235 |
# File 'lib/canon/config.rb', line 230 def to_h result = {} result[:match_profile] = profile if profile result[:match] = @options if @options && !@options.empty? result end |