Class: Dnkey::API
- Inherits:
-
Object
- Object
- Dnkey::API
- Defined in:
- lib/dnkey.rb
Class Method Summary collapse
- .get(domain, options = Dnkey::default_options) ⇒ Object
- .get_all(domain, options = Dnkey::default_options) ⇒ Object
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, =Dnkey::) keys = get_txt_entries(domain, ).answer.find_all do |answer| value = answer.strings.first value.include? "dnkey-#{[: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, =Dnkey::) keys = get_txt_entries(domain, ).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 |