class Dmarcurator::ImportReports
Import DMARC XML reports into DB
Attributes
db[R]
reports_path[R]
Public Class Methods
new(db_uri:, reports_path:)
click to toggle source
# File lib/dmarcurator/import_reports.rb, line 9 def initialize(db_uri:, reports_path:) @db = Sequel.connect(db_uri) @reports_path = reports_path end
Public Instance Methods
run()
click to toggle source
# File lib/dmarcurator/import_reports.rb, line 14 def run puts "Importing #{reports_path}" Dir.foreach(reports_path) do |path| next if path == '.' || path == '..' || File.extname(path) != ".xml" puts " #{path}" parsed_report = ::Dmarcurator::Parser::Report.new(xml: "#{reports_path}/#{path}") ::Dmarcurator::Store::Report.import_parsed(db: db, parsed: parsed_report) end puts "Done importing :)" end