Sha256: b8140fc95ce82c26c8d7632ac6c475d4b755d032accd0c08f376a38bcbc4207f

Contents?: true

Size: 920 Bytes

Versions: 4

Compression:

Stored size: 920 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "open-uri"
require "json"

urls = %w[
  https://raw.githubusercontent.com/ivolo/disposable-email-domains/master/index.json
  https://raw.githubusercontent.com/andreis/disposable-email-domains/master/domains.json
  https://raw.githubusercontent.com/FGRibreau/mailchecker/master/list.txt
  https://raw.githubusercontent.com/willwhite/freemail/master/data/disposable.txt
]

domains = urls.each_with_object([]) do |url, buffer|
  ext = File.extname(url)

  result = case ext
           when ".json"
             JSON.parse(URI.open(url).read)
           when ".txt"
             URI.open(url).read.lines.map(&:chomp)
           else
             raise "Unknown extension"
           end

  buffer.push(*result)
end

domains.map!(&:downcase)
domains.uniq!
domains.sort!

File.open("./data/disposable.json", "w") do |file|
  file << JSON.pretty_generate(domains)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
validators-3.1.1 bin/sync-disposable-hostnames
validators-3.1.0 bin/sync-disposable-hostnames
validators-3.0.5 bin/sync-disposable-hostnames
validators-3.0.4 bin/sync-disposable-hostnames