Class: Dap::Filter::FilterPrependSubdomains

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/dap/filter/names.rb

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#expand(data, names) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/dap/filter/names.rb', line 66

def expand(data, names)
  outp = [ data ]
  bits = data.split(".")
  subs = names.split(",")

  # Avoid www.www.domain.tld and mail.www.domain.tld
  return outp if subs.include?(bits.first)
  subs.each do |sub|
    outp << "#{sub}.#{data}"
  end

  outp
end

#process(doc) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dap/filter/names.rb', line 54

def process(doc)
  lines = [ ]
  self.opts.each_pair do |k,v|
    if doc.has_key?(k)
      expand(doc[k], v).each do |line|
        lines << doc.merge({ k => line })
      end
    end
  end
 lines.length == 0 ? [ ] : [ lines ]
end