Last active
August 29, 2015 14:09
-
-
Save cmittendorf/42d7c4c9fe6179a2c0c8 to your computer and use it in GitHub Desktop.
A Ruby Automator action for opening all URLs and JIRA ticket ids from the input string.
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
require 'uri' | |
# without force_encoding ruby will throw an | |
# "invalid byte sequence in US-ASCII" exception | |
# when running this script from Automator | |
input = ARGF.read.force_encoding("UTF-8") | |
# scan for JIRA Ticket IDs like MYPROJECT-42 | |
input.scan(/([A-Z]+\-[0-9]+)/).each do |id| | |
url = "https://<your JIRA server>/browse/#{id[0]}" | |
`open #{url}` | |
end | |
# extract all other URLs from the input string | |
URI.extract(input, ['http','https']).each do |url| | |
`open #{url}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment