Module: FeedImport

Defined in:
lib/rbkb/plug/feed_import.rb

Class Method Summary collapse

Class Method Details

.import_dump(file) ⇒ Object

Imports from hexdumps separated by “%” and merged by ‘,’



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rbkb/plug/feed_import.rb', line 53

def import_dump(file)
  ret = []
  dat = File.read(file)
  dat.strip.split(/^%$/).each do |msg|
    ret << ""
    msg.strip.split(/^,$/).each do |chunk|
      ret[-1] << chunk.strip.dehexdump
    end
  end
  return ret
end

.import_pcapObject

.import_rawfiles(glob_pat) ⇒ Object

Imports raw messages in files by a glob pattern (i.e. /tmp/foo/msgs.*) Manage filenames so that they’re in the right order on import. See Dir.glob for valid globbing patterns.



69
70
71
# File 'lib/rbkb/plug/feed_import.rb', line 69

def import_rawfiles(glob_pat)
  Dir.glob(glob_pat).map { |f| File.read(f) }
end

.import_yaml(file) ⇒ Object

Imports an array from yaml



43
44
45
46
47
48
# File 'lib/rbkb/plug/feed_import.rb', line 43

def import_yaml(file)
  unless ( ret = YAML.load_file(file) ).kind_of? Array
    raise "#{file.inspect} did not provide an array"
  end
  return ret
end