Class: Apadmi::Grout::IssuesFromChangelogAction
- Inherits:
-
Object
- Object
- Apadmi::Grout::IssuesFromChangelogAction
- Defined in:
- lib/apadmi/grout/actions/issues_from_changelog_action.rb
Overview
Finds and returns a list of all the issues who's ids exist in the given changelog
Instance Method Summary collapse
-
#initialize(board_service, ticket_prefix, logger) ⇒ IssuesFromChangelogAction
constructor
A new instance of IssuesFromChangelogAction.
-
#issue_ids_from_changelog(changelog) ⇒ Array<String>
List of issue ids from changelog.
-
#run(changelog) ⇒ Array<Apadmi::Grout::Issue>
List of issues from changelog.
Constructor Details
#initialize(board_service, ticket_prefix, logger) ⇒ IssuesFromChangelogAction
Returns a new instance of IssuesFromChangelogAction.
10 11 12 13 14 |
# File 'lib/apadmi/grout/actions/issues_from_changelog_action.rb', line 10 def initialize(board_service, ticket_prefix, logger) @board_service = board_service @logger = logger @ticket_prefix = ticket_prefix end |
Instance Method Details
#issue_ids_from_changelog(changelog) ⇒ Array<String>
Returns list of issue ids from changelog.
27 28 29 30 31 32 33 34 |
# File 'lib/apadmi/grout/actions/issues_from_changelog_action.rb', line 27 def issue_ids_from_changelog(changelog) # Changelog often has the pull request number in it, this can mess up the parsing so strip it out if we can changelog = changelog.gsub(/\(pull request.*\)/, "") changelog.scan(/(#{@ticket_prefix}\d+)/).flatten.uniq.filter do |id| Integer(id.delete_prefix(@ticket_prefix), exception: false) != 0 # Filter out tickets with ID 0 since these are always placeholders end end |
#run(changelog) ⇒ Array<Apadmi::Grout::Issue>
Returns list of issues from changelog.
18 19 20 21 22 23 |
# File 'lib/apadmi/grout/actions/issues_from_changelog_action.rb', line 18 def run(changelog) ids = issue_ids_from_changelog(changelog) @logger.("Found issue ids: #{ids.join(", ")}") @board_service.find_issues_by_keys(ids) end |