Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created June 30, 2020 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/e77057fbd0cfeab2e0677d2b5cae2fee to your computer and use it in GitHub Desktop.
Save havenwood/e77057fbd0cfeab2e0677d2b5cae2fee to your computer and use it in GitHub Desktop.
Tracking some packages
# frozen_string_literal: true
module Tracker
FILENAME = 'tracking.txt'
SEPARATOR = ': '
OPEN_SESAME = 'open'
OPENING = "Opening %<item>s ...\n"
module_function
def track
File.foreach(FILENAME) do |line|
line.partition(SEPARATOR).then do |item, _separator, url|
printf OPENING, item: item
system OPEN_SESAME, url
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment