Module: SnippetCli::ConflictDetector

Defined in:
lib/snippet_cli/conflict_detector.rb

Constant Summary collapse

TRIGGER_KEYS =
%w[trigger triggers regex].freeze

Class Method Summary collapse

Class Method Details

.extract_triggers(content) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/snippet_cli/conflict_detector.rb', line 9

def self.extract_triggers(content)
  return [] if content.nil? || content.strip.empty?

  doc = Psych.parse(content)
  return [] unless doc

  root = doc.root
  return [] unless root.is_a?(Psych::Nodes::Mapping)

  matches_seq = find_matches_sequence(root)
  return [] unless matches_seq

  extract_from_sequence(matches_seq)
end