Class: OutboundHosts

Inherits:
Object
  • Object
show all
Defined in:
lib/support/outbound_hosts.rb

Class Method Summary collapse

Class Method Details

.listObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/support/outbound_hosts.rb', line 5

def self.list
  hosts = Set.new
  invalid_lines = Set.new

  Dir['lib/**/*.rb'].each do |file|
    content = File.read(file)

    content.each_line do |line|
      next if line =~ /homepage_url/

      if line =~ /("|')(https:\/\/[^'"]*)("|')/
        begin
          uri = URI.parse($2)
          hosts << "#{uri.host}:#{uri.port}"
        rescue URI::InvalidURIError
          invalid_lines << line
        end
      end
    end
  end

  [hosts, invalid_lines]
end