summaryrefslogtreecommitdiff
path: root/lib/atlassian/jira_issue_key_extractor.rb
blob: 881ba4544b24a80ae60ab35529e6de40477db564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

module Atlassian
  class JiraIssueKeyExtractor
    def self.has_keys?(...)
      new(...).issue_keys.any?
    end

    def initialize(*text, custom_regex: nil)
      @text = text.join(' ')
      @match_regex = custom_regex || Gitlab::Regex.jira_issue_key_regex
    end

    def issue_keys
      @text.scan(@match_regex).flatten.uniq
    end
  end
end