class FetchEmails
Public Class Methods
new()
click to toggle source
# File lib/renuo/cli/app/fetch_emails.rb, line 7 def initialize @email_list_url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vSqPiedBeGk0N75cxZApEohj5LrIWlHWUxTjfhkmK9aOsUltcqCn24sD1haIasUjVfd8UT8VdUKUc4h/pub?gid=703649940&single=true&output=csv" end
Public Instance Methods
fetch_emails()
click to toggle source
# File lib/renuo/cli/app/fetch_emails.rb, line 11 def fetch_emails response = get_emails(@email_list_url) response = handle_redirection(response) if response.is_a?(Net::HTTPRedirection) format_response(response) end
run(_args)
click to toggle source
# File lib/renuo/cli/app/fetch_emails.rb, line 17 def run(_args) say "# Here is a complete list of Renuo email addresses".colorize :green say fetch_emails.join("\n") end
Private Instance Methods
format_response(response)
click to toggle source
# File lib/renuo/cli/app/fetch_emails.rb, line 34 def format_response(response) response.body.gsub("\r\n", "\n").split("\n").reject { |add| add == "n/a" } end
get_emails(url)
click to toggle source
# File lib/renuo/cli/app/fetch_emails.rb, line 24 def get_emails(url) uri = URI.parse(url) Net::HTTP.get_response(uri) end
handle_redirection(response)
click to toggle source
# File lib/renuo/cli/app/fetch_emails.rb, line 29 def handle_redirection(response) location = response["location"] get_emails(location) end