mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Basic whois data generator
This commit is contained in:
parent
6113401eb0
commit
c7acd7dab1
1 changed files with 30 additions and 0 deletions
30
lib/tasks/whois.rake
Normal file
30
lib/tasks/whois.rake
Normal file
|
@ -0,0 +1,30 @@
|
|||
desc 'Commands for whois'
|
||||
|
||||
desc 'generate whois files'
|
||||
task 'whois:generate' => :environment do
|
||||
Dir.mkdir("./tmp/whois") unless File.exists?("./tmp/whois") #a folder for ze stuff
|
||||
|
||||
alphabet = (("a".."z").to_a << %w(ö õ ü ä) ).flatten!
|
||||
@domains = {}
|
||||
alphabet.each do |letter|
|
||||
domains = Domain.where([ 'name LIKE ?', "#{letter}%" ])
|
||||
@domains[letter] = {}
|
||||
|
||||
domains.each do |domain|
|
||||
@domains[letter][domain.name] = {
|
||||
valid_to: domain.valid_to,
|
||||
status: domain.status,
|
||||
contacts: [
|
||||
{ name: domain.owner_contact.name, email: domain.owner_contact.email },
|
||||
{ registrar: domain.registrar.name, address: domain.registrar.address }
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@domains.each do |k,v|
|
||||
file = File.open("tmp/whois/#{k}_domain.yaml", 'w') { |f| f.write(v.to_yaml) }
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue