Module: Ace::Bundle::Atoms::ContentChecker

Defined in:
lib/ace/bundle/atoms/content_checker.rb

Overview

Pure functions for checking section content types Used by both SectionProcessor and ContextLoader

Class Method Summary collapse

Class Method Details

.has_commands_content?(section_data) ⇒ Boolean

Checks if section has commands content

Parameters:

  • section_data (Hash)

    section data with symbol or string keys

Returns:

  • (Boolean)

    true if section has commands



32
33
34
# File 'lib/ace/bundle/atoms/content_checker.rb', line 32

def has_commands_content?(section_data)
  !!(section_data[:commands] || section_data["commands"])
end

.has_content_content?(section_data) ⇒ Boolean

Checks if section has inline content

Parameters:

  • section_data (Hash)

    section data with symbol or string keys

Returns:

  • (Boolean)

    true if section has content



39
40
41
# File 'lib/ace/bundle/atoms/content_checker.rb', line 39

def has_content_content?(section_data)
  !!(section_data[:content] || section_data["content"])
end

.has_diffs_content?(section_data) ⇒ Boolean

Checks if section has diffs content Note: For _processed_diffs, we check for non-empty arrays to avoid treating empty arrays as valid diff content (which would trigger merge logic unnecessarily)

Parameters:

  • section_data (Hash)

    section data with symbol or string keys

Returns:

  • (Boolean)

    true if section has ranges, diffs, or non-empty _processed_diffs



15
16
17
18
19
20
# File 'lib/ace/bundle/atoms/content_checker.rb', line 15

def has_diffs_content?(section_data)
  ranges = section_data[:ranges] || section_data["ranges"]
  diffs = section_data[:diffs] || section_data["diffs"]
  processed_diffs = section_data[:_processed_diffs] || section_data["_processed_diffs"]
  !!(ranges || diffs || (processed_diffs.is_a?(Array) && processed_diffs.any?))
end

.has_files_content?(section_data) ⇒ Boolean

Checks if section has files content

Parameters:

  • section_data (Hash)

    section data with symbol or string keys

Returns:

  • (Boolean)

    true if section has files



25
26
27
# File 'lib/ace/bundle/atoms/content_checker.rb', line 25

def has_files_content?(section_data)
  !!(section_data[:files] || section_data["files"])
end