Sha256: 4a27d4d3fdc831277c0d052ef42cc78e16993c70ee8d57c778c9a9478359e805
Contents?: true
Size: 906 Bytes
Versions: 12
Compression:
Stored size: 906 Bytes
Contents
require 'net/http' require 'uri' class FetchEmails def initialize @email_list_url = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vSqPiedBeGk0N75cxZApEohj5LrIWlHWUxTjfhkmK9aOsUltcqCn24sD1haIasUjVfd8UT8VdUKUc4h/pub?gid=703649940&single=true&output=csv' end def fetch_emails response = get_emails(@email_list_url) response = handle_redirection(response) if response.is_a?(Net::HTTPRedirection) format_response(response) end def run(_args) say '# Here is a complete list of Renuo email addresses'.colorize :green say fetch_emails.join("\n") end private def get_emails(url) uri = URI.parse(url) Net::HTTP.get_response(uri) end def handle_redirection(response) location = response['location'] get_emails(location) end def format_response(response) response.body.gsub(/\r\n/, "\n").split("\n").reject { |add| add == 'n/a' } end end
Version data entries
12 entries across 12 versions & 1 rubygems