Class: Dap::Filter::FilterSplitDomains

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) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/dap/filter/names.rb', line 40

def expand(data)
  names = []
  bits  = data.split('.')
  while (bits.length > 1)
    names << bits.join('.')
    bits.shift
  end
  names
end

#process(doc) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dap/filter/names.rb', line 28

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