Last active
January 1, 2016 02:19
-
-
Save StephenOTT/8078793 to your computer and use it in GitHub Desktop.
Get Tasks from a GitHub Issue Body or Comment using RegEx to parse issue body or issue comment for a task.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_comment_tasks (commentBody, taskStatus = :incomplete) | |
| tasks = [] | |
| startStringOpen = /\-\s\[\s\]\s/ | |
| startStringClosed = /\-\s\[x\]\s/ | |
| endString = /[\r\n]|\z/ | |
| if taskStatus == :incomplete | |
| tasksInBody = commentBody.scan(/#{startStringOpen}(.*?)#{endString}/) | |
| tasksInBody.each do |x| | |
| tasks << x[0] | |
| end | |
| elsif taskStatus == :complete | |
| tasksInBody = commentBody.scan(/#{startStringClosed}(.*?)#{endString}/) | |
| tasksInBody.each do |x| | |
| tasks << x[0] | |
| end | |
| end | |
| return tasks | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment