Class: Dnkey::API

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

Class Method Summary collapse

Class Method Details

.get(domain, options = Dnkey::default_options) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/dnkey.rb', line 12

def self.get(domain, options=Dnkey::default_options)
  keys = get_txt_entries(domain, options).answer.find_all do |answer|
    value = answer.strings.first
    value.include? "dnkey-#{options[:key].to_s}"
  end
  keys.map.each {|key| key.rdata.first.split('=').last.strip}
end

.get_all(domain, options = Dnkey::default_options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dnkey.rb', line 20

def self.get_all(domain, options=Dnkey::default_options)
  keys = get_txt_entries(domain, options).answer.find_all do |answer|
    value = answer.strings.first
    value.include? "dnkey-"
  end
  result = {}
  keys.each do |key|
    entry = key.rdata.first.split('=')
    result[entry.first.gsub('dnkey-','').to_sym] ||= []
    result[entry.first.gsub('dnkey-','').to_sym] << entry.last.strip
  end
  result
end