Module: FeedImport
- Defined in:
- lib/rbkb/plug/feed_import.rb
Class Method Summary collapse
-
.import_dump(file) ⇒ Object
Imports from hexdumps separated by "%" and merged by ','.
- .import_pcap ⇒ Object
-
.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.
-
.import_yaml(file) ⇒ Object
Imports an array from yaml.
Class Method Details
.import_dump(file) ⇒ Object
Imports from hexdumps separated by "%" and merged by ','
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rbkb/plug/feed_import.rb', line 50 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 ret end |
.import_pcap ⇒ Object
.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.
66 67 68 |
# File 'lib/rbkb/plug/feed_import.rb', line 66 def import_rawfiles(glob_pat) Dir.glob(glob_pat).map { |f| File.read(f) } end |
.import_yaml(file) ⇒ Object
Imports an array from yaml
40 41 42 43 44 45 46 |
# File 'lib/rbkb/plug/feed_import.rb', line 40 def import_yaml(file) unless (ret = YAML.load_file(file)).is_a? Array raise "#{file.inspect} did not provide an array" end ret end |